-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
203 lines (176 loc) · 6.82 KB
/
mutation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
name: 'Mutation Testing'
on:
push:
branches:
- lms/test-hackweek-mutation-testing
workflow_dispatch:
inputs:
commit:
description: If the commit you want to test isn't the head of a branch, provide its SHA here
required: false
schedule:
# run every sunday at midnight:
- cron: '0 0 * * 0'
# Cancel in progress workflows on pull_requests.
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-a-fallback-value
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
HEAD_COMMIT: ${{ github.event.inputs.commit || github.sha }}
# WARNING: this disables cross os caching as ~ and
# github.workspace evaluate to differents paths
CACHED_DEPENDENCY_PATHS: |
${{ github.workspace }}/node_modules
${{ github.workspace }}/packages/*/node_modules
${{ github.workspace }}/dev-packages/*/node_modules
~/.cache/mongodb-binaries/
# DEPENDENCY_CACHE_KEY: can't be set here because we don't have access to yarn.lock
# WARNING: this disables cross os caching as ~ and
# github.workspace evaluate to differents paths
# packages/utils/cjs and packages/utils/esm: Symlinks to the folders inside of `build`, needed for tests
CACHED_BUILD_PATHS: |
${{ github.workspace }}/dev-packages/*/build
${{ github.workspace }}/packages/*/build
${{ github.workspace }}/packages/ember/*.d.ts
${{ github.workspace }}/packages/gatsby/*.d.ts
${{ github.workspace }}/packages/core/src/version.ts
${{ github.workspace }}/packages/utils/cjs
${{ github.workspace }}/packages/utils/esm
BUILD_CACHE_KEY: build-cache-${{ github.event.inputs.commit || github.sha }}
BUILD_CACHE_TARBALL_KEY: tarball-${{ github.event.inputs.commit || github.sha }}
# GH will use the first restore-key it finds that matches
# So it will start by looking for one from the same branch, else take the newest one it can find elsewhere
# We want to prefer the cache from the current develop branch, if we don't find any on the current branch
NX_CACHE_RESTORE_KEYS: |
nx-Linux-${{ github.ref }}-${{ github.event.inputs.commit || github.sha }}
nx-Linux-${{ github.ref }}
nx-Linux
jobs:
job_get_metadata:
name: Get Metadata
runs-on: ubuntu-20.04
permissions:
pull-requests: read
steps:
- name: Check out current commit
uses: actions/checkout@v4
with:
ref: ${{ env.HEAD_COMMIT }}
# We need to check out not only the fake merge commit between the PR and the base branch which GH creates, but
# also its parents, so that we can pull the commit message from the head commit of the PR
fetch-depth: 2
- name: Get metadata
id: get_metadata
# We need to try a number of different options for finding the head commit, because each kind of trigger event
# stores it in a different location
run: |
COMMIT_SHA=$(git rev-parse --short ${{ github.event.head_commit.id || env.HEAD_COMMIT }})
echo "COMMIT_SHA=$COMMIT_SHA" >> $GITHUB_ENV
echo "COMMIT_MESSAGE=$(git log -n 1 --pretty=format:%s $COMMIT_SHA)" >> $GITHUB_ENV
outputs:
commit_label: '${{ env.COMMIT_SHA }}: ${{ env.COMMIT_MESSAGE }}'
job_build:
name: Build
needs: job_get_metadata
runs-on: ubuntu-20.04
timeout-minutes: 15
steps:
- name: 'Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})'
uses: actions/checkout@v4
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- name: Install Dependencies
uses: ./.github/actions/install-dependencies
id: install_dependencies
- name: Check build cache
uses: actions/cache@v4
id: cache_built_packages
with:
path: ${{ env.CACHED_BUILD_PATHS }}
key: ${{ env.BUILD_CACHE_KEY }}
- name: NX cache
uses: actions/cache@v4
with:
path: .nxcache
key: nx-Linux-${{ github.ref }}-${{ env.HEAD_COMMIT || github.sha }}
restore-keys:
${{ env.NX_CACHE_RESTORE_KEYS || 'nx-never-restore'}}
- name: Build packages
run: yarn build
- name: Generate Sentry Trace
id: sentry_trace
run: |
node ./scripts/stryker/start-trace.mjs
- name: Test 1
run: |
ls -la node_modules/.bin
ls -la packages/core/node_modules/.bin
ls -la packages/svelte/node_modules/.bin
ls -la packages/browser/node_modules/.bin
outputs:
dependency_cache_key: ${{ steps.install_dependencies.outputs.cache_key }}
sentry_trace: '${{ env.SENTRY_MUT_SENTRY_TRACE }}'
baggage: '${{ env.SENTRY_MUT_BAGGAGE }}'
job_mutation_test:
name: Mutation Test (${{ matrix.package }})
needs: [job_get_metadata, job_build]
timeout-minutes: 180
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
package: [
'@sentry/core',
'@sentry/browser',
'@sentry/node',
'@sentry/svelte',
'@sentry/sveltekit',
]
steps:
- name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }})
uses: actions/checkout@v4
with:
ref: ${{ env.HEAD_COMMIT }}
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
- name: Restore caches
uses: ./.github/actions/restore-cache
env:
DEPENDENCY_CACHE_KEY: ${{ needs.job_build.outputs.dependency_cache_key }}
- name: NX cache
uses: actions/cache@v4
with:
path: .nxcache
key: nx-Linux-${{ github.ref }}-${{ env.HEAD_COMMIT || github.sha }}
restore-keys:
${{ env.NX_CACHE_RESTORE_KEYS || 'nx-never-restore'}}
- name: Run yarn again
run: yarn
- name: Set trace propagation data
run: |
echo "SENTRY_MUT_SENTRY_TRACE=${{ needs.job_build.outputs.sentry_trace }}" >> $GITHUB_ENV
echo "SENTRY_MUT_BAGGAGE=${{ needs.job_build.outputs.baggage }}" >> $GITHUB_ENV
- name: Test 2
run: |
ls -la node_modules/.bin
ls -la packages/core/node_modules/.bin
ls -la packages/svelte/node_modules/.bin
ls -la packages/browser/node_modules/.bin
- name: Run mutation test
run: yarn nx run ${{ matrix.package }}:test:mutation
env:
NODE_VERSION: ${{ matrix.node }}
- name: Upload Results
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.package }} reports
path: |
${{ github.workspace }}/packages/**/mutation.json
${{ github.workspace }}/packages/**/mutation.html