Skip to content

Commit 749f8d9

Browse files
committed
init
1 parent 8b20e46 commit 749f8d9

File tree

3 files changed

+149
-52
lines changed

3 files changed

+149
-52
lines changed

.github/actions/setup_rust_cargo/action.yaml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,5 @@ runs:
1414
with:
1515
targets: wasm32-unknown-unknown
1616

17-
- uses: actions/cache@v4
18-
with:
19-
path: |
20-
~/.cargo/bin/
21-
~/.cargo/registry/index/
22-
~/.cargo/registry/cache/
23-
~/.cargo/git/db/
24-
target/
25-
key: ${{ runner.arch }}-${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
17+
- name: Cache Rust dependencies
18+
uses: Swatinem/rust-cache@v2

.github/workflows/pull_request.yml

Lines changed: 113 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,83 @@ jobs:
6868
with:
6969
lfs: "true"
7070

71-
- name: Setup Xcode 16
71+
- name: Setup Rust & Cargo
72+
uses: ./.github/actions/setup_rust_cargo
73+
74+
- name: Build darwin target
75+
uses: ./.github/actions/build_cli_macos_target
7276
if: contains(matrix.platform.os-name, 'darwin')
73-
uses: maxim-lobanov/setup-xcode@v1
7477
with:
75-
xcode-version: 16
78+
target: ${{ matrix.platform.target }}
79+
profile: release
80+
force-sentry-dev: true
81+
82+
- name: Build unix/Windows target
83+
uses: ./.github/actions/build_cli_linux_windows_target
84+
if: ${{ !contains(matrix.platform.os-name, 'darwin') }}
85+
with:
86+
target: ${{ matrix.platform.target }}
87+
profile: release
88+
force-sentry-dev: true
89+
90+
- name: Upload built binary
91+
uses: actions/upload-artifact@v4
92+
if: always()
93+
with:
94+
name: binary-${{ matrix.platform.target }}
95+
path: target/${{ matrix.platform.target }}/release/trunk-analytics-cli*
96+
retention-days: 1
97+
98+
test:
99+
name: Test for ${{ matrix.platform.target }}
100+
needs: [build_release]
101+
strategy:
102+
matrix:
103+
platform:
104+
- os-name: linux-x86_64
105+
runs-on: ubuntu-latest
106+
target: x86_64-unknown-linux-musl
107+
108+
- os-name: linux-aarch64
109+
runs-on: ubuntu-24.04-arm
110+
target: aarch64-unknown-linux-musl
111+
112+
- os-name: x86_64-darwin
113+
runs-on: macos-latest
114+
target: x86_64-apple-darwin
115+
116+
- os-name: aarch64-darwin
117+
runs-on: macos-latest
118+
target: aarch64-apple-darwin
119+
120+
- os-name: windows-x86_64
121+
runs-on: public-amd64-4xlarge-dind-germany
122+
target: x86_64-pc-windows-gnu
123+
124+
runs-on: ${{ matrix.platform.runs-on }}
125+
steps:
126+
# we've been hitting out of free space issues
127+
- name: Delete unnecessary tools folder
128+
run: rm -rf /opt/hostedtoolcache
129+
130+
- name: Install build tools (Windows and Linux build)
131+
shell: bash
132+
if: ${{ !contains(matrix.platform.os-name, 'darwin') }}
133+
run: |
134+
sudo bash -c 'cat << EOF > /etc/apt/sources.list
135+
deb http://mirror.hetzner.com/ubuntu/packages jammy main restricted universe multiverse
136+
deb http://mirror.hetzner.com/ubuntu/packages jammy-updates main restricted universe multiverse
137+
deb http://mirror.hetzner.com/ubuntu/packages jammy-backports main restricted universe multiverse
138+
deb http://mirror.hetzner.com/ubuntu/packages jammy-security main restricted universe multiverse
139+
EOF'
140+
sudo apt-get update
141+
sudo apt-get install -y git-lfs build-essential
142+
git lfs install
143+
144+
- name: Checkout
145+
uses: actions/checkout@v4
146+
with:
147+
lfs: "true"
76148

77149
- name: Setup Rust & Cargo
78150
uses: ./.github/actions/setup_rust_cargo
@@ -99,31 +171,16 @@ jobs:
99171
target: ${{ matrix.platform.target }}
100172
codecov-token: ${{ secrets.CODECOV_TOKEN }}
101173

102-
- name: Build darwin target
103-
uses: ./.github/actions/build_cli_macos_target
104-
if: contains(matrix.platform.os-name, 'darwin')
105-
with:
106-
target: ${{ matrix.platform.target }}
107-
profile: release
108-
force-sentry-dev: true
109-
110-
- name: Build unix/Windows target
111-
uses: ./.github/actions/build_cli_linux_windows_target
112-
if: ${{ !contains(matrix.platform.os-name, 'darwin') }}
174+
- name: Download built binary
175+
uses: actions/download-artifact@v4
113176
with:
114-
target: ${{ matrix.platform.target }}
115-
profile: release
116-
force-sentry-dev: true
177+
name: binary-${{ matrix.platform.target }}
178+
path: target/${{ matrix.platform.target }}/release/
117179

118-
- name: Extract step outcome
180+
- name: Make binary executable
119181
shell: bash
120-
id: extract
121-
run: |
122-
if [[ "${{steps.tests.outcome}}" == "failure" ]]; then
123-
echo "test-step-outcome=1" >> $GITHUB_OUTPUT
124-
else
125-
echo "test-step-outcome=0" >> $GITHUB_OUTPUT
126-
fi
182+
if: ${{ !contains(matrix.platform.os-name, 'windows') }}
183+
run: chmod +x target/${{ matrix.platform.target }}/release/trunk-analytics-cli
127184

128185
- name: Upload results to staging using built CLI
129186
env:
@@ -133,11 +190,16 @@ jobs:
133190
# Windows binaries are tested in the release workflow on actual Windows runners
134191
if: ${{ !contains(matrix.platform.target, 'illumos') && !contains(matrix.platform.os-name, 'windows') }}
135192
run: |
193+
if [[ "${{steps.tests.outcome}}" == "failure" ]]; then
194+
test-step-outcome=1
195+
else
196+
test-step-outcome=0
197+
fi
136198
target/${{ matrix.platform.target }}/release/trunk-analytics-cli upload \
137199
--junit-paths ${{ github.workspace }}/target/**/*junit.xml \
138200
--org-url-slug trunk-staging-org \
139201
--token ${{ secrets.TRUNK_STAGING_ORG_API_TOKEN }} \
140-
--test-process-exit-code ${{ steps.extract.outputs.test-step-outcome }}
202+
--test-process-exit-code $test-step-outcome
141203
142204
- name: Upload results to prod using built CLI
143205
shell: bash
@@ -169,13 +231,33 @@ jobs:
169231
- name: Build workspace
170232
run: cargo build --all
171233

234+
- name: Trunk Check
235+
uses: trunk-io/trunk-action@v1
236+
with:
237+
cache: false
238+
239+
build_pyo3:
240+
name: Build context-py
241+
runs-on: ubuntu-latest
242+
243+
steps:
244+
- uses: actions/checkout@v4
245+
246+
- name: Delete huge unnecessary tools folder
247+
run: rm -rf /opt/hostedtoolcache
248+
172249
- name: Setup and build pyo3
173250
uses: ./.github/actions/setup_build_pyo3
174251

252+
build_wasm:
253+
name: Build context-js (WASM)
254+
runs-on: ubuntu-latest
255+
256+
steps:
257+
- uses: actions/checkout@v4
258+
259+
- name: Delete huge unnecessary tools folder
260+
run: rm -rf /opt/hostedtoolcache
261+
175262
- name: Setup and build wasm
176263
uses: ./.github/actions/setup_build_wasm
177-
178-
- name: Trunk Check
179-
uses: trunk-io/trunk-action@v1
180-
with:
181-
cache: false

.github/workflows/pyo3.yml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,39 @@ jobs:
8383
with:
8484
name: wheels-linux-${{ matrix.platform.target }}
8585
path: dist
86+
87+
- name: Upload wheel package to S3
88+
uses: ./.github/actions/upload_to_s3
89+
if: "!cancelled() && github.event_name != 'pull_request'"
90+
with:
91+
bucket: ${{ secrets.S3_ASSET_BUCKET }}
92+
name: linux-${{ matrix.platform.target }}
93+
path: dist
94+
s3-flags: --recursive
95+
role-to-assume: ${{ secrets.S3_UPLOAD_ROLE_ARN }}
96+
date: ${{ needs.get-date-sha.outputs.date }}
97+
sha: ${{ needs.get-date-sha.outputs.sha }}
98+
99+
linux-pytest:
100+
needs: [linux]
101+
runs-on: ${{ matrix.platform.runner }}
102+
strategy:
103+
fail-fast: false
104+
matrix:
105+
platform:
106+
- runner: ubuntu-latest
107+
target: x86_64
108+
- runner: ubuntu-latest
109+
target: aarch64
110+
steps:
111+
- uses: actions/checkout@v4
112+
113+
- name: Download wheels
114+
uses: actions/download-artifact@v4
115+
with:
116+
name: wheels-linux-${{ matrix.platform.target }}
117+
path: dist
118+
86119
- name: pytest
87120
if: ${{ startsWith(matrix.platform.target, 'x86_64') }}
88121
shell: bash
@@ -95,6 +128,7 @@ jobs:
95128
uv pip install -r requirements-dev.txt
96129
uv pip install context-py --find-links ../dist --force-reinstall
97130
pytest --cov
131+
98132
- name: pytest
99133
if: ${{ startsWith(matrix.platform.target, 'aarch64') }}
100134
uses: uraimo/run-on-arch-action@v2
@@ -122,18 +156,6 @@ jobs:
122156
slug: trunk-io/analytics-cli
123157
directory: ./context-py
124158

125-
- name: Upload wheel package to S3
126-
uses: ./.github/actions/upload_to_s3
127-
if: "!cancelled() && github.event_name != 'pull_request'"
128-
with:
129-
bucket: ${{ secrets.S3_ASSET_BUCKET }}
130-
name: linux-${{ matrix.platform.target }}
131-
path: dist
132-
s3-flags: --recursive
133-
role-to-assume: ${{ secrets.S3_UPLOAD_ROLE_ARN }}
134-
date: ${{ needs.get-date-sha.outputs.date }}
135-
sha: ${{ needs.get-date-sha.outputs.sha }}
136-
137159
macos:
138160
needs: [get-date-sha]
139161
runs-on: ${{ matrix.platform.runner }}

0 commit comments

Comments
 (0)