-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (100 loc) · 2.93 KB
/
examples.yml
File metadata and controls
116 lines (100 loc) · 2.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
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 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.
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
shared-key: examples-hm
- name: Install esbuild (for harmont-ts bundle)
working-directory: dsls/harmont-ts
run: npm ci
- 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
- java
- kotlin
- nextjs
- ocaml
- perl
- python-uv
- react
- ruby
- rust
- typescript
- zig-js
- zig
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "23"
- 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