Skip to content

Commit b31759c

Browse files
committed
ci: add test and release workflows
- ci: on push/PR, run rustfmt + cargo test on Linux and macOS (the macOS build exercises the dynamic_lookup module link), and run the Lua tests under headless Neovim - release: on a v* tag, build the native module for linux (x86_64, aarch64 via cargo-zigbuild), macOS (x86_64, aarch64, ad-hoc signed), and windows (best-effort), then publish the per-target shared libraries and SHA256SUMS to the GitHub release
1 parent 9ee55de commit b31759c

2 files changed

Lines changed: 152 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
jobs:
9+
rust:
10+
name: rust (${{ matrix.os }})
11+
strategy:
12+
fail-fast: false
13+
matrix:
14+
os: [ubuntu-latest, macos-latest]
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: dtolnay/rust-toolchain@stable
19+
with:
20+
components: rustfmt
21+
- uses: Swatinem/rust-cache@v2
22+
- name: Check formatting
23+
run: cargo fmt --all --check
24+
- name: Run Rust tests
25+
run: cargo test --all
26+
# Building the cdylib validates the module link (dynamic_lookup on macOS).
27+
- name: Build native module
28+
run: cargo build --release
29+
30+
lua:
31+
name: lua (headless nvim)
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
- uses: dtolnay/rust-toolchain@stable
36+
- uses: Swatinem/rust-cache@v2
37+
- name: Install Neovim (stable)
38+
run: |
39+
curl -fsSL https://github.com/neovim/neovim/releases/download/stable/nvim-linux-x86_64.tar.gz | tar xz
40+
echo "$PWD/nvim-linux-x86_64/bin" >> "$GITHUB_PATH"
41+
- name: Build native module and run Lua tests
42+
run: make test-lua

.github/workflows/release.yml

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: ["v*"]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
build:
13+
name: ${{ matrix.target }}
14+
runs-on: ${{ matrix.os }}
15+
# The Windows mlua module link is best-effort; a failure here must not block
16+
# publishing the other platforms' binaries (Windows users build from source).
17+
continue-on-error: ${{ matrix.experimental || false }}
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
include:
22+
- target: x86_64-unknown-linux-gnu
23+
os: ubuntu-latest
24+
builder: zigbuild
25+
ext: so
26+
built: liblockfile_native.so
27+
- target: aarch64-unknown-linux-gnu
28+
os: ubuntu-latest
29+
builder: zigbuild
30+
ext: so
31+
built: liblockfile_native.so
32+
- target: x86_64-apple-darwin
33+
os: macos-latest
34+
builder: cargo
35+
ext: so
36+
built: liblockfile_native.dylib
37+
codesign: true
38+
- target: aarch64-apple-darwin
39+
os: macos-latest
40+
builder: cargo
41+
ext: so
42+
built: liblockfile_native.dylib
43+
codesign: true
44+
- target: x86_64-pc-windows-msvc
45+
os: windows-latest
46+
builder: cargo
47+
ext: dll
48+
built: lockfile_native.dll
49+
experimental: true
50+
steps:
51+
- uses: actions/checkout@v4
52+
- uses: dtolnay/rust-toolchain@stable
53+
with:
54+
targets: ${{ matrix.target }}
55+
- uses: Swatinem/rust-cache@v2
56+
with:
57+
key: ${{ matrix.target }}
58+
59+
- name: Install zig
60+
if: matrix.builder == 'zigbuild'
61+
uses: mlugg/setup-zig@v1
62+
- name: Install cargo-zigbuild
63+
if: matrix.builder == 'zigbuild'
64+
uses: taiki-e/install-action@v2
65+
with:
66+
tool: cargo-zigbuild
67+
68+
- name: Build (zigbuild)
69+
if: matrix.builder == 'zigbuild'
70+
run: cargo zigbuild --release --target ${{ matrix.target }}
71+
- name: Build (cargo)
72+
if: matrix.builder == 'cargo'
73+
run: cargo build --release --target ${{ matrix.target }}
74+
75+
# Ad-hoc sign so macOS does not block the downloaded dylib.
76+
- name: Codesign (macOS)
77+
if: matrix.codesign
78+
run: codesign --force --sign - "target/${{ matrix.target }}/release/${{ matrix.built }}"
79+
80+
- name: Package asset
81+
shell: bash
82+
run: |
83+
mkdir -p dist
84+
cp "target/${{ matrix.target }}/release/${{ matrix.built }}" \
85+
"dist/lockfile_native-${{ matrix.target }}.${{ matrix.ext }}"
86+
87+
- uses: actions/upload-artifact@v4
88+
with:
89+
name: lockfile_native-${{ matrix.target }}
90+
path: dist/*
91+
92+
release:
93+
name: publish
94+
needs: build
95+
runs-on: ubuntu-latest
96+
steps:
97+
- uses: actions/download-artifact@v4
98+
with:
99+
path: artifacts
100+
- name: Collect binaries and checksums
101+
run: |
102+
mkdir -p dist
103+
find artifacts -type f -name 'lockfile_native-*' -exec cp {} dist/ \;
104+
(cd dist && sha256sum * > SHA256SUMS)
105+
ls -la dist
106+
- uses: softprops/action-gh-release@v2
107+
with:
108+
files: dist/*
109+
fail_on_unmatched_files: false
110+
generate_release_notes: true

0 commit comments

Comments
 (0)