-
Notifications
You must be signed in to change notification settings - Fork 8
275 lines (246 loc) · 9.7 KB
/
Copy pathruby.yml
File metadata and controls
275 lines (246 loc) · 9.7 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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
name: Build and test rspec-trunk-flaky-tests
on:
push:
branches:
- main
tags:
- "*"
pull_request: {}
workflow_dispatch: {}
permissions:
id-token: write
contents: read
jobs:
# Trunk decides which jobs this PR needs. Fails open: no verdict means no
# output, so every gate below tests `!= 'false'`. Gating is scoped to
# pull_request -- push (main), tags and dispatch run everything outright.
dynamic-ci-filter:
name: Dynamic CI Filter
runs-on: ubuntu-latest
timeout-minutes: 5
if: github.event_name == 'pull_request'
# Per-job outputs are set at runtime, so they are re-exported here by name.
outputs:
build: ${{ steps.ci-filter.outputs.build }}
build-ruby-gem: ${{ steps.ci-filter.outputs.build-ruby-gem }}
test-ruby-gem-uploads: ${{ steps.ci-filter.outputs.test-ruby-gem-uploads }}
steps:
- name: Run Dynamic CI Filter
id: ci-filter
uses: trunk-io/dynamic-ci@v1
with:
# Prod, not staging: this repo's merge queue lives in prod.
token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }}
build:
runs-on: ubuntu-latest
needs: [dynamic-ci-filter]
if: >-
!cancelled() &&
(github.event_name != 'pull_request' ||
needs.dynamic-ci-filter.outputs.build != 'false')
steps:
- uses: actions/checkout@v4
- name: Setup Rust & Cargo
uses: ./.github/actions/setup_rust_cargo
- name: Setup Ruby
uses: ./.github/actions/setup_ruby
- name: Build CLI
run: cargo build -p trunk-analytics-cli
- name: Test ruby package
if: "!cancelled()"
run: |
bundle install
bundle exec rake test
working-directory: rspec-trunk-flaky-tests
env:
TRUNK_LOCAL_UPLOAD_DIR: ../upload_bundle
- name: Upload ruby package results → analytics-cli-ruby-gem (staging)
if: "!cancelled()"
run: |
./target/debug/trunk-analytics-cli upload \
--org-url-slug trunk-staging-org \
--token ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }} \
--test-reports ./upload_bundle/trunk_output.bin \
--test-collection-id T5yKSn9h
env:
TRUNK_PUBLIC_API_ADDRESS: https://api.trunk-staging.io
- name: Upload ruby package results → analytics-cli-ruby-gem (prod)
if: "!cancelled()"
run: |
./target/debug/trunk-analytics-cli upload \
--org-url-slug trunk \
--token ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }} \
--test-reports ./upload_bundle/trunk_output.bin \
--test-collection-id BiBP2neA
env:
TRUNK_PUBLIC_API_ADDRESS: https://api.trunk.io
- name: Upload ruby package results → analytics-cli-smoke-tests (staging)
if: "!cancelled()"
run: |
./target/debug/trunk-analytics-cli upload \
--org-url-slug trunk-staging-org \
--token ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }} \
--test-reports ./upload_bundle/trunk_output.bin \
--test-collection-id z2dzjLHm
env:
TRUNK_PUBLIC_API_ADDRESS: https://api.trunk-staging.io
- name: Upload ruby package results → analytics-cli-smoke-tests (prod)
if: "!cancelled()"
run: |
./target/debug/trunk-analytics-cli upload \
--org-url-slug trunk \
--token ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }} \
--test-reports ./upload_bundle/trunk_output.bin \
--test-collection-id 4B2wfoEU
env:
TRUNK_PUBLIC_API_ADDRESS: https://api.trunk.io
- name: Validate ruby platform gem
if: "!cancelled()"
uses: ./.github/actions/validate_ruby_platform_gem
build-ruby-gem:
name: Build Ruby gem
runs-on: ubuntu-latest
needs: [dynamic-ci-filter]
# Also runs when `test-ruby-gem-uploads` is wanted: it consumes this gem.
if: >-
!cancelled() &&
(github.event_name != 'pull_request' ||
needs.dynamic-ci-filter.outputs.build-ruby-gem != 'false' ||
needs.dynamic-ci-filter.outputs.test-ruby-gem-uploads != 'false')
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true
working-directory: rspec-trunk-flaky-tests
- name: Get commit SHA
id: get-sha
shell: bash
run: |
COMMIT_SHA=$(git rev-parse --short HEAD)
echo "sha=${COMMIT_SHA}" >> $GITHUB_OUTPUT
echo "Setting version to 0.0.0-${COMMIT_SHA}"
- name: Update version with commit SHA
uses: ./.github/actions/update_version
with:
version: 0.0.0-${{ steps.get-sha.outputs.sha }}
file: cli/Cargo.toml
- name: Update Test Report version
uses: ./.github/actions/update_version
with:
version: 0.0.0-${{ steps.get-sha.outputs.sha }}
file: test_report/Cargo.toml
- name: Update Gem version
uses: ./.github/actions/update_version
with:
version: 0.0.0-${{ steps.get-sha.outputs.sha }}
file: rspec-trunk-flaky-tests/rspec_trunk_flaky_tests.gemspec
# this is necessary because the cross-gem action doesn't support reading the Gemfile.lock from the subdirectory
# leading to a mismatch in the rb_sys version
- name: Copy Gemfile.lock to root
run: cp rspec-trunk-flaky-tests/Gemfile.lock ./Gemfile.lock
shell: bash
- name: Build cross-compiled gem
uses: oxidize-rb/actions/cross-gem@v1
with:
platform: x86_64-linux
working-directory: rspec-trunk-flaky-tests
ruby-versions: "3.4"
- name: Upload gem artifact
uses: actions/upload-artifact@v4
with:
name: ruby-gem-pr
path: rspec-trunk-flaky-tests/pkg/*.gem
if-no-files-found: error
retention-days: 1
test-ruby-gem-uploads:
name: Test Ruby gem uploads
runs-on: ubuntu-latest
needs: [build-ruby-gem, dynamic-ci-filter]
if: >-
!cancelled() &&
needs.build-ruby-gem.result == 'success' &&
(github.event_name != 'pull_request' ||
needs.dynamic-ci-filter.outputs.test-ruby-gem-uploads != 'false')
steps:
- uses: actions/checkout@v4
- name: Download gem artifact
uses: actions/download-artifact@v4
with:
name: ruby-gem-pr
path: .github/actions/test_ruby_gem_uploads/
- name: Test ruby gem uploads → analytics-cli-ruby-gem (staging)
uses: ./.github/actions/test_ruby_gem_uploads
with:
ruby-version: "3.4"
trunk-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }}
trunk-public-api-address: https://api.trunk-staging.io
trunk-org-slug: trunk-staging-org
test-collection-id: T5yKSn9h
platform: x86_64-linux
artifact-pattern: ""
knapsack-pro-test-suite-token-rspec: ${{ secrets.KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC }}
- name: Test ruby gem uploads → analytics-cli-ruby-gem (prod)
uses: ./.github/actions/test_ruby_gem_uploads
with:
ruby-version: "3.4"
trunk-token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }}
trunk-public-api-address: https://api.trunk.io
trunk-org-slug: trunk
test-collection-id: BiBP2neA
platform: x86_64-linux
artifact-pattern: ""
knapsack-pro-test-suite-token-rspec: ${{ secrets.KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC }}
- name: Test ruby gem uploads → analytics-cli-smoke-tests (staging)
uses: ./.github/actions/test_ruby_gem_uploads
with:
ruby-version: "3.4"
trunk-token: ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }}
trunk-public-api-address: https://api.trunk-staging.io
trunk-org-slug: trunk-staging-org
test-collection-id: z2dzjLHm
platform: x86_64-linux
artifact-pattern: ""
knapsack-pro-test-suite-token-rspec: ${{ secrets.KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC }}
- name: Test ruby gem uploads → analytics-cli-smoke-tests (prod)
uses: ./.github/actions/test_ruby_gem_uploads
with:
ruby-version: "3.4"
trunk-token: ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }}
trunk-public-api-address: https://api.trunk.io
trunk-org-slug: trunk
test-collection-id: 4B2wfoEU
platform: x86_64-linux
artifact-pattern: ""
knapsack-pro-test-suite-token-rspec: ${{ secrets.KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC }}
gate:
name: rspec Gate
runs-on: ubuntu-latest
timeout-minutes: 5
# Branch-protection fan-in: one stable required context for this whole workflow.
# A matrix job skipped by its job-level `if:` reports a single check run under the
# *unexpanded* name (`Test for ${{ matrix.platform.target }}`) because the matrix is
# never evaluated -- so per-leg contexts never report and required checks hang on
# "Expected". This job always runs, so its name always reports.
# build-ruby-gem / test-ruby-gem-uploads are omitted: not required checks today.
if: always()
needs: [build]
steps:
- name: Check fan-in results
env:
RESULTS: ${{ join(needs.*.result, ' ') }}
shell: bash
run: |
read -ra results <<<"${RESULTS}"
for result in "${results[@]}"; do
case "${result}" in
# A skipped job is a pass: it was deliberately not run for this change.
success | skipped) ;;
*)
echo "::error::a needed job reported '${result}'"
exit 1
;;
esac
done
echo "needed jobs all passed or were skipped: ${RESULTS}"