API cleanup #622
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: pull_request | |
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#defining-environment-variables-for-a-single-workflow | |
# (cf. services.phpfpm.user in ../../docker-compose.yml) | |
env: | |
COMPOSE_USER: root | |
name: PR Review | |
jobs: | |
fail-for-do-not-merge: | |
if: contains(github.event.pull_request.labels.*.name, 'not ready for merge') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Fail if PR is labeled with not ready for merge | |
run: | | |
echo "This PR can't be merged, due to the 'not ready for merge' label." | |
exit 1 | |
changelog: | |
runs-on: ubuntu-latest | |
name: Changelog should be updated | |
strategy: | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Git fetch | |
run: git fetch | |
- name: Check that changelog has been updated. | |
run: git diff --exit-code origin/${{ github.base_ref }} -- CHANGELOG.md && exit 1 || exit 0 | |
test-composer-files: | |
name: Validate composer | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup PHP, with composer and extensions | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: 8.3 | |
extensions: ctype, dom, iconv, json, zip, gd, soap | |
coverage: none | |
tools: composer:v2 | |
# https://github.com/shivammathur/setup-php#cache-composer-dependencies | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- name: Cache dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-composer- | |
- name: Validate composer files | |
run: | | |
composer validate composer.json | |
- name: Check composer file is normalized | |
run: | | |
composer install --no-interaction --no-progress | |
composer normalize composer.json --dry-run | |
coding-standards-assets: | |
name: Assets - Check Coding Standards | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnorton5432/setup-task@v1 | |
- run: task coding-standards:assets:check | |
# Check for any changes (task …:check runs task …:apply) | |
- run: git diff --exit-code | |
coding-standards-markdown: | |
name: Markdown - Check Coding Standards | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnorton5432/setup-task@v1 | |
- run: task coding-standards:markdown:check | |
# Check for any changes (task …:check runs task …:apply) | |
- run: git diff --exit-code | |
coding-standards-php: | |
name: PHP - Check Coding Standards | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnorton5432/setup-task@v1 | |
- run: | | |
docker network create frontend | |
task compose -- up --detach | |
task composer -- install | |
task coding-standards:php:check | |
# Check for any changes (task …:check runs task …:apply) | |
- run: git diff --exit-code | |
coding-standards-twig: | |
name: Twig - Check Coding Standards | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnorton5432/setup-task@v1 | |
- run: | | |
docker network create frontend | |
task compose -- up --detach | |
task composer -- install | |
task coding-standards:twig:check | |
# Check for any changes (task …:check runs task …:apply) | |
- run: git diff --exit-code | |
code-analysis: | |
name: PHP - Code analysis | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnorton5432/setup-task@v1 | |
- run: | | |
docker network create frontend | |
task compose -- up --detach | |
task composer -- install | |
task code-analysis | |
coding-standards-custom-themes: | |
name: Yarn - Check Coding Standards in custom themes | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup docker network | |
run: docker network create frontend | |
- name: Install build dependencies | |
run: docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal install | |
- name: Check coding standards | |
run: docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal check-coding-standards | |
check-custom-theme-assets: | |
name: Check custom theme assets are up to date | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup docker network | |
run: docker network create frontend | |
- name: Install build dependencies | |
run: docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal install | |
- name: Build theme assets | |
run: docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal build | |
- name: Check for changes in built css | |
run: git diff --diff-filter=ACMRT --exit-code web/themes/custom/hoeringsportal/build | |
install-site: | |
name: Check that site can be installed | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install site | |
run: | | |
docker network create frontend | |
docker compose pull | |
docker compose up --detach | |
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect. | |
docker compose exec --user root phpfpm composer install --no-interaction | |
# Install the site | |
docker compose exec --user root phpfpm vendor/bin/drush site:install minimal --existing-config --yes | |
# Build theme assets | |
docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal install | |
docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal build | |
- name: Open site | |
run: | | |
# Open the site | |
echo $(docker compose exec phpfpm vendor/bin/drush --uri=http://$(docker compose port nginx 8080) user:login) | |
config-check: | |
name: Check that config is up to date | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install site | |
run: | | |
docker network create frontend | |
docker compose pull | |
docker compose up --detach | |
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect. | |
docker compose exec --user root phpfpm composer install --no-interaction | |
# Install the site | |
docker compose exec --user root phpfpm vendor/bin/drush site:install --existing-config --yes | |
- name: Export config | |
run: docker compose exec --user root phpfpm vendor/bin/drush config:export --yes | |
- name: Check for changes in config | |
run: git diff --diff-filter=ACMRT --exit-code config/ | |
playwright-tests: | |
if: false # Disabled due to timeout issues when running on GitHub. | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install site | |
run: | | |
docker network create frontend | |
docker compose pull | |
docker compose --profile test up --detach | |
cat > web/sites/default/settings.local.php <<'EOL' | |
<?php | |
$settings['hoeringsportal_openid_connect']['openid_connect'] = [ | |
'clientId' => 'client-id', | |
'clientSecret' => 'client-secret', | |
'openIDConnectMetadataUrl' => 'http://idp-citizen.hoeringsportal.local.itkdev.dk/.well-known/openid-configuration', | |
]; | |
EOL | |
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect. | |
docker compose exec --user root phpfpm composer install --no-interaction | |
# Install the site | |
docker compose exec --user root phpfpm vendor/bin/drush site:install minimal --existing-config --yes | |
# Build theme assets | |
docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal install | |
docker compose run --rm node yarn --cwd /app/web/themes/custom/hoeringsportal build | |
- name: Run Playwright | |
run: | | |
docker compose run --rm node yarn install | |
docker compose run --rm playwright npx playwright install | |
docker compose run --rm playwright npx playwright test --retries 3 | |
- uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: playwright-report | |
path: playwright-report/ | |
retention-days: 30 | |
update-site: | |
name: Check that site can be updated | |
runs-on: ubuntu-latest | |
steps: | |
# Install site from our base ref | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.base_ref }} | |
- name: setup-docker-and-composer | |
run: | | |
docker network create frontend | |
docker compose pull | |
docker compose up --detach | |
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect. | |
docker compose exec --user root phpfpm composer install --no-interaction | |
- name: Install site | |
run: | | |
# Add some local settings. | |
cat > web/sites/default/settings.local.php <<'EOF' | |
<?php | |
$settings['hash_salt'] = '${{ github.head_ref }}'; | |
EOF | |
cat web/sites/default/settings.local.php | |
# Install the site from config | |
docker compose exec --user root phpfpm vendor/bin/drush site:install --existing-config --yes | |
- name: Clean up root stuff | |
run: | | |
sudo chown -Rv $USER:$USER vendor/ web/ private-files/ || true | |
sudo chmod -Rv a+w web/sites/default || true | |
# Install site with our current ref | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
# Keep our local settings (cf. | |
# https://github.com/actions/checkout?tab=readme-ov-file#usage) | |
clean: false | |
# - run: | | |
# sudo git fetch | |
# sudo git checkout ${{ github.head_ref }} | |
- name: setup-docker-and-composer | |
run: | | |
docker compose pull | |
docker compose up --detach | |
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect. | |
docker compose exec --user root phpfpm composer install --no-interaction | |
- name: Update site | |
run: | | |
docker compose exec --user root phpfpm vendor/bin/drush deploy --yes | |
check-debug-patches: | |
name: Check that debug patches can be applied and reversed. | |
runs-on: ubuntu-latest | |
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow | |
strategy: | |
matrix: | |
patch: | |
# Cf. documentation/openIdConnect.md | |
- patches/openid_connect-debug-userinfo.patch | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Start docker compose setup and install composer packages | |
run: | | |
docker network create frontend | |
docker compose pull | |
docker compose up --detach | |
# Important: Use --no-interaction to make https://getcomposer.org/doc/06-config.md#discard-changes have effect. | |
docker compose exec --user root phpfpm composer install --no-interaction | |
- name: Apply patch | |
run: | | |
docker compose exec --user root phpfpm patch --strip=1 --verbose --input=${{ matrix.patch }} | |
- name: Reverse patch | |
run: | | |
docker compose exec --user root phpfpm patch --strip=1 --verbose --input=${{ matrix.patch }} --reverse |