Skip to content

Commit 46c4fa0

Browse files
committed
simplify
1 parent a0a3af5 commit 46c4fa0

File tree

1 file changed

+38
-115
lines changed

1 file changed

+38
-115
lines changed

.github/workflows/pull_request.yml

Lines changed: 38 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ env:
1818
CARGO_TERM_COLOR: always
1919

2020
jobs:
21-
test:
22-
name: Test for ${{ matrix.platform.target }}
21+
build_release:
22+
name: Build CLI for ${{ matrix.platform.target }}
2323
strategy:
2424
matrix:
2525
platform:
@@ -68,67 +68,36 @@ jobs:
6868
with:
6969
lfs: "true"
7070

71-
- name: Setup Xcode 16
72-
if: contains(matrix.platform.os-name, 'darwin')
73-
uses: maxim-lobanov/setup-xcode@v1
74-
with:
75-
xcode-version: 16
76-
7771
- name: Setup Rust & Cargo
7872
uses: ./.github/actions/setup_rust_cargo
7973

80-
# This is a canary test to ensure that the github actions crate is working
81-
# as expected in a real environment. If this fails, we should investigate
82-
# why the github actions crate is not working as expected. This test relies
83-
# on the github actions crate to be able to extract the job ID from the logs,
84-
# which is an undocumented feature that can break at any moment.
85-
- name: canary - Test github actions crate
86-
shell: bash
87-
run: |
88-
cargo run --bin github-actions -- -v
89-
if [[ "$?" -ne 0 ]]; then
90-
echo "Failed to run github-actions crate"
91-
exit 1
92-
fi
93-
94-
- name: Run tests
95-
uses: ./.github/actions/run_tests
96-
id: tests
97-
continue-on-error: true
74+
- name: Build darwin target
75+
uses: ./.github/actions/build_cli_macos_target
76+
if: contains(matrix.platform.os-name, 'darwin')
9877
with:
9978
target: ${{ matrix.platform.target }}
100-
codecov-token: ${{ secrets.CODECOV_TOKEN }}
101-
102-
- name: Extract step outcome
103-
shell: bash
104-
id: extract
105-
run: |
106-
if [[ "${{steps.tests.outcome}}" == "failure" ]]; then
107-
echo "test-step-outcome=1" >> $GITHUB_OUTPUT
108-
echo "1" > test-outcome.txt
109-
else
110-
echo "test-step-outcome=0" >> $GITHUB_OUTPUT
111-
echo "0" > test-outcome.txt
112-
fi
79+
profile: release
80+
force-sentry-dev: true
11381

114-
- name: Upload test outcome
115-
uses: actions/upload-artifact@v4
116-
if: always()
82+
- name: Build unix/Windows target
83+
uses: ./.github/actions/build_cli_linux_windows_target
84+
if: ${{ !contains(matrix.platform.os-name, 'darwin') }}
11785
with:
118-
name: test-outcome-${{ matrix.platform.target }}
119-
path: test-outcome.txt
120-
retention-days: 1
86+
target: ${{ matrix.platform.target }}
87+
profile: release
88+
force-sentry-dev: true
12189

122-
- name: Upload junit files
90+
- name: Upload built binary
12391
uses: actions/upload-artifact@v4
12492
if: always()
12593
with:
126-
name: junit-${{ matrix.platform.target }}
127-
path: target/**/*junit.xml
94+
name: binary-${{ matrix.platform.target }}
95+
path: target/${{ matrix.platform.target }}/release/trunk-analytics-cli*
12896
retention-days: 1
12997

130-
build_release:
131-
name: Build CLI for ${{ matrix.platform.target }}
98+
test:
99+
name: Test for ${{ matrix.platform.target }}
100+
needs: [build_release]
132101
strategy:
133102
matrix:
134103
platform:
@@ -186,72 +155,27 @@ jobs:
186155
- name: Setup Rust & Cargo
187156
uses: ./.github/actions/setup_rust_cargo
188157

