mirror of
https://github.com/notf0und/SGS
synced 2026-07-18 02:31:08 +00:00
101 lines
2.7 KiB
YAML
101 lines
2.7 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
pull_request:
|
|
branches: ['**']
|
|
|
|
jobs:
|
|
test:
|
|
name: Run test suite
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '8.4'
|
|
extensions: mbstring
|
|
coverage: none
|
|
|
|
- name: Install Composer dependencies
|
|
working-directory: www
|
|
run: composer install --no-interaction --prefer-dist --optimize-autoloader
|
|
|
|
- name: Set up environment
|
|
working-directory: www
|
|
run: |
|
|
cp .env.example .env
|
|
php artisan key:generate
|
|
|
|
- name: Build frontend assets
|
|
working-directory: www
|
|
run: npm ci && npm run build
|
|
|
|
- name: Run tests
|
|
working-directory: www
|
|
run: php artisan test
|
|
|
|
lint:
|
|
name: Check code style (Pint)
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '8.4'
|
|
extensions: mbstring
|
|
coverage: none
|
|
|
|
- name: Install Composer dependencies
|
|
working-directory: www
|
|
run: composer install --no-interaction --prefer-dist --optimize-autoloader
|
|
|
|
- name: Run Pint
|
|
working-directory: www
|
|
run: ./vendor/bin/pint --test
|
|
|
|
update-checklist:
|
|
name: Update PR checklist
|
|
runs-on: ubuntu-latest
|
|
if: always() && github.event_name == 'pull_request'
|
|
needs: [test, lint]
|
|
permissions:
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const testsPass = '${{ needs.test.result }}' === 'success';
|
|
const lintPass = '${{ needs.lint.result }}' === 'success';
|
|
|
|
const check = (pass) => pass ? 'x' : ' ';
|
|
|
|
const { data: pr } = await github.rest.pulls.get({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
pull_number: context.payload.pull_request.number,
|
|
});
|
|
|
|
const body = (pr.body ?? '').replace(
|
|
/- \[[ x]\] Tests pass \(`php artisan test`\)/,
|
|
`- [${check(testsPass)}] Tests pass (\`php artisan test\`)`
|
|
).replace(
|
|
/- \[[ x]\] Code style passes \(`\.\/vendor\/bin\/pint --test`\)/,
|
|
`- [${check(lintPass)}] Code style passes (\`./vendor/bin/pint --test\`)`
|
|
);
|
|
|
|
await github.rest.pulls.update({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
pull_number: context.payload.pull_request.number,
|
|
body,
|
|
});
|