From bfc848e8899146b747ebf401e351b250e515d239 Mon Sep 17 00:00:00 2001 From: Benjamin Rasmussen Date: Fri, 4 Oct 2024 08:50:11 +0200 Subject: [PATCH] Cache the docker images that GH Actions use. --- .github/workflows/ci-site-tests.yml | 87 ++++++++++++++++++++ .github/workflows/ci-tests.yml | 123 ---------------------------- .github/workflows/site-reset.yml | 44 ++++++++++ 3 files changed, 131 insertions(+), 123 deletions(-) create mode 100644 .github/workflows/ci-site-tests.yml create mode 100644 .github/workflows/site-reset.yml diff --git a/.github/workflows/ci-site-tests.yml b/.github/workflows/ci-site-tests.yml new file mode 100644 index 0000000000..1f064cf515 --- /dev/null +++ b/.github/workflows/ci-site-tests.yml @@ -0,0 +1,87 @@ +on: pull_request +name: CI site tests + +jobs: + LightHouse: + name: Test site performance using Lighthouse + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Re-setting site + uses: ./.github/workflows/site-reset.yml + - name: Run Lighthouse test + run: task ci:lighthouse + - name: Archive logs + uses: actions/upload-artifact@v4 + if: ${{ always() }} + with: + name: lighthouse-results + path: .lighthouseci + + Pa11y: + name: Test accessibility using Pa11y + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Re-setting site + uses: ./.github/workflows/site-reset.yml + - name: Run Pa11y + run: task ci:pa11y + - name: Archive screenshots + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: pa11y-screenshots + path: pa11y/screenshots + + Cypress: + name: Run Cypress functional tests + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Re-setting site + uses: ./.github/workflows/site-reset.yml + - name: Run Cypress + run: task ci:cypress + - name: Archive videoes + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: cypress-videos + path: cypress/videos + - name: Archive screenshots + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: cypress-screenshots + path: cypress/screenshots + + CheckOpenApiSpec: + name: Check OpenAPI specification + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Re-setting site + uses: ./.github/workflows/site-reset.yml + - name: Validate specification + run: task ci:openapi:validate + - name: Download current specification + run: task ci:openapi:download + - name: Ensure specification has not drifted + run: git diff --ignore-space-at-eol --exit-code openapi.json + - name: Generate package for CMS API specification + run: task dev:codegen:dpl-cms + - name: Ensure CMS API package code has not drifted + run: git diff --ignore-space-at-eol --exit-code packages/cms-api/* + + CheckDrupalConfig: + name: Check Drupal Config + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Re-setting site + uses: ./.github/workflows/site-reset.yml + - name: Export configuration + run: task dev:cli -- drush config-export -y + - name: Check for uncommited configuration after install + run: git diff --ignore-space-at-eol --exit-code config/sync/*.yml diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index 0ce56d467c..f016a59c76 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -102,83 +102,6 @@ jobs: - name: Run PhpUnit run: ./vendor/bin/phpunit --coverage-text - LightHouse: - name: Test site performance using Lighthouse - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - # Our Taskfile requires a proper checkout to function because of - # certain vars. - fetch-depth: 0 - - name: Install go-task - uses: arduino/setup-task@v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Setup site - run: task ci:reset - - name: Run Lighthouse test - run: task ci:lighthouse - - name: Archive logs - uses: actions/upload-artifact@v4 - with: - name: lighthouse-results - path: .lighthouseci - - Pa11y: - name: Test accessibility using Pa11y - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - # Our Taskfile requires a proper checkout to function because of - # certain vars. - fetch-depth: 0 - - name: Install go-task - uses: arduino/setup-task@v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Setup site - run: task ci:reset - - name: Run Pa11y - run: task ci:pa11y - - name: Archive screenshots - if: ${{ always() }} - uses: actions/upload-artifact@v4 - with: - name: pa11y-screenshots - path: pa11y/screenshots - - Cypress: - name: Run Cypress functional tests - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - # Our Taskfile requires a proper checkout to function because of - # certain vars. - fetch-depth: 0 - - name: Install go-task - uses: arduino/setup-task@v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Setup site - run: task ci:reset - - name: Run Cypress - run: task ci:cypress - - name: Archive videoes - if: always() - uses: actions/upload-artifact@v4 - with: - name: cypress-videos - path: cypress/videos - - name: Archive screenshots - if: always() - uses: actions/upload-artifact@v4 - with: - name: cypress-screenshots - path: cypress/screenshots - MarkdownLint: name: Lint Markdown runs-on: ubuntu-latest @@ -256,52 +179,6 @@ jobs: - name: Run ESLint run: npx eslint cypress -c cypress/.eslintrc.json - CheckOpenApiSpec: - name: Check OpenAPI specification - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - # Our Taskfile requires a proper checkout to function because of - # certain vars. - fetch-depth: 0 - - name: Install go-task - uses: arduino/setup-task@v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Setup site - run: task ci:reset - - name: Validate specification - run: task ci:openapi:validate - - name: Download current specification - run: task ci:openapi:download - - name: Ensure specification has not drifted - run: git diff --ignore-space-at-eol --exit-code openapi.json - - name: Generate package for CMS API specification - run: task dev:codegen:dpl-cms - - name: Ensure CMS API package code has not drifted - run: git diff --ignore-space-at-eol --exit-code packages/cms-api/* - - CheckDrupalConfig: - name: Check Drupal Config - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - # Our Taskfile requires a proper checkout to function because of - # certain vars. - fetch-depth: 0 - - name: Install go-task - uses: arduino/setup-task@v2 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - name: Setup site - run: task ci:reset - - name: Export configuration - run: task dev:cli -- drush config-export -y - - name: Check for uncommited configuration after install - run: git diff --ignore-space-at-eol --exit-code config/sync/*.yml - CheckPhpVersion: name: Check PHP version runs-on: ubuntu-latest diff --git a/.github/workflows/site-reset.yml b/.github/workflows/site-reset.yml new file mode 100644 index 0000000000..e036780532 --- /dev/null +++ b/.github/workflows/site-reset.yml @@ -0,0 +1,44 @@ +name: Re-setting site, for CI Tests + +on: + workflow_call: + inputs: + task: + required: true + type: string +env: + PHP_VERSION: 8.1 + COMPOSER_VERSION: v2 + +jobs: + setup-docker: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install go-task + uses: arduino/setup-task@v2 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Build and cache Docker images + run: | + docker compose build \ + --cache-from=type=local,src=/tmp/.buildx-cache \ + --cache-to=type=local,dest=/tmp/.buildx-cache-new + + - name: Setup site + run: task ci:reset