Skip to content

Commit b918a4c

Browse files
committed
move to github actions — wip
1 parent 5765215 commit b918a4c

4 files changed

Lines changed: 120 additions & 55 deletions

File tree

.github/workflows/tests.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
phpunit:
9+
name: PHPUnit
10+
runs-on: ubuntu-24.04
11+
12+
services:
13+
mysql:
14+
image: mysql:8.0
15+
env:
16+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
17+
MYSQL_DATABASE: wordpress
18+
ports:
19+
- 3306:3306
20+
options: >-
21+
--health-cmd="mysqladmin ping --host=127.0.0.1 --user=root"
22+
--health-interval=10s
23+
--health-timeout=5s
24+
--health-retries=5
25+
redis:
26+
image: redis:7
27+
ports:
28+
- 6379:6379
29+
options: >-
30+
--health-cmd="redis-cli ping"
31+
--health-interval=10s
32+
--health-timeout=5s
33+
--health-retries=5
34+
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- name: Setup PHP
40+
uses: shivammathur/setup-php@v2
41+
with:
42+
php-version: '8.4'
43+
extensions: json, mbstring, openssl, mysqli, pdo_mysql, redis, memcached
44+
coverage: none
45+
tools: composer:v2
46+
47+
- name: Get Composer cache directory
48+
id: composer-cache
49+
run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT"
50+
51+
- name: Cache Composer dependencies
52+
uses: actions/cache@v4
53+
with:
54+
path: ${{ steps.composer-cache.outputs.dir }}
55+
key: ${{ runner.os }}-composer-${{ hashFiles('composer.lock') }}
56+
restore-keys: ${{ runner.os }}-composer-
57+
58+
- name: Install dependencies
59+
run: composer install --no-interaction --prefer-dist
60+
61+
- name: Setup databases
62+
run: |
63+
mysql --host=127.0.0.1 --user=root --execute="SET NAMES utf8; CREATE DATABASE IF NOT EXISTS wordpress;"
64+
mysql --host=127.0.0.1 --user=root --execute="SET NAMES utf8; CREATE DATABASE IF NOT EXISTS tr_v51_alt;"
65+
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));"
66+
67+
- name: Setup WordPress
68+
run: bin/setup-ci.sh
69+
70+
- name: Run tests
71+
run: vendor/bin/phpunit

.travis.yml

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

bin/setup-ci.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
WP_PATH="${WP_PATH:-wordpress}"
5+
DB_HOST="${DB_HOST:-127.0.0.1}"
6+
DB_USER="${DB_USER:-root}"
7+
DB_PASSWORD="${DB_PASSWORD:-}"
8+
DB_NAME="${DB_NAME:-wordpress}"
9+
ALT_DB_NAME="${ALT_DB_NAME:-tr_v51_alt}"
10+
11+
if [ ! -f wp-cli.phar ]; then
12+
curl -fsSL -o wp-cli.phar https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
13+
fi
14+
15+
chmod +x wp-cli.phar
16+
17+
if [ ! -d typerocket ]; then
18+
composer create-project typerocket/typerocket typerocket --prefer-dist --no-dev --no-interaction
19+
fi
20+
21+
if [ ! -f "$WP_PATH/wp-load.php" ]; then
22+
./wp-cli.phar core download --allow-root --path="$WP_PATH"
23+
fi
24+
25+
if [ ! -f "$WP_PATH/wp-config.php" ]; then
26+
./wp-cli.phar core config \
27+
--allow-root \
28+
--dbname="$DB_NAME" \
29+
--dbuser="$DB_USER" \
30+
--dbpass="$DB_PASSWORD" \
31+
--dbhost="$DB_HOST" \
32+
--path="$WP_PATH"
33+
fi
34+
35+
if ! ./wp-cli.phar core is-installed --allow-root --path="$WP_PATH"; then
36+
./wp-cli.phar core install \
37+
--allow-root \
38+
--admin_name=admin \
39+
--admin_password=admin \
40+
--admin_email=admin@example.com \
41+
--url=http://127.0.0.1 \
42+
--title=WordPress \
43+
--path="$WP_PATH"
44+
fi
45+
46+
./wp-cli.phar config set TYPEROCKET_ALT_DATABASE_USER "$DB_USER" --add --allow-root --path="$WP_PATH"
47+
./wp-cli.phar config set TYPEROCKET_ALT_DATABASE_PASSWORD "$DB_PASSWORD" --add --allow-root --path="$WP_PATH"
48+
./wp-cli.phar config set TYPEROCKET_ALT_DATABASE_DATABASE "$ALT_DB_NAME" --add --allow-root --path="$WP_PATH"
49+
./wp-cli.phar config set TYPEROCKET_ALT_DATABASE_HOST "$DB_HOST" --add --allow-root --path="$WP_PATH"

bin/travis.sh

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

0 commit comments

Comments
 (0)