-
Notifications
You must be signed in to change notification settings - Fork 6
129 lines (114 loc) · 3.81 KB
/
Copy pathexamples.yml
File metadata and controls
129 lines (114 loc) · 3.81 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
name: examples
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
# Cancel superseded runs on rapid pushes — 17-leg matrix is expensive.
concurrency:
group: examples-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
# Fail fast if the matrix list has drifted from examples/. Cheaper than
# waiting for 17 legs to finish and finding out a new example was added
# but never wired into CI.
validate-matrix:
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- uses: actions/checkout@v4
- name: Diff examples/ against matrix slugs
run: |
on_disk="$(ls examples | grep -v '^README\.md$' | sort)"
in_matrix="$(awk '/^ example:$/{flag=1;next}/^ steps:$/{flag=0}flag' .github/workflows/examples.yml \
| sed -n 's/^\s*- //p' | sort)"
if [ "$on_disk" != "$in_matrix" ]; then
echo "matrix list out of sync with examples/ directory" >&2
diff <(printf '%s\n' "$on_disk") <(printf '%s\n' "$in_matrix") >&2 || true
exit 1
fi
# Build `hm` once and share the binary across every matrix leg.
# Each leg only needs Python + Docker + the binary; making them
# re-compile the whole workspace 17× was the long tent-pole.
build-hm:
needs: validate-matrix
runs-on: ubuntu-latest
# Debug build only — examples just need a working `hm` binary;
# release-mode LTO/codegen on wasmtime+cranelift can't finish in
# GH's 6h cap on a 2-vCPU runner. Debug builds in ~10 minutes
# cold, ~1 minute warm.
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
# crates/hm/build.rs cross-compiles hm-plugin-docker as a wasm
# plugin embedded into the binary, so the target must be on
# the toolchain.
targets: wasm32-wasip1
- uses: Swatinem/rust-cache@v2
with:
shared-key: examples-hm
- name: Build hm
run: cargo build -p harmont-cli
- uses: actions/upload-artifact@v4
with:
name: hm-bin
path: target/debug/hm
retention-days: 1
if-no-files-found: error
run-example:
needs: build-hm
name: ${{ matrix.example }}
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
example:
- c
- cpp
- csharp
- go
- haskell
- java
- kotlin
- nextjs
- ocaml
- perl
- php-laravel
- python-uv
- react
- ruby
- rust
- typescript
- zig-js
- zig
steps:
- uses: actions/checkout@v4
# `hm run` shells out to `/usr/bin/python3` with PATH restricted
# to /usr/bin:/usr/local/bin:/bin (see render.rs), so harmont-py
# has to land in the *system* Python's site-packages — not the
# actions/setup-python hostedtoolcache. PEP 668's
# externally-managed marker requires --break-system-packages.
- name: Install harmont-py into system Python
run: |
git clone --depth 1 https://github.com/harmont-dev/harmont-py /tmp/harmont-py
sudo /usr/bin/python3 -m pip install --break-system-packages /tmp/harmont-py
/usr/bin/python3 -c "import harmont; print('harmont', harmont.__file__)"
- name: Download hm binary
uses: actions/download-artifact@v4
with:
name: hm-bin
path: bin
- name: Mark hm executable
run: chmod +x bin/hm
- name: Run example via hm run
working-directory: examples/${{ matrix.example }}
env:
HM_NONINTERACTIVE: '1'
run: ${{ github.workspace }}/bin/hm run ci