CI: Made actions more efficient (#6124)

Updates our CI process to be more efficient by:

- Uses setupphp/node image for more direct access to desired PHP versions.
- Adds php extension caching via https://github.com/shivammathur/cache-extensions
- Reverted to using MySQL in-test-container to reduce syscalls across the container stack which seemed to be slowing things down.
- Update JS testing to only use one worker, to avoid exhausting all CPUs. I think it was attempting to use all threads on the host system before, causing the machine to lock up, since only a subset of cores were available to the environment.

Reviewed-on: https://codeberg.org/bookstack/bookstack/pulls/6124
This commit is contained in:
Dan Brown
2026-05-08 17:03:27 +02:00
committed by Dan Brown
parent 85baa6e9c8
commit 50d3be4c95
3 changed files with 36 additions and 14 deletions

View File

@@ -29,4 +29,4 @@ jobs:
run: npm run ts:lint
- name: Run JavaScript tests
run: npm run test
run: npm run test:ci

View File

@@ -16,26 +16,36 @@ jobs:
if: ${{ github.ref != 'refs/heads/l10n_development' }}
runs-on: docker
container:
image: docker.io/library/node:24-trixie
image: docker.io/setupphp/node:noble
strategy:
matrix:
php: ['8.2', '8.3', '8.4', '8.5']
services:
mysql:
image: docker.io/library/mariadb:12.2.2-noble
env:
MARIADB_USER: bookstack-test
MARIADB_PASSWORD: bookstack-test
MARIADB_DATABASE: bookstack-test
MARIADB_ROOT_PASSWORD: password
env:
phpextensions: gd, mbstring, json, curl, xml, mysql, ldap, gmp
phpextensioncachekey: cache-v1
steps:
- uses: https://code.forgejo.org/actions/checkout@v6
- name: Setup cache environment
id: extcache
uses: https://github.com/shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php }}
extensions: ${{ env.phpextensions }}
key: ${{ env.phpextensioncachekey }}
- name: Cache extensions
uses: https://code.forgejo.org/actions/cache@v5
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
- name: Setup PHP
uses: https://github.com/shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: gd, mbstring, json, curl, xml, mysql, ldap, gmp
extensions: ${{ env.phpextensions }}
- name: Get Composer Cache Directory
id: composer-cache
@@ -54,14 +64,25 @@ jobs:
env:
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GH_TOKEN }}"}}'
- name: Start MySQL
run: |
sudo systemctl start mysql
- name: Create database & user
run: |
mysql -uroot -proot -e 'CREATE DATABASE IF NOT EXISTS `bookstack-test`;'
mysql -uroot -proot -e "CREATE USER 'bookstack-test'@'localhost' IDENTIFIED WITH mysql_native_password BY 'bookstack-test';"
mysql -uroot -proot -e "GRANT ALL ON \`bookstack-test\`.* TO 'bookstack-test'@'localhost';"
mysql -uroot -proot -e 'FLUSH PRIVILEGES;'
- name: Migrate and seed the database
env:
TEST_DATABASE_URL: 'mysql://bookstack-test:bookstack-test@mysql/bookstack-test'
TEST_DATABASE_URL: 'mysql://bookstack-test:bookstack-test@localhost/bookstack-test'
run: |
php${{ matrix.php }} artisan migrate --force -n --database=mysql_testing
php${{ matrix.php }} artisan db:seed --force -n --class=DummyContentSeeder --database=mysql_testing
- name: Run PHP tests
env:
TEST_DATABASE_URL: 'mysql://bookstack-test:bookstack-test@mysql/bookstack-test'
TEST_DATABASE_URL: 'mysql://bookstack-test:bookstack-test@localhost/bookstack-test'
run: php${{ matrix.php }} ./vendor/bin/phpunit

View File

@@ -15,7 +15,8 @@
"lint": "eslint \"resources/**/*.js\" \"resources/**/*.mjs\"",
"fix": "eslint --fix \"resources/**/*.js\" \"resources/**/*.mjs\"",
"ts:lint": "tsc --noEmit",
"test": "jest"
"test": "jest",
"test:ci": "jest --maxWorkers=1"
},
"devDependencies": {
"@eslint/js": "^10.0.1",