|
| 1 | +name: CI - frontend |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + paths: |
| 9 | + - frontend/** |
| 10 | + - .github/workflows/ci-frontend.yml |
| 11 | + |
| 12 | +defaults: |
| 13 | + run: |
| 14 | + working-directory: ./frontend |
| 15 | + |
| 16 | +env: |
| 17 | + NODE_VERSION: 20 |
| 18 | + LOCKFILE_PATH: ./frontend/package-lock.json # or yarn.lock |
| 19 | + PACKAGE_MANAGER: npm # or yarn |
| 20 | + |
| 21 | +concurrency: |
| 22 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 23 | + cancel-in-progress: true |
| 24 | + |
| 25 | +jobs: |
| 26 | + tests: |
| 27 | + name: Tests |
| 28 | + runs-on: ubuntu-latest |
| 29 | + |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + - uses: actions/setup-node@v4 |
| 33 | + with: |
| 34 | + node-version: ${{ env.NODE_VERSION }} |
| 35 | + cache-dependency-path: ${{ env.LOCKFILE_PATH }} |
| 36 | + cache: ${{ env.PACKAGE_MANAGER }} |
| 37 | + - run: npm ci |
| 38 | + - run: npm run test -- --testLocationInResults --json --outputFile=coverage/report.json |
| 39 | + - uses: ArtiomTr/jest-coverage-report-action@v2 |
| 40 | + with: |
| 41 | + coverage-file: coverage/report.json |
| 42 | + test-script: npm test |
| 43 | + working-directory: frontend |
| 44 | + annotations: failed-tests |
| 45 | + # base-coverage-file: report.json |
| 46 | + |
| 47 | + lint: |
| 48 | + name: Lint |
| 49 | + runs-on: ubuntu-latest |
| 50 | + |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v4 |
| 53 | + - uses: actions/setup-node@v4 |
| 54 | + with: |
| 55 | + node-version: ${{ env.NODE_VERSION }} |
| 56 | + cache-dependency-path: ${{ env.LOCKFILE_PATH }} |
| 57 | + cache: ${{ env.PACKAGE_MANAGER }} |
| 58 | + - run: npm ci |
| 59 | + - run: npm run lint |
| 60 | + |
| 61 | + types: |
| 62 | + name: Type check |
| 63 | + runs-on: ubuntu-latest |
| 64 | + |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v4 |
| 67 | + - uses: actions/setup-node@v4 |
| 68 | + with: |
| 69 | + node-version: ${{ env.NODE_VERSION }} |
| 70 | + cache-dependency-path: ${{ env.LOCKFILE_PATH }} |
| 71 | + cache: ${{ env.PACKAGE_MANAGER }} |
| 72 | + - run: npm ci |
| 73 | + - run: npm run ts:check |
| 74 | + |
| 75 | + formatting: |
| 76 | + name: Format check |
| 77 | + runs-on: ubuntu-latest |
| 78 | + |
| 79 | + steps: |
| 80 | + - uses: actions/checkout@v4 |
| 81 | + - uses: actions/setup-node@v4 |
| 82 | + with: |
| 83 | + node-version: ${{ env.NODE_VERSION }} |
| 84 | + cache-dependency-path: ${{ env.LOCKFILE_PATH }} |
| 85 | + cache: ${{ env.PACKAGE_MANAGER }} |
| 86 | + - run: npm ci |
| 87 | + - run: npm run format-check |
| 88 | + |
| 89 | + # Confirms the app still builds successfully |
| 90 | + check-app-builds: |
| 91 | + name: Build check - App |
| 92 | + runs-on: ubuntu-latest |
| 93 | + |
| 94 | + steps: |
| 95 | + - uses: actions/checkout@v4 |
| 96 | + - uses: actions/setup-node@v4 |
| 97 | + with: |
| 98 | + node-version: ${{ env.NODE_VERSION }} |
| 99 | + cache-dependency-path: ${{ env.LOCKFILE_PATH }} |
| 100 | + cache: ${{ env.PACKAGE_MANAGER }} |
| 101 | + |
| 102 | + # https://nextjs.org/docs/advanced-features/ci-build-caching |
| 103 | + - uses: actions/cache@v4 |
| 104 | + with: |
| 105 | + path: | |
| 106 | + ~/.npm |
| 107 | + ${{ github.workspace }}/frontend/.next/cache |
| 108 | + # Generate a new cache whenever packages or source files change. |
| 109 | + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }} |
| 110 | + # If source files changed but packages didn't, rebuild from a prior cache. |
| 111 | + restore-keys: | |
| 112 | + ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- |
| 113 | +
|
| 114 | + - run: npm ci |
| 115 | + - run: npm run build -- --no-lint |
| 116 | + |
| 117 | + # Confirms Storybook still builds successfully |
| 118 | + check-storybook-builds: |
| 119 | + name: Build check - Storybook |
| 120 | + runs-on: ubuntu-latest |
| 121 | + |
| 122 | + steps: |
| 123 | + - uses: actions/checkout@v4 |
| 124 | + - uses: actions/setup-node@v4 |
| 125 | + with: |
| 126 | + node-version: ${{ env.NODE_VERSION }} |
| 127 | + cache-dependency-path: ${{ env.LOCKFILE_PATH }} |
| 128 | + cache: ${{ env.PACKAGE_MANAGER }} |
| 129 | + - run: npm ci |
| 130 | + - run: npm run storybook-build |
0 commit comments