Skip to content

Commit 7cc47fc

Browse files
chore(ci): move node setup and package install to dedicated action (#1822)
1 parent b2f05b1 commit 7cc47fc

File tree

7 files changed

+87
-144
lines changed

7 files changed

+87
-144
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: 'Setup Node and Install Dependencies'
2+
description: 'Sets up Node.js, configures NPM cache, and installs dependencies with retry logic'
3+
4+
inputs:
5+
node-version:
6+
description: 'Version of Node.js to install'
7+
required: false
8+
default: '22'
9+
platform:
10+
description: 'Platform identifier for cache key (e.g., linux-x64, macos-arm, windows-x64)'
11+
required: true
12+
save-cache:
13+
description: 'Whether to save the NPM cache at the end'
14+
required: false
15+
default: 'false'
16+
17+
outputs:
18+
cache-dir:
19+
description: 'Path to the NPM cache directory'
20+
value: ${{ steps.npm-cache-dir.outputs.dir }}
21+
cache-hit:
22+
description: 'Whether the cache was restored successfully'
23+
value: ${{ steps.restore-cache.outputs.cache-hit }}
24+
25+
runs:
26+
using: 'composite'
27+
steps:
28+
- name: Install Node
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: ${{ inputs.node-version }}
32+
33+
- name: Get NPM cache directory
34+
id: npm-cache-dir
35+
shell: bash
36+
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
37+
38+
- name: Restore NPM cache
39+
id: restore-cache
40+
uses: actions/cache/restore@v4
41+
with:
42+
path: ${{ steps.npm-cache-dir.outputs.dir }}
43+
key: npm-main-${{ inputs.platform }}-${{ hashFiles('./package-lock.json') }}
44+
restore-keys: |
45+
npm-main-${{ inputs.platform }}-
46+
47+
- name: Download dependencies
48+
shell: bash
49+
run: |
50+
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
51+
52+
- name: Save NPM cache
53+
if: inputs.save-cache == 'true'
54+
uses: actions/cache/save@v4
55+
with:
56+
path: ${{ steps.npm-cache-dir.outputs.dir }}
57+
key: npm-main-${{ inputs.platform }}-${{ hashFiles('./package-lock.json') }}

.github/workflows/ci.yml

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,11 @@ jobs:
159159
name: corebridge-native-debug-${{ matrix.platform }}
160160
path: ./packages/core-bridge/releases
161161

162-
- name: Install Node
163-
uses: actions/setup-node@v4
162+
- name: Setup Node and Install Dependencies
163+
uses: ./.github/actions/setup-node-deps
164164
with:
165165
node-version: ${{ matrix.node-release-override || matrix.node }}
166+
platform: ${{ matrix.platform }}
166167

167168
# On Windows, the 'runner.temp' variable uses backslashes as path separators, but
168169
# that may pose problems in later steps when we try to join that with subpaths;
@@ -176,23 +177,6 @@ jobs:
176177
run: echo "dir=$(pwd)" >> ${GITHUB_OUTPUT}
177178
working-directory: ${{ runner.temp }}
178179

179-
- name: Get NPM cache directory
180-
id: npm-cache-dir
181-
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
182-
183-
- name: Restore NPM cache
184-
uses: actions/cache/restore@v4
185-
with:
186-
path: ${{ steps.npm-cache-dir.outputs.dir }}
187-
key: npm-main-${{ matrix.platform }}-${{ hashFiles('./package-lock.json') }}
188-
restore-keys: |
189-
npm-main-${{ matrix.platform }}-
190-
191-
- name: Download dependencies
192-
# Make up to 3 attempts to install NPM dependencies, to work around transient NPM errors :(
193-
run: |
194-
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
195-
196180
- name: Compile code
197181
run: npm run build -- --ignore @temporalio/core-bridge
198182

.github/workflows/conventions.yml

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,11 @@ jobs:
2020
with:
2121
submodules: recursive
2222

23-
- name: Install Node
24-
uses: actions/setup-node@v4
23+
- name: Setup Node and Install Dependencies
24+
uses: ./.github/actions/setup-node-deps
2525
with:
26-
node-version: 22
27-
28-
- name: Get NPM cache directory
29-
id: npm-cache-dir
30-
shell: bash
31-
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
32-
33-
- name: Restore NPM cache
34-
uses: actions/cache/restore@v4
35-
with:
36-
path: ${{ steps.npm-cache-dir.outputs.dir }}
37-
key: npm-main-linux-x64-${{ hashFiles('./package-lock.json') }}
38-
restore-keys: |
39-
npm-main-linux-x64-
26+
node-version: '22'
27+
platform: 'linux-x64'
4028

4129
- name: Install protoc
4230
uses: arduino/setup-protoc@v3
@@ -58,10 +46,6 @@ jobs:
5846
env-vars: ''
5947
save-if: false
6048

61-
- name: Download dependencies
62-
run: |
63-
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
64-
6549
# eslint-import-resolver-typescript requires packages to be built
6650
- name: Compile all non-rust code
6751
run: npm run build -- --ignore @temporalio/core-bridge

.github/workflows/docs.yml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,11 @@ jobs:
3939
with:
4040
submodules: recursive
4141

42-
- name: Install Node
43-
uses: actions/setup-node@v4
42+
- name: Setup Node and Install Dependencies
43+
uses: ./.github/actions/setup-node-deps
4444
with:
45-
node-version: 22
46-
47-
- name: Get NPM cache directory
48-
id: npm-cache-dir
49-
shell: bash
50-
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
51-
52-
- name: Restore NPM cache
53-
uses: actions/cache/restore@v4
54-
with:
55-
path: ${{ steps.npm-cache-dir.outputs.dir }}
56-
key: npm-main-linux-x64-${{ hashFiles('./package-lock.json') }}
57-
restore-keys: |
58-
npm-main-linux-x64-
59-
60-
- name: Download dependencies
61-
# Make up to 3 attempts to install NPM dependencies, to work around transient NPM errors
62-
# Don't build during install phase since we're going to explicitly build anyway
63-
run: |
64-
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
45+
node-version: '22'
46+
platform: 'linux-x64'
6547

6648
- run: npm run build -- --ignore @temporalio/core-bridge
6749

.github/workflows/nightly-throughput-stress.yml

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,22 +75,12 @@ jobs:
7575
go-version-file: omes/go.mod
7676
cache-dependency-path: omes/go.sum
7777

78-
- name: Setup Node
79-
uses: actions/setup-node@v4
78+
- name: Setup Node and Install Dependencies
79+
id: setup-node
80+
uses: ./.github/actions/setup-node-deps
8081
with:
81-
node-version: 22
82-
83-
- name: Get NPM cache directory
84-
id: npm-cache-dir
85-
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
86-
87-
- name: Restore NPM cache
88-
uses: actions/cache/restore@v4
89-
with:
90-
path: ${{ steps.npm-cache-dir.outputs.dir }}
91-
key: npm-main-linux-x64-${{ hashFiles('./package-lock.json') }}
92-
restore-keys: |
93-
npm-main-linux-x64-
82+
node-version: '22'
83+
platform: 'linux-x64'
9484

9585
- name: Install protoc
9686
uses: arduino/setup-protoc@v3
@@ -106,12 +96,6 @@ jobs:
10696
with:
10797
workspaces: packages/core-bridge -> target
10898

109-
- name: Install SDK dependencies
110-
run: |
111-
npm ci --ignore-scripts --verbose || \
112-
npm ci --ignore-scripts --verbose || \
113-
npm ci --ignore-scripts --verbose
114-
11599
- name: Build SDK
116100
run: npm run build
117101
env:
@@ -121,7 +105,7 @@ jobs:
121105
uses: actions/cache/save@v4
122106
if: always()
123107
with:
124-
path: ${{ steps.npm-cache-dir.outputs.dir }}
108+
path: ${{ steps.setup-node.outputs.cache-dir }}
125109
key: npm-main-linux-x64-${{ hashFiles('./package-lock.json') }}
126110

127111
- name: Install Temporal CLI

.github/workflows/release.yml

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -169,27 +169,12 @@ jobs:
169169
mv tmp/corebridge-*/* ./
170170
rm -rf tmp
171171
172-
- name: Install Node
173-
uses: actions/setup-node@v4
172+
- name: Setup Node and Install Dependencies
173+
id: setup-node
174+
uses: ./.github/actions/setup-node-deps
174175
with:
175-
node-version: 22
176-
177-
- name: Get NPM cache directory
178-
id: npm-cache-dir
179-
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
180-
181-
- name: Restore NPM cache
182-
uses: actions/cache/restore@v4
183-
with:
184-
path: ${{ steps.npm-cache-dir.outputs.dir }}
185-
key: npm-main-${{ matrix.platform }}-${{ hashFiles('./package-lock.json') }}
186-
restore-keys: |
187-
npm-main-${{ matrix.platform }}-
188-
189-
- name: Download dependencies
190-
# Make up to 3 attempts to install NPM dependencies, to work around transient NPM errors :(
191-
run: |
192-
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
176+
node-version: '22'
177+
platform: ${{ matrix.platform }}
193178

194179
- name: Compile code
195180
run: npm run build -- --ignore @temporalio/core-bridge
@@ -208,7 +193,7 @@ jobs:
208193
# Only saves NPM cache from the main branch, to reduce pressure on the cache (limited to 10GB).
209194
if: ${{ env.IS_MAIN_OR_RELEASE == 'true' }}
210195
with:
211-
path: ${{ steps.npm-cache-dir.outputs.dir }}
196+
path: ${{ steps.setup-node.outputs.cache-dir }}
212197
key: npm-main-${{ matrix.platform }}-${{ hashFiles('./package-lock.json') }}
213198

214199
# Tests that npm init @temporalio results in a working worker and client
@@ -258,28 +243,11 @@ jobs:
258243
# We don't need the core submodule here since won't build the project
259244
submodules: false
260245

261-
- name: Install Node
262-
uses: actions/setup-node@v4
246+
- name: Setup Node and Install Dependencies
247+
uses: ./.github/actions/setup-node-deps
263248
with:
264249
node-version: ${{ matrix.node }}
265-
266-
- name: Get NPM cache directory
267-
id: npm-cache-dir
268-
shell: bash
269-
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
270-
271-
- name: Restore NPM cache
272-
uses: actions/cache/restore@v4
273-
with:
274-
path: ${{ steps.npm-cache-dir.outputs.dir }}
275-
key: npm-main-${{ matrix.platform }}-${{ hashFiles('./package-lock.json') }}
276-
restore-keys: |
277-
npm-main-${{ matrix.platform }}-
278-
279-
# No need to compile anything, we just need the package ./scripts and their dependencies
280-
- name: Install dependencies without compilation
281-
run: |
282-
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
250+
platform: ${{ matrix.platform }}
283251

284252
- name: Restore Verdaccio repo artifact
285253
uses: actions/download-artifact@v4

.github/workflows/stress.yml

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,11 @@ jobs:
6363
submodules: recursive
6464
ref: ${{ inputs.ref }}
6565

66-
- name: Install Node
67-
uses: actions/setup-node@v4
66+
- name: Setup Node and Install Dependencies
67+
uses: ./.github/actions/setup-node-deps
6868
with:
69-
node-version: 22
70-
71-
- name: Get NPM cache directory
72-
id: npm-cache-dir
73-
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
74-
75-
- name: Restore NPM cache
76-
uses: actions/cache/restore@v4
77-
with:
78-
path: ${{ steps.npm-cache-dir.outputs.dir }}
79-
key: npm-main-linux-x64-${{ hashFiles('./package-lock.json') }}
80-
restore-keys: |
81-
npm-main-linux-x64-
69+
node-version: '22'
70+
platform: 'linux-x64'
8271

8372
- name: Install protoc
8473
uses: arduino/setup-protoc@v3
@@ -99,11 +88,6 @@ jobs:
9988
env-vars: ''
10089
save-if: ${{ env.IS_MAIN_OR_RELEASE == 'true' }}
10190

102-
- name: Download dependencies
103-
# Make up to 3 attempts to install NPM dependencies, to work around transient NPM errors
104-
run: |
105-
npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose || npm ci --ignore-scripts --verbose
106-
10791
- name: Compile code
10892
run: npm run build
10993
env:

0 commit comments

Comments
 (0)