Skip to content

Commit f45eb77

Browse files
ci: parallelize build-web, typecheck, and build jobs
Split CI workflow to run build-web, typecheck, and npm-app build in parallel after shared setup job. Tests now depend on all three parallel jobs completing successfully, maintaining fail-fast behavior while improving CI performance. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent 8500775 commit f45eb77

File tree

1 file changed

+97
-3
lines changed

1 file changed

+97
-3
lines changed

.github/workflows/ci.yml

Lines changed: 97 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,35 @@ on:
1313

1414
# Define reusable job template
1515
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
1745
runs-on: ubuntu-latest
1846
steps:
1947
- name: Checkout repository
@@ -54,10 +82,76 @@ jobs:
5482
run: |
5583
cd web && bun run build
5684
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+
57124
- name: Typecheck
58125
run: |
59126
bun run typecheck
60127
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+
61155
- name: Build
62156
run: |
63157
cd npm-app && bun run build
@@ -69,7 +163,7 @@ jobs:
69163

70164
# Template for test jobs
71165
test:
72-
needs: build
166+
needs: [build-web, typecheck, build]
73167
strategy:
74168
matrix:
75169
package: [npm-app, backend, common]
@@ -129,7 +223,7 @@ jobs:
129223

130224
# Integration tests job
131225
test-integration:
132-
needs: build
226+
needs: [build-web, typecheck, build]
133227
strategy:
134228
matrix:
135229
package: [npm-app, backend, common]

0 commit comments

Comments
 (0)