|
13 | 13 |
|
14 | 14 | # Define reusable job template |
15 | 15 | jobs: |
16 | | - build: |
| 16 | + # Shared setup job for dependency installation |
| 17 | + setup: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Checkout repository |
| 21 | + uses: actions/checkout@v3 |
| 22 | + |
| 23 | + - name: Set up Bun |
| 24 | + uses: oven-sh/setup-bun@v2 |
| 25 | + with: |
| 26 | + bun-version: '1.2.12' |
| 27 | + |
| 28 | + - name: Cache dependencies |
| 29 | + uses: actions/cache@v3 |
| 30 | + with: |
| 31 | + path: | |
| 32 | + node_modules |
| 33 | + */node_modules |
| 34 | + packages/*/node_modules |
| 35 | + key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lockb') }} |
| 36 | + restore-keys: | |
| 37 | + ${{ runner.os }}-deps- |
| 38 | +
|
| 39 | + - name: Install dependencies |
| 40 | + run: bun install --frozen-lockfile |
| 41 | + |
| 42 | + # Build web in parallel |
| 43 | + build-web: |
| 44 | + needs: setup |
17 | 45 | runs-on: ubuntu-latest |
18 | 46 | steps: |
19 | 47 | - name: Checkout repository |
@@ -54,10 +82,76 @@ jobs: |
54 | 82 | run: | |
55 | 83 | cd web && bun run build |
56 | 84 |
|
| 85 | + # Typecheck in parallel |
| 86 | + typecheck: |
| 87 | + needs: setup |
| 88 | + runs-on: ubuntu-latest |
| 89 | + steps: |
| 90 | + - name: Checkout repository |
| 91 | + uses: actions/checkout@v3 |
| 92 | + |
| 93 | + - name: Set up Bun |
| 94 | + uses: oven-sh/setup-bun@v2 |
| 95 | + with: |
| 96 | + bun-version: '1.2.12' |
| 97 | + |
| 98 | + - name: Cache dependencies |
| 99 | + uses: actions/cache@v3 |
| 100 | + with: |
| 101 | + path: | |
| 102 | + node_modules |
| 103 | + */node_modules |
| 104 | + packages/*/node_modules |
| 105 | + key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lockb') }} |
| 106 | + restore-keys: | |
| 107 | + ${{ runner.os }}-deps- |
| 108 | +
|
| 109 | + - name: Install dependencies |
| 110 | + run: bun install --frozen-lockfile |
| 111 | + |
| 112 | + - name: Set environment variables |
| 113 | + env: |
| 114 | + SECRETS_CONTEXT: ${{ toJSON(secrets) }} |
| 115 | + run: | |
| 116 | + VAR_NAMES=$(node scripts/generate-ci-env.js) |
| 117 | + echo "$SECRETS_CONTEXT" | jq -r --argjson vars "$VAR_NAMES" ' |
| 118 | + to_entries | .[] | select(.key as $k | $vars | index($k)) | .key + "=" + .value |
| 119 | + ' >> $GITHUB_ENV |
| 120 | + echo "CODEBUFF_GITHUB_ACTIONS=true" >> $GITHUB_ENV |
| 121 | + echo "NEXT_PUBLIC_CB_ENVIRONMENT=test" >> $GITHUB_ENV |
| 122 | + echo "CODEBUFF_GITHUB_TOKEN=${{ secrets.CODEBUFF_GITHUB_TOKEN }}" >> $GITHUB_ENV |
| 123 | +
|
57 | 124 | - name: Typecheck |
58 | 125 | run: | |
59 | 126 | bun run typecheck |
60 | 127 |
|
| 128 | + # Build npm-app in parallel |
| 129 | + build: |
| 130 | + needs: setup |
| 131 | + runs-on: ubuntu-latest |
| 132 | + steps: |
| 133 | + - name: Checkout repository |
| 134 | + uses: actions/checkout@v3 |
| 135 | + |
| 136 | + - name: Set up Bun |
| 137 | + uses: oven-sh/setup-bun@v2 |
| 138 | + with: |
| 139 | + bun-version: '1.2.12' |
| 140 | + |
| 141 | + - name: Cache dependencies |
| 142 | + uses: actions/cache@v3 |
| 143 | + with: |
| 144 | + path: | |
| 145 | + node_modules |
| 146 | + */node_modules |
| 147 | + packages/*/node_modules |
| 148 | + key: ${{ runner.os }}-deps-${{ hashFiles('**/bun.lockb') }} |
| 149 | + restore-keys: | |
| 150 | + ${{ runner.os }}-deps- |
| 151 | +
|
| 152 | + - name: Install dependencies |
| 153 | + run: bun install --frozen-lockfile |
| 154 | + |
61 | 155 | - name: Build |
62 | 156 | run: | |
63 | 157 | cd npm-app && bun run build |
|
69 | 163 |
|
70 | 164 | # Template for test jobs |
71 | 165 | test: |
72 | | - needs: build |
| 166 | + needs: [build-web, typecheck, build] |
73 | 167 | strategy: |
74 | 168 | matrix: |
75 | 169 | package: [npm-app, backend, common] |
@@ -129,7 +223,7 @@ jobs: |
129 | 223 |
|
130 | 224 | # Integration tests job |
131 | 225 | test-integration: |
132 | | - needs: build |
| 226 | + needs: [build-web, typecheck, build] |
133 | 227 | strategy: |
134 | 228 | matrix: |
135 | 229 | package: [npm-app, backend, common] |
|
0 commit comments