-
Notifications
You must be signed in to change notification settings - Fork 6
271 lines (223 loc) · 8.93 KB
/
pull_request.yml
File metadata and controls
271 lines (223 loc) · 8.93 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
name: Pull Request
run-name: Pull Request for ${{ github.ref_name }} by ${{ github.actor }}
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions: write-all
on:
pull_request: {}
workflow_dispatch: {}
push:
branches:
- main
env:
CARGO_TERM_COLOR: always
jobs:
build_release:
name: Build CLI for ${{ matrix.platform.target }}
strategy:
matrix:
platform:
- os-name: linux-x86_64
runs-on: ubuntu-latest
target: x86_64-unknown-linux-musl
- os-name: linux-aarch64
runs-on: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
- os-name: x86_64-darwin
runs-on: macos-latest
target: x86_64-apple-darwin
- os-name: aarch64-darwin
runs-on: macos-latest
target: aarch64-apple-darwin
- os-name: windows-x86_64
runs-on: public-amd64-4xlarge-dind-germany
target: x86_64-pc-windows-gnu
runs-on: ${{ matrix.platform.runs-on }}
steps:
# we've been hitting out of free space issues
- name: Delete unnecessary tools folder
run: rm -rf /opt/hostedtoolcache
- name: Install build tools (Windows and Linux build)
shell: bash
if: ${{ !contains(matrix.platform.os-name, 'darwin') }}
run: |
sudo bash -c 'cat << EOF > /etc/apt/sources.list
deb http://mirror.hetzner.com/ubuntu/packages jammy main restricted universe multiverse
deb http://mirror.hetzner.com/ubuntu/packages jammy-updates main restricted universe multiverse
deb http://mirror.hetzner.com/ubuntu/packages jammy-backports main restricted universe multiverse
deb http://mirror.hetzner.com/ubuntu/packages jammy-security main restricted universe multiverse
EOF'
sudo apt-get update
sudo apt-get install -y git-lfs build-essential
git lfs install
- name: Checkout
uses: actions/checkout@v4
with:
lfs: "true"
- name: Setup Rust & Cargo
uses: ./.github/actions/setup_rust_cargo
- name: Build darwin target
uses: ./.github/actions/build_cli_macos_target
if: contains(matrix.platform.os-name, 'darwin')
with:
target: ${{ matrix.platform.target }}
profile: release
force-sentry-dev: true
- name: Build unix/Windows target
uses: ./.github/actions/build_cli_linux_windows_target
if: ${{ !contains(matrix.platform.os-name, 'darwin') }}
with:
target: ${{ matrix.platform.target }}
profile: release
force-sentry-dev: true
- name: Upload built binary
uses: actions/upload-artifact@v4
if: always()
with:
name: binary-${{ matrix.platform.target }}
path: target/${{ matrix.platform.target }}/release/trunk-analytics-cli*
retention-days: 1
test:
name: Test for ${{ matrix.platform.target }}
needs: [build_release]
strategy:
matrix:
platform:
- os-name: linux-x86_64
runs-on: ubuntu-latest
target: x86_64-unknown-linux-musl
- os-name: linux-aarch64
runs-on: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
- os-name: x86_64-darwin
runs-on: macos-latest
target: x86_64-apple-darwin
- os-name: aarch64-darwin
runs-on: macos-latest
target: aarch64-apple-darwin
- os-name: windows-x86_64
runs-on: public-amd64-4xlarge-dind-germany
target: x86_64-pc-windows-gnu
runs-on: ${{ matrix.platform.runs-on }}
steps:
# we've been hitting out of free space issues
- name: Delete unnecessary tools folder
run: rm -rf /opt/hostedtoolcache
- name: Install build tools (Windows and Linux build)
shell: bash
if: ${{ !contains(matrix.platform.os-name, 'darwin') }}
run: |
sudo bash -c 'cat << EOF > /etc/apt/sources.list
deb http://mirror.hetzner.com/ubuntu/packages jammy main restricted universe multiverse
deb http://mirror.hetzner.com/ubuntu/packages jammy-updates main restricted universe multiverse
deb http://mirror.hetzner.com/ubuntu/packages jammy-backports main restricted universe multiverse
deb http://mirror.hetzner.com/ubuntu/packages jammy-security main restricted universe multiverse
EOF'
sudo apt-get update
sudo apt-get install -y git-lfs build-essential
git lfs install
- name: Checkout
uses: actions/checkout@v4
with:
lfs: "true"
- name: Setup Rust & Cargo
uses: ./.github/actions/setup_rust_cargo
# This is a canary test to ensure that the github actions crate is working
# as expected in a real environment. If this fails, we should investigate
# why the github actions crate is not working as expected. This test relies
# on the github actions crate to be able to extract the job ID from the logs,
# which is an undocumented feature that can break at any moment.
- name: canary - Test github actions crate
shell: bash
run: |
cargo run --bin github-actions -- -v
if [[ "$?" -ne 0 ]]; then
echo "Failed to run github-actions crate"
exit 1
fi
- name: Run tests
uses: ./.github/actions/run_tests
id: tests
continue-on-error: true
with:
target: ${{ matrix.platform.target }}
codecov-token: ${{ secrets.CODECOV_TOKEN }}
- name: Download built binary
uses: actions/download-artifact@v4
with:
name: binary-${{ matrix.platform.target }}
path: target/${{ matrix.platform.target }}/release/
- name: Make binary executable
shell: bash
if: ${{ !contains(matrix.platform.os-name, 'windows') }}
run: chmod +x target/${{ matrix.platform.target }}/release/trunk-analytics-cli
- name: Extract step outcome
shell: bash
id: extract
run: |
if [[ "${{steps.tests.outcome}}" == "failure" ]]; then
echo "test-step-outcome=1" >> $GITHUB_OUTPUT
else
echo "test-step-outcome=0" >> $GITHUB_OUTPUT
fi
- name: Upload results to staging using built CLI
env:
TRUNK_PUBLIC_API_ADDRESS: https://api.trunk-staging.io
shell: bash
# Skip Windows builds - can't run Windows binaries on Linux runners
# Windows binaries are tested in the release workflow on actual Windows runners
if: ${{ !contains(matrix.platform.target, 'illumos') && !contains(matrix.platform.os-name, 'windows') }}
run: |
target/${{ matrix.platform.target }}/release/trunk-analytics-cli upload \
--junit-paths ${{ github.workspace }}/target/**/*junit.xml \
--org-url-slug trunk-staging-org \
--token ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }} \
--test-process-exit-code ${{ steps.extract.outputs.test-step-outcome }}
- name: Upload results to prod using built CLI
shell: bash
# Skip Windows builds - can't run Windows binaries on Linux runners
# Windows binaries are tested in the release workflow on actual Windows runners
if: ${{ !contains(matrix.platform.target, 'illumos') && !contains(matrix.platform.os-name, 'windows') }}
run: |
target/${{ matrix.platform.target }}/release/trunk-analytics-cli upload \
--junit-paths ${{ github.workspace }}/target/**/*junit.xml \
--org-url-slug trunk \
--token ${{ secrets.TRUNK_PROD_ORG_API_TOKEN }}
trunk_check_runner:
name: Trunk Check runner [linux]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Delete huge unnecessary tools folder
run: rm -rf /opt/hostedtoolcache
- name: Setup Rust & Cargo
uses: ./.github/actions/setup_rust_cargo
- name: Setup Ruby
uses: ./.github/actions/setup_ruby
- name: Build workspace
run: cargo build --all
- name: Setup and build wasm
uses: ./.github/actions/setup_build_wasm
- name: Trunk Check
uses: trunk-io/trunk-action@v1
with:
cache: false
build_pyo3:
name: Build context-py
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Delete huge unnecessary tools folder
run: rm -rf /opt/hostedtoolcache
- name: Setup and build pyo3
uses: ./.github/actions/setup_build_pyo3
build_wasm:
name: Build context-js (WASM)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Delete huge unnecessary tools folder
run: rm -rf /opt/hostedtoolcache
- name: Setup and build wasm
uses: ./.github/actions/setup_build_wasm