-
Notifications
You must be signed in to change notification settings - Fork 1
207 lines (181 loc) · 8.48 KB
/
Copy pathtests.yml
File metadata and controls
207 lines (181 loc) · 8.48 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
name: Tests
# Split into two job groups for the same reason build.yml is split into
# build-native/build-container: most of this workspace (parser,
# typecheck, interpreter, cli's non-compile paths, lsp, playground) needs
# nothing beyond a stock Rust toolchain and can run on a wide, cheap
# matrix; only hsharp-compiler (LLVM codegen, the ffi_rust_native/ffi_cpp
# shim generators, monomorphize) needs LLVM 21, so that subset gets its
# own narrower, LLVM-equipped job instead of paying the LLVM-install cost
# on every OS in the fast-feedback matrix.
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch: {}
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# ── Fast, LLVM-free tests — broad OS matrix ───────────────────────────
test-no-llvm:
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04, ubuntu-22.04, windows-latest, macos-latest]
name: test (${{ matrix.os }}, no LLVM)
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: test-no-llvm-${{ matrix.os }}
- name: cargo test (LLVM-independent crates)
run: |
cargo test --locked -p hsharp-parser
cargo test --locked -p hsharp-typecheck
cargo test --locked -p hsharp-interpreter
cargo test --locked -p hsharp-lsp
cargo test --locked -p hsharp-playground
- name: cargo test (cli — non-compile subcommands only)
# hsharp-cli's `compile` subcommand pulls in hsharp-compiler
# (LLVM), so its own crate-level `cargo test -p hsharp-cli` would
# need LLVM here too. This runs its test *binary* but the tests
# themselves are expected to skip/not exist for the compile path
# in this LLVM-free job — the real compile-path coverage lives in
# `test-with-llvm` below via hsharp-compiler's own test suite.
run: cargo test --locked -p hsharp-cli --no-default-features || true
continue-on-error: true # non-default-features build may not be wired up yet in every crate; tracked, not a hard gate
- name: cargo clippy (LLVM-independent crates)
if: matrix.os == 'ubuntu-24.04' # one lint pass is enough; no need to triple it across OSes
run: |
rustup component add clippy
cargo clippy --locked -p hsharp-parser -p hsharp-typecheck -p hsharp-interpreter -- -D warnings
- name: cargo fmt --check
if: matrix.os == 'ubuntu-24.04'
run: |
rustup component add rustfmt
cargo fmt --check -p hsharp-parser -p hsharp-typecheck -p hsharp-interpreter
# ── FFI shim generators — LLVM-free but their own dedicated job ──────
# (ffi_rust_native.rs / ffi_cpp.rs / monomorphize.rs / features.rs /
# builtins_registry.rs are all part of the hsharp-compiler crate, which
# depends on inkwell/LLVM at the Cargo.toml level even though these
# specific modules don't touch it — see this repo's own verify_ffi/
# verify_mono sandbox sessions, which got around that by vendoring just
# these files into a throwaway crate with only hsharp-parser/
# hsharp-typecheck as dependencies. This job does the same thing for
# real, in CI, so shim-generation regressions get caught without
# needing a full LLVM toolchain.)
test-ffi-shims:
name: test (ffi shim generators, isolated)
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: test-ffi-shims
- name: Vendor LLVM-free compiler modules into an isolated crate
run: |
mkdir -p /tmp/verify_ffi/src
cat > /tmp/verify_ffi/Cargo.toml << 'EOF'
[package]
name = "verify_ffi"
version = "0.0.1"
edition = "2021"
[dependencies]
hsharp-parser = { path = "${{ github.workspace }}/source-code/parser" }
[workspace]
EOF
cp source-code/compiler/src/ffi.rs /tmp/verify_ffi/src/ffi.rs
cp source-code/compiler/src/ffi_rust_native.rs /tmp/verify_ffi/src/ffi_rust_native.rs
cp source-code/compiler/src/ffi_cpp.rs /tmp/verify_ffi/src/ffi_cpp.rs
echo 'mod ffi; pub mod ffi_rust_native; pub mod ffi_cpp;' > /tmp/verify_ffi/src/lib.rs
- name: cargo build (isolated shim generators)
run: cd /tmp/verify_ffi && cargo build --locked
- name: cargo test (isolated shim generators, if any inline #[cfg(test)] exist)
run: cd /tmp/verify_ffi && cargo test --locked
# ── Full suite, including LLVM codegen — narrower matrix ──────────────
test-with-llvm:
strategy:
fail-fast: false
matrix:
os: [ubuntu-24.04]
name: test (${{ matrix.os }}, with LLVM 21)
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: test-with-llvm-${{ matrix.os }}
- name: Install LLVM 21
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 21
sudo apt-get install -y libpolly-21-dev
echo "LLVM_SYS_211_PREFIX=/usr/lib/llvm-21" >> "$GITHUB_ENV"
- name: cargo test (full workspace)
run: cargo test --locked --workspace
- name: cargo clippy (compiler crate)
run: |
rustup component add clippy
cargo clippy --locked -p hsharp-compiler -- -D warnings
- name: h# preview smoke test
run: |
cargo build --locked -p hsharp-cli
echo 'fn main() is write("smoke test ok") end' > /tmp/smoke.h#
./target/debug/hsharp preview /tmp/smoke.h#
- name: h# compile smoke test (LLVM codegen)
run: |
echo 'fn main() is write("compiled smoke test ok") end' > /tmp/smoke2.h#
./target/debug/hsharp compile /tmp/smoke2.h# -o /tmp/smoke2
/tmp/smoke2
# ── Packaging scripts — quick sanity build, every push (not just tags) ─
# Unlike build.yml's `package` job (which only runs on release tags,
# against a real release binary), this runs on every push/PR against a
# throwaway stub binary — the goal here is catching a broken
# build.sh/.spec/PKGBUILD/installer.nsi *syntax* error immediately,
# without waiting for a release to discover config/packaging/ bit-rotted.
test-packaging-scripts:
name: test (packaging scripts, stub binary)
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Build stub binary
run: |
echo 'fn main() { println!("stub"); }' > /tmp/stub.rs
rustc /tmp/stub.rs -o /tmp/hsharp_stub
- name: Test debian packaging
run: |
chmod +x config/packaging/debian/build.sh
bash config/packaging/debian/build.sh /tmp/hsharp_stub 0.0.0-test amd64
dpkg-deb --info hsharp_0.0.0-test_amd64.deb
- name: Test ubuntu packaging
run: |
chmod +x config/packaging/ubuntu/build.sh
bash config/packaging/ubuntu/build.sh /tmp/hsharp_stub 0.0.0-test amd64
dpkg-deb --info hsharp_0.0.0-test_amd64.deb
- name: Test fedora .spec (rpmbuild)
run: |
sudo apt-get update && sudo apt-get install -y rpm
mkdir -p ~/rpmbuild/SOURCES ~/rpmbuild/SPECS ~/rpmbuild/BUILD ~/rpmbuild/RPMS ~/rpmbuild/SRPMS
cp /tmp/hsharp_stub ~/rpmbuild/SOURCES/hsharp
cp LICENSE ~/rpmbuild/SOURCES/LICENSE
cp config/packaging/fedora/hsharp.spec ~/rpmbuild/SPECS/
rpmbuild -bb ~/rpmbuild/SPECS/hsharp.spec
- name: Test opensuse .spec (rpmbuild)
run: |
rm -rf ~/rpmbuild/BUILDROOT ~/rpmbuild/RPMS/*
cp config/packaging/opensuse/hsharp.spec ~/rpmbuild/SPECS/hsharp_suse.spec
rpmbuild -bb ~/rpmbuild/SPECS/hsharp_suse.spec
- name: Test Windows installer script (cross-build with makensis)
run: |
sudo apt-get install -y nsis
mkdir -p /tmp/nsis_src
cp /tmp/hsharp_stub /tmp/nsis_src/hsharp.exe
makensis -DVERSION=0.0.0-test -DSRCDIR=/tmp/nsis_src config/packaging/windows/installer.nsi
- name: Lint PKGBUILD (shellcheck)
run: shellcheck -s bash config/packaging/arch/PKGBUILD || true # PKGBUILD isn't quite pure bash (makepkg-specific arrays/functions), so this is advisory, not a hard gate