8000 ref(CI): Speed up testing in GHA (#3237) · Zlash65/sentry-javascript@8cb7a49 · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8cb7a49

Browse files
authored
ref(CI): Speed up testing in GHA (getsentry#3237)
1 parent 35aaf90 commit 8cb7a49

File tree

5 files changed

+302
-176
lines changed

5 files changed

+302
-176
lines changed

.github/workflows/build.yml

Lines changed: 174 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,80 @@ on:
66
- release/**
77
pull_request:
88

9+
env:
10+
CACHED_DEPENDENCY_PATHS: |
11+
${{ github.workspace }}/node_modules
12+
${{ github.workspace }}/packages/**/node_modules
13+
14+
# DEPENDENCY_CACHE_KEY: can't be set here because we don't have access to yarn.lock
15+
16+
CACHED_BUILD_PATHS: |
17+
${{ github.workspace }}/packages/**/build
18+
${{ github.workspace }}/packages/**/dist
19+
${{ github.workspace }}/packages/**/esm
20+
${{ github.workspace }}/packages/serverless/dist-awslambda-layer/*.zip
21+
22+
BUILD_CACHE_KEY: ${{ github.sha }}
23+
924
jobs:
25+
job_install_deps:
26+
name: Install Dependencies
27+
runs-on: ubuntu-latest
28+
timeout-minutes: 15
29+
steps:
30+
- name: Check out current commit (${{ github.sha }})
31+
uses: actions/checkout@v2
32+
- name: Set up Node
33+
uses: actions/setup-node@v1
34+
# we use a hash of yarn.lock as our cache key, because if it hasn't changed, our dependencies haven't changed,
35+
# so no need to reinstall them
36+
- name: Compute dependency cache key
37+
id: compute_lockfile_hash
38+
run: echo "::set-output name=hash::${{ hashFiles('yarn.lock') }}"
39+
- name: Check dependency cache
40+
uses: actions/cache@v2
41+
id: cache_dependencies
42+
with:
43+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
44+
key: ${{ steps.compute_lockfile_hash.outputs.hash }}
45+
- name: Install dependencies
46+
if: steps.cache_dependencies.outputs.cache-hit == ''
47+
run: yarn install
48+
outputs:
49+
dependency_cache_key: ${{ steps.compute_lockfile_hash.outputs.hash }}
50+
1051
job_build:
1152
name: Build
53+
needs: job_install_deps
1254
runs-on: ubuntu-latest
1355
timeout-minutes: 15
1456
steps:
15-
- uses: actions/checkout@v2
16-
- uses: actions/setup-node@v1
17-
- uses: actions/cache@v2
57+
- name: Check out current commit (${{ github.sha }})
58+
uses: actions/checkout@v2
59+
- name: Set up Node
60+
uses: actions/setup-node@v1
61+
- name: Check dependency cache
62+
uses: actions/cache@v2
1863
with:
19-
path: |
20-
${{ github.workspace }}/node_modules
21-
${{ github.workspace }}/packages/**/node_modules
22-
${{ github.workspace }}/packages/**/build
23-
${{ github.workspace }}/packages/**/dist
24-
${{ github.workspace }}/packages/**/esm
25-
${{ github.workspace }}/packages/serverless/dist-awslambda-layer/*.zip
26-
key: ${{ github.sha }}
27-
- name: Install
28-
run: yarn install
29-
- name: Build
64+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
65+
key: ${{ needs.job_install_deps.outputs.dependency_cache_key }}
66+
- name: Check build cache
67+
uses: actions/cache@v2
68+
id: cache_built_packages
69+
with:
70+
path: ${{ env.CACHED_BUILD_PATHS }}
71+
key: ${{ env.BUILD_CACHE_KEY }}
72+
- name: Build packages
73+
# Under normal circumstances, using the git SHA as a cache key, there shouldn't ever be a cache hit on the built
74+
# packages, and so `yarn build` should always run. This `if` check is therefore only there for testing CI issues
75+
# where the built packages are beside the point. In that case, you can change `BUILD_CACHE_KEY` (at the top of
76+
# this file) to a constant and skip rebuilding all of the packages each time CI runs.
77+
if: steps.cache_built_packages.outputs.cache-hit == ''
3078
run: yarn build
79+
outputs:
80+
# this needs to be passed on, because the `needs` context only looks at direct ancestors (so steps which depend on
81+
# `job_build` can't see `job_install_deps` and what it returned)
82+
dependency_cache_key: ${{ needs.job_install_deps.outputs.dependency_cache_key }}
3183

3284
job_size_check:
3385
name: Size Check
@@ -36,19 +88,22 @@ jobs:
3688
runs-on: ubuntu-latest
3789
if: ${{ github.head_ref }}
3890
steps:
39-
- uses: actions/checkout@v2
40-
- uses: actions/setup-node@v1
41-
- uses: actions/cache@v2
91+
- name: Check out current commit (${{ github.sha }})
92+
uses: actions/checkout@v2
93+
- name: Set up Node
94+
uses: actions/setup-node@v1
95+
- name: Check dependency cache
96+
uses: actions/cache@v2
4297
with:
43-
path: |
44-
${{ github.workspace }}/node_modules
45-
${{ github.workspace }}/packages/**/node_modules
46-
${{ github.workspace }}/packages/**/build
47-
${{ github.workspace }}/packages/**/dist
48-
${{ github.workspace }}/packages/**/esm
49-
${{ github.workspace }}/packages/serverless/dist-awslambda-layer/*.zip
50-
key: ${{ github.sha }}
51-
- uses: andresz1/size-limit-action@v1.4.0
98+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
99+
key: ${{ needs.job_build.outputs.dependency_cache_key }}
100+
- name: Check build cache
101+
uses: actions/cache@v2
102+
with:
103+
path: ${{ env.CACHED_BUILD_PATHS }}
104+
key: ${{ env.BUILD_CACHE_KEY }}
105+
- name: Check bundle sizes
106+
uses: andresz1/size-limit-action@v1.4.0
52107
with:
53108
github_token: ${{ secrets.GITHUB_TOKEN }}
54109
skip_step: build
@@ -59,20 +114,21 @@ jobs:
59114
timeout-minutes: 10
60115
runs-on: ubuntu-latest
61116
steps:
62-
- uses: actions/checkout@v2
63-
- uses: actions/setup-node@v1
64-
- uses: actions/cache@v2
117+
- name: Check out current commit (${{ github.sha }})
118+
uses: actions/checkout@v2
119+
- name: Set up Node
120+
uses: actions/setup-node@v1
121+
- name: Check dependency cache
122+
uses: actions/cache@v2
65123
with:
66-
path: |
67-
${{ github.workspace }}/node_modules
68-
${{ github.workspace }}/packages/**/node_modules
69-
${{ github.workspace }}/packages/**/build
70-
${{ github.workspace }}/packages/**/dist
71-
${{ github.workspace }}/packages/**/esm
72-
${{ github.workspace }}/packages/serverless/dist-awslambda-layer/*.zip
73-
key: ${{ github.sha }}
74-
- run: yarn install
75-
- name: Run Linter
124+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
125+
key: ${{ needs.job_build.outputs.dependency_cache_key }}
126+
- name: Check build cache
127+
uses: actions/cache@v2
128+
with:
129+
path: ${{ env.CACHED_BUILD_PATHS }}
130+
key: ${{ env.BUILD_CACHE_KEY }}
131+
- name: Run linter
76132
run: yarn lint
77133

78134
job_unit_test:
@@ -85,47 +141,85 @@ jobs:
85141
matrix:
86142
node: [6, 8, 10, 12, 14]
87143
steps:
88-
- uses: actions/checkout@v2
89-
- uses: actions/setup-node@v1
144+
- name: Check out current commit (${{ github.sha }})
145+
uses: actions/checkout@v2
146+
- name: Set up Node
147+
uses: actions/setup-node@v1
90148
with:
91149
node-version: ${{ matrix.node }}
92-
- uses: actions/cache@v2
150+
- name: Check dependency cache
151+
uses: actions/cache@v2
93152
with:
94-
path: |
95-
${{ github.workspace }}/node_modules
96-
${{ github.workspace }}/packages/**/node_modules
97-
${{ github.workspace }}/packages/**/build
98-
${{ github.workspace }}/packages/**/dist
99-
${{ github.workspace }}/packages/**/esm
100-
${{ github.workspace }}/packages/serverless/dist-awslambda-layer/*.zip
101-
key: ${{ github.sha }}
102-
- name: Unit Tests
153+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
154+
key: ${{ needs.job_build.outputs.dependency_cache_key }}
155+
- name: Check build cache
156+
uses: actions/cache@v2
157+
with:
158+
path: ${{ env.CACHED_BUILD_PATHS }}
159+
key: ${{ env.BUILD_CACHE_KEY }}
160+
- name: Run tests
103161
env:
104162
NODE_VERSION: ${{ matrix.node }}
105163
run: ./scripts/test.sh
106-
- uses: codecov/codecov-action@v1
164+
- name: Compute test coverage
165+
uses: codecov/codecov-action@v1
166+
167+
# Ember tests are separate from the rest because they are the slowest part of the test suite, and making them a
168+
# separate job allows them to run in parallel with the other tests.
169+
job_ember_tests:
170+
name: Test @sentry/ember
171+
needs: job_build
172+
continue-on-error: true
173+
timeout-minutes: 30
174+
runs-on: ubuntu-latest
175+
steps:
176+
- name: Check out current commit (${{ github.sha }})
177+
uses: actions/checkout@v2
178+
- name: Set up Node
179+
uses: actions/setup-node@v1
180+
with:
181+
# The only danger with Ember in terms of Node versions is that the build tool, ember-cli, won't work if Node
182+
# is too old. Since Oct 2019, Node 10 has been the oldest version supported by ember-cli, so test against
183+
# that. If it passes, newer versions of Node should also be fine. This saves us from having to run the Ember
184+
# tests in our Node matrix above.
185+
node-version: '10'
186+
- name: Check dependency cache
187+
uses: actions/cache@v2
188+
with:
189+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
190+
key: ${{ needs.job_build.outputs.dependency_cache_key }}
191+
- name: Check build cache
192+
uses: actions/cache@v2
193+
with:
194+
path: ${{ env.CACHED_BUILD_PATHS }}
195+
key: ${{ env.BUILD_CACHE_KEY }}
196+
- name: Run Ember tests
197+
run: yarn test --scope=@sentry/ember
198+
- name: Compute test coverage
199+
uses: codecov/codecov-action@v1
107200

108201
job_artifacts:
109-
name: Artifacts Upload
202+
name: Upload Artifacts
110203
needs: job_build
111204
runs-on: ubuntu-latest
112205
steps:
113-
- uses: actions/checkout@v2
114-
- uses: actions/setup-node@v1
115-
- uses: actions/cache@v2
206+
- name: Check out current commit (${{ github.sha }})
207+
uses: actions/checkout@v2
208+
- name: Set up Node
209+
uses: actions/setup-node@v1
210+
- name: Check dependency cache
211+
uses: actions/cache@v2
116212
with:
117-
path: |
118-
${{ github.workspace }}/node_modules
119-
${{ github.workspace }}/packages/**/node_modules
120-
${{ github.workspace }}/packages/**/build
121-
${{ github.workspace }}/packages/**/dist
122-
${{ github.workspace }}/packages/**/esm
123-
${{ github.workspace }}/packages/serverless/dist-awslambda-layer/*.zip
124-
key: ${{ github.sha }}
213+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
214+
key: ${{ needs.job_build.outputs.dependency_cache_key }}
215+
- name: Check build cache
216+
uses: actions/cache@v2
217+
with:
218+
path: ${{ env.CACHED_BUILD_PATHS }}
219+
key: ${{ env.BUILD_CACHE_KEY }}
125220
- name: Pack
126221
run: yarn pack:changed
127-
- run: yarn install
128-
- name: Archive Artifacts
222+
- name: Archive artifacts
129223
uses: actions/upload-artifact@v2
130224
with:
131225
name: ${{ github.sha }}
@@ -146,20 +240,21 @@ jobs:
146240
# if: startsWith(github.ref, 'refs/heads/release/')
147241
if: false
148242
steps:
149-
- uses: actions/checkout@v2
150-
- uses: actions/setup-node@v1
151-
- uses: actions/cache@v2
243+
- name: Check out current commit (${{ github.sha }})
244+
uses: actions/checkout@v2
245+
- name: Set up Node
246+
uses: actions/setup-node@v1
247+
- name: Check dependency cache
248+
uses: actions/cache@v2
152249
with:
153-
path: |
154-
${{ github.workspace }}/node_modules
155-
${{ github.workspace }}/packages/**/node_modules
156-
${{ github.workspace }}/packages/**/build
157-
${{ github.workspace }}/packages/**/dist
158-
${{ github.workspace }}/packages/**/esm
159-
${{ github.workspace }}/packages/serverless/dist-awslambda-layer/*.zip
160-
key: ${{ github.sha }}
161-
- run: yarn install
162-
- name: Integration Tests
250+
path: ${{ env.CACHED_DEPENDENCY_PATHS }}
251+
key: ${{ needs.job_build.outputs.dependency_cache_key }}
252+
- name: Check build cache
253+
uses: actions/cache@v2
254+
with:
255+
path: ${{ env.CACHED_BUILD_PATHS }}
256+
key: ${{ env.BUILD_CACHE_KEY }}
257+
- name: Run integration tests
163258
env:
164259
BROWSERSTACK_USERNAME: ${{ secrets.BROWSERSTACK_USERNAME }}
165260
BROWSERSTACK_ACCESS_KEY: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}

0 commit comments

Comments
 (0)
0