Skip to content

Commit 0c3a109

Browse files
committed
faster builds
1 parent b8b43f0 commit 0c3a109

1 file changed

Lines changed: 36 additions & 20 deletions

File tree

.github/workflows/examples.yml

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,34 @@ jobs:
3535
exit 1
3636
fi
3737
38-
run-example:
38+
# Build `hm` once and share the binary across every matrix leg.
39+
# Each leg only needs Python + Docker + the binary; making them
40+
# re-compile the whole workspace 17× was the long tent-pole.
41+
build-hm:
3942
needs: validate-matrix
43+
runs-on: ubuntu-latest
44+
timeout-minutes: 20
45+
steps:
46+
- uses: actions/checkout@v4
47+
48+
- uses: dtolnay/rust-toolchain@stable
49+
50+
- uses: Swatinem/rust-cache@v2
51+
with:
52+
shared-key: examples-hm
53+
54+
- name: Build hm
55+
run: cargo build --release -p harmont-cli
56+
57+
- uses: actions/upload-artifact@v4
58+
with:
59+
name: hm-bin
60+
path: target/release/hm
61+
retention-days: 1
62+
if-no-files-found: error
63+
64+
run-example:
65+
needs: build-hm
4066
name: ${{ matrix.example }}
4167
runs-on: ubuntu-latest
4268
timeout-minutes: 20
@@ -64,22 +90,6 @@ jobs:
6490
steps:
6591
- uses: actions/checkout@v4
6692

67-
- name: Install system build deps
68-
# libdbus-1-dev is required by the `keyring` crate's
69-
# sync-secret-service feature; the GH-hosted Ubuntu runner
70-
# doesn't ship the headers by default.
71-
run: |
72-
sudo apt-get update
73-
sudo apt-get install -y --no-install-recommends libdbus-1-dev pkg-config
74-
75-
- uses: dtolnay/rust-toolchain@stable
76-
77-
- uses: Swatinem/rust-cache@v2
78-
with:
79-
# All matrix legs share the same hm binary; one cache key for the
80-
# whole workflow is sufficient.
81-
shared-key: examples-hm
82-
8393
- uses: actions/setup-python@v5
8494
with:
8595
python-version: '3.11'
@@ -89,8 +99,14 @@ jobs:
8999
git clone --depth 1 https://github.com/harmont-dev/harmont-py /tmp/harmont-py
90100
pip install /tmp/harmont-py
91101
92-
- name: Build hm
93-
run: cargo build --release -p harmont-cli
102+
- name: Download hm binary
103+
uses: actions/download-artifact@v4
104+
with:
105+
name: hm-bin
106+
path: bin
107+
108+
- name: Mark hm executable
109+
run: chmod +x bin/hm
94110

95111
- name: Run example via hm run
96112
working-directory: examples/${{ matrix.example }}
@@ -99,4 +115,4 @@ jobs:
99115
# pipeline; the system Python on the runner is what setup-python
100116
# just installed.
101117
HM_NONINTERACTIVE: '1'
102-
run: ../../target/release/hm run ci
118+
run: ${{ github.workspace }}/bin/hm run ci

0 commit comments

Comments
 (0)