Skip to content

Commit e8551f1

Browse files
committed
Speed up CI builds and prevent duplicate translation runs
- Use setup-node's npm cache instead of caching node_modules, which npm ci wipes anyway. - Move puppeteer to optionalDependencies and pass --omit=optional in deploy/translate workflows, skipping the Chromium download. - Add per-job concurrency: cancel in-flight builds on new pushes, but never cancel deploy or translate jobs mid-run. - Set timeout-minutes: 60 on translate to bound stuck Anthropic batches.
1 parent 7040089 commit e8551f1

4 files changed

Lines changed: 49 additions & 37 deletions

File tree

.github/workflows/s3-deploy-development.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,16 @@ on:
66
jobs:
77
build-en:
88
runs-on: ubuntu-latest
9+
concurrency:
10+
group: build-en-${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
912
steps:
1013
- uses: actions/checkout@v4
1114

1215
- uses: actions/setup-node@v4
1316
with:
1417
node-version: 20
15-
16-
- name: Cache node_modules
17-
uses: actions/cache@v4
18-
with:
19-
path: node_modules
20-
key: npm-${{ hashFiles('package-lock.json') }}
18+
cache: 'npm'
2119

2220
- name: Cache Astro build
2321
uses: actions/cache@v4
@@ -26,7 +24,7 @@ jobs:
2624
key: astro-dev-en-${{ github.sha }}
2725
restore-keys: astro-dev-en-
2826

29-
- run: npm ci
27+
- run: npm ci --omit=optional
3028

3129
- name: Build English only
3230
env:
@@ -49,18 +47,16 @@ jobs:
4947
strategy:
5048
matrix:
5149
locale: [zh, tr, ru]
50+
concurrency:
51+
group: build-locale-${{ matrix.locale }}-${{ github.workflow }}-${{ github.ref }}
52+
cancel-in-progress: true
5253
steps:
5354
- uses: actions/checkout@v4
5455

5556
- uses: actions/setup-node@v4
5657
with:
5758
node-version: 20
58-
59-
- name: Cache node_modules
60-
uses: actions/cache@v4
61-
with:
62-
path: node_modules
63-
key: npm-${{ hashFiles('package-lock.json') }}
59+
cache: 'npm'
6460

6561
- name: Cache Astro build
6662
uses: actions/cache@v4
@@ -69,7 +65,7 @@ jobs:
6965
key: astro-dev-${{ matrix.locale }}-${{ github.sha }}
7066
restore-keys: astro-dev-${{ matrix.locale }}-
7167

72-
- run: npm ci
68+
- run: npm ci --omit=optional
7369

7470
- name: Build locale ${{ matrix.locale }}
7571
env:
@@ -85,6 +81,9 @@ jobs:
8581
deploy:
8682
needs: [build-en, build-locale]
8783
runs-on: ubuntu-latest
84+
concurrency:
85+
group: deploy-${{ github.workflow }}-${{ github.ref }}
86+
cancel-in-progress: false
8887
permissions:
8988
contents: write
9089
environment: development

.github/workflows/s3-deploy-production.yml

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,17 @@ jobs:
4141
needs: classify
4242
if: needs.classify.outputs.translation_only == 'false'
4343
runs-on: ubuntu-latest
44+
concurrency:
45+
group: check-internal-links-${{ github.workflow }}-${{ github.ref }}
46+
cancel-in-progress: true
4447
steps:
4548
- uses: actions/checkout@v4
4649
with:
4750
fetch-depth: 0
4851
- uses: actions/setup-node@v4
4952
with:
5053
node-version: 20
54+
cache: 'npm'
5155
- run: npm install github-slugger
5256
- run: node scripts/check-links/index.mjs --diff --base=last-production-deploy --internal-only
5357

@@ -57,18 +61,16 @@ jobs:
5761
build-en:
5862
needs: check-internal-links
5963
runs-on: ubuntu-latest
64+
concurrency:
65+
group: build-en-${{ github.workflow }}-${{ github.ref }}
66+
cancel-in-progress: true
6067
steps:
6168
- uses: actions/checkout@v4
6269

6370
- uses: actions/setup-node@v4
6471
with:
6572
node-version: 20
66-
67-
- name: Cache node_modules
68-
uses: actions/cache@v4
69-
with:
70-
path: node_modules
71-
key: npm-${{ hashFiles('package-lock.json') }}
73+
cache: 'npm'
7274

7375
- name: Cache Astro build
7476
uses: actions/cache@v4
@@ -77,7 +79,7 @@ jobs:
7779
key: astro-en-${{ github.sha }}
7880
restore-keys: astro-en-
7981

80-
- run: npm ci
82+
- run: npm ci --omit=optional
8183

8284
- name: Build English only
8385
env:
@@ -101,18 +103,16 @@ jobs:
101103
strategy:
102104
matrix:
103105
locale: [zh, tr, ru]
106+
concurrency:
107+
group: build-locale-full-${{ matrix.locale }}-${{ github.workflow }}-${{ github.ref }}
108+
cancel-in-progress: true
104109
steps:
105110
- uses: actions/checkout@v4
106111

107112
- uses: actions/setup-node@v4
108113
with:
109114
node-version: 20
110-
111-
- name: Cache node_modules
112-
uses: actions/cache@v4
113-
with:
114-
path: node_modules
115-
key: npm-${{ hashFiles('package-lock.json') }}
115+
cache: 'npm'
116116

117117
- name: Cache Astro build
118118
uses: actions/cache@v4
@@ -121,7 +121,7 @@ jobs:
121121
key: astro-${{ matrix.locale }}-${{ github.sha }}
122122
restore-keys: astro-${{ matrix.locale }}-
123123

124-
- run: npm ci
124+
- run: npm ci --omit=optional
125125

126126
- name: Build locale ${{ matrix.locale }}
127127
env:
@@ -137,6 +137,9 @@ jobs:
137137
deploy-full:
138138
needs: [build-en, build-locale-full]
139139
runs-on: ubuntu-latest
140+
concurrency:
141+
group: deploy-full-${{ github.workflow }}-${{ github.ref }}
142+
cancel-in-progress: false
140143
permissions:
141144
contents: write
142145
environment: production
@@ -192,18 +195,16 @@ jobs:
192195
strategy:
193196
matrix:
194197
locale: [zh, tr, ru]
198+
concurrency:
199+
group: build-locale-only-${{ matrix.locale }}-${{ github.workflow }}-${{ github.ref }}
200+
cancel-in-progress: true
195201
steps:
196202
- uses: actions/checkout@v4
197203

198204
- uses: actions/setup-node@v4
199205
with:
200206
node-version: 20
201-
202-
- name: Cache node_modules
203-
uses: actions/cache@v4
204-
with:
205-
path: node_modules
206-
key: npm-${{ hashFiles('package-lock.json') }}
207+
cache: 'npm'
207208

208209
- name: Cache Astro build
209210
uses: actions/cache@v4
@@ -212,7 +213,7 @@ jobs:
212213
key: astro-${{ matrix.locale }}-${{ github.sha }}
213214
restore-keys: astro-${{ matrix.locale }}-
214215

215-
- run: npm ci
216+
- run: npm ci --omit=optional
216217

217218
- name: Build locale ${{ matrix.locale }}
218219
env:
@@ -228,6 +229,9 @@ jobs:
228229
deploy-translations:
229230
needs: build-locale-only
230231
runs-on: ubuntu-latest
232+
concurrency:
233+
group: deploy-translations-${{ github.workflow }}-${{ github.ref }}
234+
cancel-in-progress: false
231235
permissions:
232236
contents: write
233237
environment: production

.github/workflows/translate.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ on:
1010
- 'src/api-reference/specs/*.yaml'
1111
- 'src/locales/dictionary.json'
1212

13+
# Queue concurrent runs (do not cancel) so an in-flight Anthropic batch isn't
14+
# killed mid-call and two pushes don't race on the translation commit.
15+
concurrency:
16+
group: translate-${{ github.ref }}
17+
cancel-in-progress: false
18+
1319
jobs:
1420
translate:
1521
runs-on: ubuntu-latest
22+
timeout-minutes: 60
1623
permissions:
1724
contents: write
1825

@@ -39,7 +46,7 @@ jobs:
3946
cache: 'npm'
4047

4148
- name: Install dependencies
42-
run: npm ci
49+
run: npm ci --omit=optional
4350

4451
# Split the diff into added/modified files (to translate) and deleted files (to clean up).
4552
- name: Get changed translatable files

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@
5252
"eslint": "^10.1.0",
5353
"eslint-plugin-astro": "^1.6.0",
5454
"globals": "^17.4.0",
55-
"puppeteer": "^24.0.0",
5655
"typescript": "^5.9.3",
5756
"typescript-eslint": "^8.57.2"
5857
},
58+
"optionalDependencies": {
59+
"puppeteer": "^24.0.0"
60+
},
5961
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
6062
}

0 commit comments

Comments
 (0)