189-
- name: Build darwin target
190-
uses: ./.github/actions/build_cli_macos_target
191-
if: contains(matrix.platform.os-name, 'darwin')
192-
with:
193-
target: ${{ matrix.platform.target }}
194-
profile: release
195-
force-sentry-dev: true
158+
# This is a canary test to ensure that the github actions crate is working
159+
# as expected in a real environment. If this fails, we should investigate
160+
# why the github actions crate is not working as expected. This test relies
161+
# on the github actions crate to be able to extract the job ID from the logs,
162+
# which is an undocumented feature that can break at any moment.
163+
- name: canary - Test github actions crate
164+
shell: bash
165+
run: |
166+
cargo run --bin github-actions -- -v
167+
if [[ "$?" -ne 0 ]]; then
168+
echo "Failed to run github-actions crate"
169+
exit 1
170+
fi
196171
197-
- name: Build unix/Windows target
198-
uses: ./.github/actions/build_cli_linux_windows_target
199-
if: ${{ !contains(matrix.platform.os-name, 'darwin') }}
172+
- name: Run tests
173+
uses: ./.github/actions/run_tests
174+
id: tests
175+
continue-on-error: true
200176
with:
201177
target: ${{ matrix.platform.target }}
202-
profile: release
203-
force-sentry-dev: true
204-
205-
- name: Upload built binary
206-
uses: actions/upload-artifact@v4
207-
if: always()
208-
with:
209-
name: binary-${{ matrix.platform.target }}
210-
path: target/${{ matrix.platform.target }}/release/trunk-analytics-cli*
211-
retention-days: 1
212-
213-
upload_results:
214-
name: Upload results for ${{ matrix.platform.target }}
215-
needs: [test, build_release]
216-
strategy:
217-
matrix:
218-
platform:
219-
- os-name: linux-x86_64
220-
runs-on: ubuntu-latest
221-
target: x86_64-unknown-linux-musl
222-
223-
- os-name: linux-aarch64
224-
runs-on: ubuntu-24.04-arm
225-
target: aarch64-unknown-linux-musl
226-
227-
- os-name: x86_64-darwin
228-
runs-on: macos-latest
229-
target: x86_64-apple-darwin
230-
231-
- os-name: aarch64-darwin
232-
runs-on: macos-latest
233-
target: aarch64-apple-darwin
234-
235-
- os-name: windows-x86_64
236-
runs-on: public-amd64-4xlarge-dind-germany
237-
target: x86_64-pc-windows-gnu
238-
239-
runs-on: ${{ matrix.platform.runs-on }}
240-
steps:
241-
- name: Checkout
242-
uses: actions/checkout@v4
243-
244-
- name: Download test outcome
245-
uses: actions/download-artifact@v4
246-
with:
247-
name: test-outcome-${{ matrix.platform.target }}
248-
path: ./
249-
250-
- name: Download junit files
251-
uses: actions/download-artifact@v4
252-
with:
253-
name: junit-${{ matrix.platform.target }}
254-
path: target/
178+
codecov-token: ${{ secrets.CODECOV_TOKEN }}
255179

256180
- name: Download built binary
257181
uses: actions/download-artifact@v4
@@ -272,12 +196,11 @@ jobs:
272196
# Windows binaries are tested in the release workflow on actual Windows runners
273197
if: ${{ !contains(matrix.platform.target, 'illumos') && !contains(matrix.platform.os-name, 'windows') }}
274198
run: |
275-
TEST_OUTCOME=$(cat test-outcome.txt)
276199
target/${{ matrix.platform.target }}/release/trunk-analytics-cli upload \
277200
--junit-paths ${{ github.workspace }}/target/**/*junit.xml \
278201
--org-url-slug trunk-staging-org \
279202
--token ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }} \
280-
--test-process-exit-code $TEST_OUTCOME
203+
--test-process-exit-code ${{ steps.tests.outcome }}
281204
282205
- name: Upload results to prod using built CLI
283206
shell: bash

0 commit comments

Comments
 (0)