Skip to content

Commit 1132c0a

Browse files
authored
ci: adjust caching to apply to all OSs (#1182)
1 parent 5508c95 commit 1132c0a

File tree

3 files changed

+88
-48
lines changed

3 files changed

+88
-48
lines changed

.github/workflows/nodejs.yml

Lines changed: 33 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,21 @@ on:
1111
- next
1212

1313
jobs:
14-
prepare-yarn-cache:
15-
name: Prepare yarn cache
16-
runs-on: ubuntu-latest
17-
18-
steps:
19-
- uses: actions/checkout@v3
20-
21-
- uses: actions/setup-node@v3
22-
with:
23-
node-version: lts/*
24-
cache: yarn
25-
26-
- name: Validate cache
27-
env:
28-
# Use PnP and disable postinstall scripts as this just needs to
29-
# populate the cache for the other jobs
30-
YARN_NODE_LINKER: pnp
31-
YARN_ENABLE_SCRIPTS: false
32-
run: yarn --immutable
14+
prepare-yarn-cache-ubuntu:
15+
uses: ./.github/workflows/prepare-cache.yml
16+
with:
17+
os: ubuntu-latest
18+
prepare-yarn-cache-macos:
19+
uses: ./.github/workflows/prepare-cache.yml
20+
with:
21+
os: macos-latest
22+
prepare-yarn-cache-windows:
23+
uses: ./.github/workflows/prepare-cache.yml
24+
with:
25+
os: windows-latest
3326

3427
prettier:
35-
needs: prepare-yarn-cache
28+
needs: prepare-yarn-cache-ubuntu
3629
runs-on: ubuntu-latest
3730
steps:
3831
- uses: actions/checkout@v3
@@ -46,7 +39,7 @@ jobs:
4639
run: yarn prettier:check
4740

4841
typecheck:
49-
needs: prepare-yarn-cache
42+
needs: prepare-yarn-cache-ubuntu
5043
runs-on: ubuntu-latest
5144
steps:
5245
- uses: actions/checkout@v3
@@ -63,7 +56,7 @@ jobs:
6356
name:
6457
# prettier-ignore
6558
Test on Node.js v${{ matrix.node-version }}, eslint v${{ matrix.eslint-version }}
66-
needs: prepare-yarn-cache
59+
needs: prepare-yarn-cache-ubuntu
6760
strategy:
6861
fail-fast: false
6962
matrix:
@@ -91,34 +84,25 @@ jobs:
9184
CI: true
9285
- uses: codecov/codecov-action@v3
9386
if: ${{ matrix.eslint-version >= 8 }}
94-
test-os:
95-
name: Test on ${{ matrix.os }} using Node.js LTS
96-
needs: prepare-yarn-cache
97-
strategy:
98-
fail-fast: false
99-
matrix:
100-
os: [ubuntu-latest, windows-latest, macOS-latest]
101-
runs-on: ${{ matrix.os }}
102-
103-
steps:
104-
- uses: actions/checkout@v3
105-
- uses: actions/setup-node@v3
106-
with:
107-
node-version: lts/*
108-
cache: yarn
109-
- name: install
110-
run: yarn
111-
- name: run tests
112-
# only collect coverage on eslint versions that support dynamic import
113-
run: yarn test --coverage ${{ matrix.eslint-version >= 8 }}
114-
env:
115-
CI: true
116-
- uses: codecov/codecov-action@v3
117-
if: ${{ matrix.eslint-version >= 8 }}
87+
test-ubuntu:
88+
uses: ./.github/workflows/test.yml
89+
needs: prepare-yarn-cache-ubuntu
90+
with:
91+
os: ubuntu-latest
92+
test-macos:
93+
uses: ./.github/workflows/test.yml
94+
needs: prepare-yarn-cache-macos
95+
with:
96+
os: macos-latest
97+
test-windows:
98+
uses: ./.github/workflows/test.yml
99+
needs: prepare-yarn-cache-windows
100+
with:
101+
os: windows-latest
118102

119103
docs:
120104
if: ${{ github.event_name == 'pull_request' }}
121-
needs: prepare-yarn-cache
105+
needs: prepare-yarn-cache-ubuntu
122106
runs-on: ubuntu-latest
123107
steps:
124108
- uses: actions/checkout@v3
@@ -141,7 +125,8 @@ jobs:
141125
# prettier-ignore
142126
${{ github.event_name == 'push' && (github.event.ref == 'refs/heads/main' || github.event.ref == 'refs/heads/next') }}
143127
name: Release new version
144-
needs: [prettier, typecheck, test-node, test-os]
128+
needs:
129+
[prettier, typecheck, test-node, test-ubuntu, test-macos, test-windows]
145130
runs-on: ubuntu-latest
146131
steps:
147132
- uses: actions/checkout@v3

.github/workflows/prepare-cache.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Prepare CI cache
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
prepare-yarn-cache:
12+
name: Prepare yarn cache for ${{ inputs.os }}
13+
runs-on: ${{ inputs.os }}
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- uses: actions/setup-node@v3
19+
with:
20+
node-version: lts/*
21+
cache: yarn
22+
23+
- name: Validate cache
24+
env:
25+
# Use PnP and disable postinstall scripts as this just needs to
26+
# populate the cache for the other jobs
27+
YARN_NODE_LINKER: pnp
28+
YARN_ENABLE_SCRIPTS: false
29+
run: yarn --immutable

.github/workflows/test.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Test
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
os:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
test:
12+
name: Test on ${{ inputs.os }} using Node.js LTS
13+
runs-on: ${{ inputs.os }}
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: lts/*
20+
cache: yarn
21+
- name: install
22+
run: yarn
23+
- name: run tests
24+
run: yarn test
25+
env:
26+
CI: true

0 commit comments

Comments
 (0)