Repository navigation
187 lines (181 loc) · 6.47 KB
/
Copy pathrelease-gate.yml
File metadata and controls
187 lines (181 loc) · 6.47 KB
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
name: Release gate
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: release-gate-${{ github.ref }}
cancel-in-progress: false
jobs:
plan:
name: plan · mutation shards
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
matrix: ${{ steps.publish.outputs.matrix }}
has-shards: ${{ steps.publish.outputs.has-shards }}
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: ./.github/actions/dev-shell
- name: Discover mutation projects
uses: ./.github/actions/sandbox
with:
hosts: |
jsr.io
registry.npmjs.org
command: >-
deno run --config=scripts/deno.json --allow-read --allow-write
scripts/stryker-plan-gate.ts projects --out .cache/mutation-projects.txt
- id: projects
name: Publish the project list
run: echo "projects=$(cat .cache/mutation-projects.txt)" >> "$GITHUB_OUTPUT"
- name: Plan mutation shards
if: steps.projects.outputs.projects != ''
uses: ./.github/actions/sandbox
env:
MUTATION_PROJECTS: ${{ steps.projects.outputs.projects }}
with:
hosts: |
jsr.io
registry.npmjs.org
pass-env: MUTATION_PROJECTS
command: ./node_modules/.bin/stryker plan --target-seconds 900 --projects "$MUTATION_PROJECTS" --out stryker-plan.json
- name: Gate the plan
uses: ./.github/actions/sandbox
with:
hosts: |
jsr.io
registry.npmjs.org
command: >-
deno run --config=scripts/deno.json --allow-read --allow-write
scripts/stryker-plan-gate.ts gate --plan stryker-plan.json --out .cache/mutation-plan.out
- id: publish
name: Publish the plan
run: cat .cache/mutation-plan.out >> "$GITHUB_OUTPUT"
- if: always()
uses: actions/upload-artifact@v7
with:
name: stryker-plan
path: stryker-plan.json
if-no-files-found: ignore
mutation:
name: mutation · shard ${{ matrix.shard }}
needs: [plan]
if: needs.plan.outputs.has-shards == 'true'
runs-on: ubuntu-latest
timeout-minutes: 75
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.plan.outputs.matrix) }}
env:
CI: "true"
steps:
- uses: actions/checkout@v7
with:
persist-credentials: false
- uses: ./.github/actions/dev-shell
- name: Download the shard plan
uses: actions/download-artifact@v8
with:
name: stryker-plan
path: .
- name: Stryker incremental cache
uses: actions/cache@v6
with:
path: |
packages/*/reports/stryker-incremental.json
reports/shards/**/stryker-incremental.json
key: stryker-shard-${{ matrix.shard }}-${{ github.sha }}
restore-keys: stryker-shard-${{ matrix.shard }}-
- name: Select the shard's projects
uses: ./.github/actions/sandbox
env:
MUTATION_SHARD: ${{ matrix.shard }}
with:
hosts: |
jsr.io
registry.npmjs.org
pass-env: |
MUTATION_SHARD
command: >-
mkdir -p .cache &&
deno run --config=scripts/deno.json --allow-read --allow-write
scripts/stryker-plan-gate.ts shard --plan stryker-plan.json --shard "$MUTATION_SHARD"
--out .cache/shard-projects.tsv
- name: Mutation at break 100
uses: ./.github/actions/sandbox
env:
MUTATION_SHARD: ${{ matrix.shard }}
with:
pass-env: |
GITHUB_ACTIONS
MUTATION_SHARD
command: .github/scripts/run-shard.sh stryker-plan.json "$MUTATION_SHARD" .cache/shard-projects.tsv
- if: always()
uses: actions/upload-artifact@v7
with:
name: mutation-shard-${{ strategy.job-index }}
path: reports/shards/
if-no-files-found: ignore
- if: always()
uses: actions/upload-artifact@v7
with:
name: mutation-report-shard-${{ strategy.job-index }}
path: packages/*/reports/mutation-report.*
if-no-files-found: ignore
verdict:
name: verdict · merged report
needs: [plan, mutation]
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Refuse a plan or a shard that did not finish
env:
PLAN: ${{ needs.plan.result }}
MUTATION: ${{ needs.mutation.result }}
HAS_SHARDS: ${{ needs.plan.outputs.has-shards }}
run: |
if [ "$PLAN" != success ]; then echo "::error::the plan job ended $PLAN"; exit 1; fi
if [ "$HAS_SHARDS" != true ]; then echo "the plan scheduled no shards"; exit 0; fi
if [ "$MUTATION" != success ]; then echo "::error::a mutation shard ended $MUTATION"; exit 1; fi
- if: needs.plan.outputs.has-shards == 'true'
uses: actions/checkout@v7
with:
persist-credentials: false
- if: needs.plan.outputs.has-shards == 'true'
uses: ./.github/actions/dev-shell
- name: Download the shard plan
if: needs.plan.outputs.has-shards == 'true'
uses: actions/download-artifact@v8
with:
name: stryker-plan
path: .
- name: Download every shard's reports
if: needs.plan.outputs.has-shards == 'true'
uses: actions/download-artifact@v8
with:
pattern: mutation-shard-*
path: .cache/shard-reports
merge-multiple: true
- name: Merge the shard reports and gate them at zero survivors
if: needs.plan.outputs.has-shards == 'true'
uses: ./.github/actions/sandbox
with:
command: |
set -euo pipefail
printf '{"schemaVersion":1,"survivors":[]}\n' > .cache/no-survivors.json
jq -r '.shards[] | ".cache/shard-reports/\(.index)"' stryker-plan.json > .cache/shard-dirs.txt
mapfile -t shard_dirs < .cache/shard-dirs.txt
./node_modules/.bin/stryker merge --plan stryker-plan.json --out reports/mutation "${shard_dirs[@]}"
./node_modules/.bin/stryker gate --baseline .cache/no-survivors.json
- if: always() && needs.plan.outputs.has-shards == 'true'
uses: actions/upload-artifact@v7
with:
name: mutation-report
path: reports/mutation/
if-no-files-found: ignore