ci: add a working CI gate #1398
Workflow file for this run
This file contains hidden or 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
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: ~ | |
| workflow_dispatch: ~ | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| pwa: | |
| name: PWA | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: pwa | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| # Activated globally: the cache lookup below runs pnpm from the repository | |
| # root, where no packageManager field pins the version. | |
| - name: Enable corepack | |
| run: | | |
| corepack enable | |
| corepack prepare pnpm@9.1.1 --activate | |
| - name: Setup Node | |
| uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | |
| with: | |
| node-version: 20 | |
| cache: pnpm | |
| cache-dependency-path: pwa/pnpm-lock.yaml | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: ESLint | |
| run: pnpm lint | |
| api: | |
| name: API | |
| runs-on: ubuntu-latest | |
| env: | |
| APP_ENV: test | |
| defaults: | |
| run: | |
| working-directory: api | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@f3e473d116dcccaddc5834248c87452386958240 # 2.37.2 | |
| with: | |
| php-version: '8.4' | |
| coverage: none | |
| tools: composer:v2 | |
| - name: Validate composer.json and composer.lock | |
| run: composer validate --strict --no-check-publish | |
| - name: Get Composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" | |
| - name: Cache Composer dependencies | |
| uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('api/composer.lock') }} | |
| restore-keys: ${{ runner.os }}-composer- | |
| - name: Install dependencies | |
| run: composer install --prefer-dist --no-progress | |
| - name: Lint YAML | |
| run: bin/console lint:yaml config --parse-tags | |
| - name: Lint Twig | |
| run: bin/console lint:twig templates | |
| - name: Lint container | |
| run: bin/console lint:container | |
| tests: | |
| name: Tests | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: 'read' | |
| id-token: 'write' | |
| env: | |
| # Falls back to the run token on forks, where the personal token is absent: | |
| # the contributors fetch during the PWA build is rate-limited without one. | |
| GITHUB_KEY: ${{ secrets.GH_KEY || secrets.GITHUB_TOKEN }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| - name: Pull images | |
| run: docker compose pull --ignore-pull-failures || true | |
| - name: Start services | |
| run: docker compose up --build -d | |
| - name: Wait for services | |
| run: | | |
| while status="$(docker inspect --format="{{if .Config.Healthcheck}}{{print .State.Health.Status}}{{end}}" "$(docker compose ps -q php)")"; do | |
| case $status in | |
| starting) sleep 1;; | |
| healthy) exit 0;; | |
| unhealthy) | |
| docker compose ps | |
| docker compose logs | |
| exit 1 | |
| ;; | |
| esac | |
| done | |
| exit 1 | |
| - name: Check HTTP reachability | |
| run: curl -v -o /dev/null http://localhost | |
| - name: Check API reachability | |
| run: curl -vk -o /dev/null https://localhost | |
| - name: Check PWA reachability | |
| run: "curl -vk -o /dev/null -H 'Accept: text/html' https://localhost" | |
| - name: Create test database | |
| run: | | |
| docker compose exec -T php bin/console -e test doctrine:database:create | |
| docker compose exec -T php bin/console -e test doctrine:migrations:migrate --no-interaction | |
| - name: PHPUnit | |
| run: docker compose exec -T php bin/phpunit | |
| - name: Doctrine Schema Validator | |
| run: docker compose exec -T php bin/console doctrine:schema:validate | |
| # Helm came from the gcloud SDK, itself pinned to an old Python. Nothing in | |
| # this job calls gcloud, so it is installed directly instead. | |
| - name: Setup Helm | |
| uses: azure/setup-helm@9bc31f4ebc9c6b171d7bfbaa5d006ae7abdb4310 # v5.0.1 | |
| - name: Lint Helm | |
| run: helm lint ./helm/api-platform/ |