|
1 | 1 | name: CI |
2 | 2 | on: push |
| 3 | + |
| 4 | +# Limit the permissions of the GITHUB_TOKEN |
| 5 | +permissions: |
| 6 | + contents: read |
| 7 | + |
3 | 8 | jobs: |
| 9 | + # Setup job: Install dependencies and cache them for parallel jobs |
| 10 | + setup: |
| 11 | + runs-on: |
| 12 | + group: gusto-ubuntu-default |
| 13 | + outputs: |
| 14 | + cache-key: ${{ steps.cache-key.outputs.key }} |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - uses: actions/setup-node@v4 |
| 19 | + with: |
| 20 | + node-version-file: '.nvmrc' |
| 21 | + |
| 22 | + - name: Generate cache key |
| 23 | + id: cache-key |
| 24 | + run: echo "key=node-modules-${{ hashFiles('package-lock.json') }}" >> $GITHUB_OUTPUT |
| 25 | + |
| 26 | + - name: Cache node_modules |
| 27 | + id: cache-node-modules |
| 28 | + uses: actions/cache@v4 |
| 29 | + with: |
| 30 | + path: node_modules |
| 31 | + key: ${{ steps.cache-key.outputs.key }} |
| 32 | + |
| 33 | + - name: Install dependencies |
| 34 | + if: steps.cache-node-modules.outputs.cache-hit != 'true' |
| 35 | + run: npm ci |
| 36 | + |
| 37 | + # Build job: Build the project and cache artifacts |
4 | 38 | build: |
| 39 | + needs: setup |
| 40 | + runs-on: |
| 41 | + group: gusto-ubuntu-default |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v4 |
| 44 | + |
| 45 | + - uses: actions/setup-node@v4 |
| 46 | + with: |
| 47 | + node-version-file: '.nvmrc' |
| 48 | + |
| 49 | + - name: Restore node_modules cache |
| 50 | + uses: actions/cache/restore@v4 |
| 51 | + with: |
| 52 | + path: node_modules |
| 53 | + key: ${{ needs.setup.outputs.cache-key }} |
| 54 | + |
| 55 | + - name: Cache build artifacts |
| 56 | + id: cache-build |
| 57 | + uses: actions/cache@v4 |
| 58 | + with: |
| 59 | + path: dist |
| 60 | + key: build-${{ github.sha }} |
| 61 | + |
| 62 | + - name: Generate i18n translations |
| 63 | + if: steps.cache-build.outputs.cache-hit != 'true' |
| 64 | + run: npm run i18n:generate |
| 65 | + |
| 66 | + - name: Build |
| 67 | + if: steps.cache-build.outputs.cache-hit != 'true' |
| 68 | + run: npx vite build |
| 69 | + |
| 70 | + # Lint job: Run ESLint (parallel with other checks) |
| 71 | + lint: |
| 72 | + needs: setup |
| 73 | + runs-on: |
| 74 | + group: gusto-ubuntu-default |
| 75 | + steps: |
| 76 | + - uses: actions/checkout@v4 |
| 77 | + |
| 78 | + - uses: actions/setup-node@v4 |
| 79 | + with: |
| 80 | + node-version-file: '.nvmrc' |
| 81 | + |
| 82 | + - name: Restore node_modules cache |
| 83 | + uses: actions/cache/restore@v4 |
| 84 | + with: |
| 85 | + path: node_modules |
| 86 | + key: ${{ needs.setup.outputs.cache-key }} |
| 87 | + |
| 88 | + - name: Lint |
| 89 | + run: npm run lint:check |
| 90 | + |
| 91 | + # Format job: Run Prettier check (parallel with other checks) |
| 92 | + format: |
| 93 | + needs: setup |
5 | 94 | runs-on: |
6 | 95 | group: gusto-ubuntu-default |
7 | 96 | steps: |
8 | 97 | - uses: actions/checkout@v4 |
| 98 | + |
9 | 99 | - uses: actions/setup-node@v4 |
10 | 100 | with: |
11 | 101 | node-version-file: '.nvmrc' |
12 | | - cache: 'npm' |
13 | | - - run: npm ci |
14 | | - - run: npm run build:ci |
| 102 | + |
| 103 | + - name: Restore node_modules cache |
| 104 | + uses: actions/cache/restore@v4 |
| 105 | + with: |
| 106 | + path: node_modules |
| 107 | + key: ${{ needs.setup.outputs.cache-key }} |
| 108 | + |
| 109 | + - name: Format check |
| 110 | + run: npm run format:check |
| 111 | + |
| 112 | + # TypeScript job: Run type checking (parallel with other checks) |
| 113 | + typecheck: |
| 114 | + needs: setup |
| 115 | + runs-on: |
| 116 | + group: gusto-ubuntu-default |
| 117 | + steps: |
| 118 | + - uses: actions/checkout@v4 |
| 119 | + |
| 120 | + - uses: actions/setup-node@v4 |
| 121 | + with: |
| 122 | + node-version-file: '.nvmrc' |
| 123 | + |
| 124 | + - name: Restore node_modules cache |
| 125 | + uses: actions/cache/restore@v4 |
| 126 | + with: |
| 127 | + path: node_modules |
| 128 | + key: ${{ needs.setup.outputs.cache-key }} |
| 129 | + |
| 130 | + - name: TypeScript check |
| 131 | + run: npm run tsc |
| 132 | + |
| 133 | + # Test job: Run tests with coverage (parallel with other checks) |
| 134 | + test: |
| 135 | + needs: setup |
| 136 | + runs-on: |
| 137 | + group: gusto-ubuntu-default |
| 138 | + steps: |
| 139 | + - uses: actions/checkout@v4 |
| 140 | + |
| 141 | + - uses: actions/setup-node@v4 |
| 142 | + with: |
| 143 | + node-version-file: '.nvmrc' |
| 144 | + |
| 145 | + - name: Restore node_modules cache |
| 146 | + uses: actions/cache/restore@v4 |
| 147 | + with: |
| 148 | + path: node_modules |
| 149 | + key: ${{ needs.setup.outputs.cache-key }} |
| 150 | + |
| 151 | + - name: Test with coverage |
| 152 | + run: npm run test:ci |
0 commit comments