mirror of
https://github.com/BookStackApp/BookStack.git
synced 2026-07-15 21:31:36 +03:00
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:
@@ -29,4 +29,4 @@ jobs:
|
|||||||
run: npm run ts:lint
|
run: npm run ts:lint
|
||||||
|
|
||||||
- name: Run JavaScript tests
|
- name: Run JavaScript tests
|
||||||
run: npm run test
|
run: npm run test:ci
|
||||||
@@ -16,26 +16,36 @@ jobs:
|
|||||||
if: ${{ github.ref != 'refs/heads/l10n_development' }}
|
if: ${{ github.ref != 'refs/heads/l10n_development' }}
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
image: docker.io/library/node:24-trixie
|
image: docker.io/setupphp/node:noble
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
php: ['8.2', '8.3', '8.4', '8.5']
|
php: ['8.2', '8.3', '8.4', '8.5']
|
||||||
services:
|
env:
|
||||||
mysql:
|
phpextensions: gd, mbstring, json, curl, xml, mysql, ldap, gmp
|
||||||
image: docker.io/library/mariadb:12.2.2-noble
|
phpextensioncachekey: cache-v1
|
||||||
env:
|
|
||||||
MARIADB_USER: bookstack-test
|
|
||||||
MARIADB_PASSWORD: bookstack-test
|
|
||||||
MARIADB_DATABASE: bookstack-test
|
|
||||||
MARIADB_ROOT_PASSWORD: password
|
|
||||||
steps:
|
steps:
|
||||||
- uses: https://code.forgejo.org/actions/checkout@v6
|
- 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
|
- name: Setup PHP
|
||||||
uses: https://github.com/shivammathur/setup-php@v2
|
uses: https://github.com/shivammathur/setup-php@v2
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php }}
|
php-version: ${{ matrix.php }}
|
||||||
extensions: gd, mbstring, json, curl, xml, mysql, ldap, gmp
|
extensions: ${{ env.phpextensions }}
|
||||||
|
|
||||||
- name: Get Composer Cache Directory
|
- name: Get Composer Cache Directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
@@ -54,14 +64,25 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.GH_TOKEN }}"}}'
|
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
|
- name: Migrate and seed the database
|
||||||
env:
|
env:
|
||||||
TEST_DATABASE_URL: 'mysql://bookstack-test:bookstack-test@mysql/bookstack-test'
|
TEST_DATABASE_URL: 'mysql://bookstack-test:bookstack-test@localhost/bookstack-test'
|
||||||
run: |
|
run: |
|
||||||
php${{ matrix.php }} artisan migrate --force -n --database=mysql_testing
|
php${{ matrix.php }} artisan migrate --force -n --database=mysql_testing
|
||||||
php${{ matrix.php }} artisan db:seed --force -n --class=DummyContentSeeder --database=mysql_testing
|
php${{ matrix.php }} artisan db:seed --force -n --class=DummyContentSeeder --database=mysql_testing
|
||||||
|
|
||||||
- name: Run PHP tests
|
- name: Run PHP tests
|
||||||
env:
|
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
|
run: php${{ matrix.php }} ./vendor/bin/phpunit
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
"lint": "eslint \"resources/**/*.js\" \"resources/**/*.mjs\"",
|
"lint": "eslint \"resources/**/*.js\" \"resources/**/*.mjs\"",
|
||||||
"fix": "eslint --fix \"resources/**/*.js\" \"resources/**/*.mjs\"",
|
"fix": "eslint --fix \"resources/**/*.js\" \"resources/**/*.mjs\"",
|
||||||
"ts:lint": "tsc --noEmit",
|
"ts:lint": "tsc --noEmit",
|
||||||
"test": "jest"
|
"test": "jest",
|
||||||
|
"test:ci": "jest --maxWorkers=1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/js": "^10.0.1",
|
"@eslint/js": "^10.0.1",
|
||||||
|
|||||||
Reference in New Issue
Block a user