For discussion: Allow tabs to work on mobile #4922
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: Checks | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| - 'feature/**' | |
| - 'support/**' | |
| workflow_dispatch: | |
| concurrency: | |
| group: pull-request-${{ github.head_ref || github.run_id }} | |
| cancel-in-progress: true | |
| jobs: | |
| install: | |
| name: Install | |
| runs-on: ubuntu-latest | |
| env: | |
| PUPPETEER_SKIP_DOWNLOAD: true | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Install dependencies | |
| uses: ./.github/workflows/actions/install | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| needs: [install] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install and build | |
| uses: ./.github/workflows/actions/build | |
| with: | |
| environment: development | |
| linting: | |
| name: ${{ matrix.task.description }} | |
| runs-on: ubuntu-latest | |
| needs: [install] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| task: | |
| - description: Stylelint | |
| name: lint-styles | |
| run: npm run lint:css | |
| cache: .cache/stylelint | |
| - description: ESLint | |
| name: lint-scripts | |
| run: npm run lint:js | |
| cache: .cache/eslint | |
| - description: Prettier | |
| name: lint-prettier | |
| run: npm run lint:prettier | |
| cache: .cache/prettier | |
| - description: TypeScript compiler | |
| name: lint-types | |
| run: npm run lint:types -- --incremental | |
| cache: '**/*.tsbuildinfo' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Restore dependencies (from cache) | |
| uses: actions/cache/restore@v5 | |
| with: | |
| fail-on-cache-miss: true | |
| key: npm-install-${{ hashFiles('package-lock.json') }} | |
| path: node_modules | |
| - name: Cache lint task | |
| if: ${{ matrix.task.cache }} | |
| uses: actions/cache@v5 | |
| with: | |
| key: ${{ matrix.task.name }} | |
| path: ${{ matrix.task.cache }} | |
| - name: Setup Node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: .nvmrc | |
| package-manager-cache: false | |
| - name: Run lint task | |
| run: ${{ matrix.task.run }} | |
| tests: | |
| name: ${{ matrix.task.description }} | |
| runs-on: ubuntu-latest | |
| needs: [install, build] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| task: | |
| - description: JavaScript unit tests | |
| name: test-unit | |
| cache: .cache/jest | |
| coverage: true | |
| - description: JavaScript behaviour tests | |
| name: test-behaviour | |
| cache: .cache/jest | |
| coverage: true | |
| - description: JavaScript component tests | |
| name: test-component | |
| run: npm run install:puppeteer | |
| cache: | | |
| .cache/jest | |
| .cache/puppeteer | |
| coverage: true | |
| - description: Accessibility tests | |
| name: test-accessibility | |
| run: npm run install:puppeteer | |
| cache: | | |
| .cache/jest | |
| .cache/puppeteer | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Restore dependencies (from cache) | |
| uses: actions/cache/restore@v5 | |
| with: | |
| fail-on-cache-miss: true | |
| key: npm-install-${{ hashFiles('package-lock.json') }} | |
| path: node_modules | |
| - name: Restore build (from cache) | |
| uses: actions/cache/restore@v5 | |
| with: | |
| fail-on-cache-miss: true | |
| key: build-${{ github.sha }} | |
| path: packages/*/dist/ | |
| - name: Cache task | |
| if: ${{ matrix.task.cache }} | |
| uses: actions/cache@v5 | |
| with: | |
| key: ${{ matrix.task.name }} | |
| path: ${{ matrix.task.cache }} | |
| - name: Setup Node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: .nvmrc | |
| package-manager-cache: false | |
| - name: Run test task | |
| if: ${{ matrix.task.run }} | |
| run: ${{ matrix.task.run }} | |
| - name: Run test project | |
| # Use 2x CPU cores for hosted GitHub runners | |
| # https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources | |
| run: npx jest --color ${{ format('--coverage={0} --coverageDirectory="coverage/{1}" --maxWorkers=2 --selectProjects "{2}"', matrix.task.coverage || false, matrix.task.name, matrix.task.description) }} | |
| - name: Save test coverage | |
| if: ${{ matrix.task.coverage }} | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ matrix.task.description }} coverage | |
| path: coverage | |
| if-no-files-found: ignore | |
| exports: | |
| name: Package ${{ matrix.conditions }} | |
| runs-on: ubuntu-latest | |
| needs: [install, build] | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| conditions: | |
| - require | |
| - import | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| - name: Restore dependencies (from cache) | |
| uses: actions/cache/restore@v5 | |
| with: | |
| fail-on-cache-miss: true | |
| key: npm-install-${{ hashFiles('package-lock.json') }} | |
| path: node_modules | |
| - name: Restore build (from cache) | |
| uses: actions/cache/restore@v5 | |
| with: | |
| fail-on-cache-miss: true | |
| key: build-${{ github.sha }} | |
| path: packages/*/dist/ | |
| - name: Setup Node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: .nvmrc | |
| package-manager-cache: false | |
| - name: Resolve entry path | |
| run: | | |
| node --eval "console.log(require.resolve('nhsuk-frontend'))" --conditions ${{ matrix.conditions }} | |
| node --eval "console.log(require.resolve('nhsuk-frontend/package.json'))" --conditions ${{ matrix.conditions }} | |
| node --eval "console.log(require.resolve('nhsuk-frontend/dist/nhsuk/i18n.js'))" --conditions ${{ matrix.conditions }} | |
| node --eval "console.log(require.resolve('nhsuk-frontend/dist/nhsuk/i18n.mjs'))" --conditions ${{ matrix.conditions }} | |
| node --eval "console.log(require.resolve('nhsuk-frontend/dist/nhsuk/index.js'))" --conditions ${{ matrix.conditions }} | |
| node --eval "console.log(require.resolve('nhsuk-frontend/dist/nhsuk/index.mjs'))" --conditions ${{ matrix.conditions }} | |
| node --eval "console.log(require.resolve('nhsuk-frontend/dist/nhsuk/components/button/button.js'))" --conditions ${{ matrix.conditions }} | |
| node --eval "console.log(require.resolve('nhsuk-frontend/dist/nhsuk/components/button/button.mjs'))" --conditions ${{ matrix.conditions }} | |
| sass: | |
| name: Sass import | |
| needs: [install, build] | |
| # Run existing "Sass" workflow | |
| # (after build has been cached) | |
| uses: ./.github/workflows/sass.yml | |
| regression: | |
| name: Visual regression tests | |
| runs-on: macos-latest | |
| needs: [install, build] | |
| if: ${{ github.base_ref == 'main' || startsWith(github.base_ref, 'support/') || contains(github.event.pull_request.labels.*.name, 'dependencies') }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for changes | |
| uses: ./.github/workflows/actions/diff | |
| id: changes | |
| - name: Download browsers | |
| if: ${{ steps.changes.outputs.changes == 'true' || steps.changes.outputs.screenshots == 'true' }} | |
| run: | | |
| npm run install:puppeteer | |
| npm run install:playwright | |
| - name: Run backstop | |
| if: ${{ steps.changes.outputs.changes == 'true' || steps.changes.outputs.screenshots == 'true' }} | |
| run: npm run test:visual --ignore-scripts | |
| - name: Save backstop report | |
| if: ${{ !cancelled() && (steps.changes.outputs.changes == 'true' || steps.changes.outputs.screenshots == 'true') }} | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: Backstop report | |
| path: tests/backstop/ | |
| if-no-files-found: ignore | |
| sonar: | |
| name: Sonar analysis | |
| runs-on: ubuntu-latest | |
| needs: [build, tests] | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
| steps: | |
| - name: Checkout | |
| if: ${{ env.SONAR_TOKEN }} | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Restore test coverage | |
| if: ${{ env.SONAR_TOKEN }} | |
| uses: actions/download-artifact@v7 | |
| with: | |
| merge-multiple: true | |
| path: coverage | |
| pattern: '* coverage' | |
| - name: Sonar analysis | |
| if: ${{ env.SONAR_TOKEN }} | |
| uses: SonarSource/sonarqube-scan-action@v7 |