Skip to content

Commit 9ac28ac

Browse files
committed
update tests for github actions — wip
1 parent a5bab1a commit 9ac28ac

3 files changed

Lines changed: 43 additions & 95 deletions

File tree

.github/workflows/tests.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ jobs:
99
name: PHPUnit
1010
runs-on: ubuntu-24.04
1111

12-
defaults:
13-
run:
14-
working-directory: vendor/typerocket/core
15-
1612
services:
1713
mysql:
1814
image: mysql:8.0
@@ -37,11 +33,6 @@ jobs:
3733
--health-retries=5
3834
3935
steps:
40-
- name: Checkout
41-
uses: actions/checkout@v4
42-
with:
43-
path: vendor/typerocket/core
44-
4536
- name: Setup PHP
4637
uses: shivammathur/setup-php@v2
4738
with:
@@ -58,20 +49,28 @@ jobs:
5849
uses: actions/cache@v4
5950
with:
6051
path: ${{ steps.composer-cache.outputs.dir }}
61-
key: ${{ runner.os }}-composer-${{ hashFiles('vendor/typerocket/core/composer.lock') }}
52+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
6253
restore-keys: ${{ runner.os }}-composer-
6354

64-
- name: Install dependencies
65-
run: composer install --no-interaction --prefer-dist
55+
- name: Create TypeRocket root install
56+
run: |
57+
composer create-project --prefer-dist typerocket/typerocket .
58+
rm -rf vendor/typerocket/core
59+
60+
- name: Checkout core package
61+
uses: actions/checkout@v4
62+
with:
63+
path: vendor/typerocket/core
6664

6765
- name: Setup databases
6866
run: |
6967
mysql --host=127.0.0.1 --user=root --execute="SET NAMES utf8; CREATE DATABASE IF NOT EXISTS wordpress;"
7068
mysql --host=127.0.0.1 --user=root --execute="SET NAMES utf8; CREATE DATABASE IF NOT EXISTS tr_v51_alt;"
7169
mysql --host=127.0.0.1 --user=root --database=tr_v51_alt --execute="CREATE TABLE IF NOT EXISTS some_table (id INT, text_field VARCHAR(255));"
7270
73-
- name: Setup WordPress
74-
run: bin/setup-ci.sh
71+
- name: Setup TypeRocket test install
72+
run: vendor/typerocket/core/bin/setup-github-actions.sh
7573

7674
- name: Run tests
75+
working-directory: vendor/typerocket/core
7776
run: vendor/bin/phpunit

bin/setup-ci.sh

Lines changed: 0 additions & 81 deletions
This file was deleted.

bin/setup-github-actions.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT_PATH="$(cd "$(dirname "$0")/../../../.." && pwd)"
5+
CORE_PATH="$ROOT_PATH/vendor/typerocket/core"
6+
DB_NAME="${DB_NAME:-wordpress}"
7+
DB_USER="${DB_USER:-root}"
8+
DB_PASSWORD="${DB_PASSWORD:-}"
9+
ALT_DB_NAME="${ALT_DB_NAME:-tr_v51_alt}"
10+
DB_HOST="${DB_HOST:-127.0.0.1}"
11+
12+
cd "$ROOT_PATH"
13+
14+
php galaxy root:install "$DB_NAME" "$DB_USER" "$DB_PASSWORD"
15+
16+
php galaxy config:seed
17+
18+
if ! grep -q "TYPEROCKET_ALT_DATABASE_DATABASE" wp-config.php; then
19+
sed -i "/\/\* That's all, stop editing! Happy publishing\. \*\//i\\
20+
define( 'TYPEROCKET_ALT_DATABASE_USER', '$DB_USER' );\\
21+
define( 'TYPEROCKET_ALT_DATABASE_PASSWORD', '$DB_PASSWORD' );\\
22+
define( 'TYPEROCKET_ALT_DATABASE_DATABASE', '$ALT_DB_NAME' );\\
23+
define( 'TYPEROCKET_ALT_DATABASE_HOST', '$DB_HOST' );\\
24+
define( 'TYPEROCKET_LOG_FILE_FOLDER', null );\\
25+
define( 'TYPEROCKET_GOOGLE_MAPS_API_KEY', '12345678910' );\\
26+
" wp-config.php
27+
fi
28+
29+
cd "$CORE_PATH"
30+
composer install --no-interaction --prefer-dist

0 commit comments

Comments
 (0)