Repository navigation
163 lines (154 loc) · 6.91 KB
/
Copy pathci.yml
File metadata and controls
163 lines (154 loc) · 6.91 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
# SPDX-License-Identifier: Apache-2.0
#
# Continuous integration: builds and TESTS the Rust engine and every binding on each push to
# `main` and every pull request. This is the test/quality gate — it publishes nothing.
#
# Division of labour (see DISTRIBUTION.md):
# * This workflow -> build + test everything, on push/PR (no deploy).
# * *-release.yml -> tag-triggered publishing (crate->crates.io, cli->Releases, py->PyPI).
# * Jenkinsfile -> the ONE thing GitHub Actions can't do here: deploy the Java FFM
# binding to GBIF's Nexus (repository.gbif.org), whose credentials live
# in Jenkins. Jenkins stays scoped to that; all *testing* lives here,
# where the multi-OS runner matrix is free.
#
# The Python crate (crates/nameparser-py) is a PyO3 `extension-module` (abi3) — plain
# `cargo test`/`cargo clippy` on it drags in libpython linking, so the pure-Rust jobs below
# `--exclude nameparser-py` and the dedicated `python` job exercises it via maturin + pytest.
name: CI
on:
push:
branches: [main]
pull_request:
# Cancel superseded runs on the same branch/PR — the newest push is the only one worth checking.
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# ---- Rust: format + lint. Cheap, single-platform, fails fast on style/clippy. ----
rust-lint:
name: rust fmt + clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
key: lint
# fmt covers the whole workspace (it never compiles, so the py crate is safe to include).
- name: cargo fmt --check
run: cargo fmt --all --check
# clippy/test skip nameparser-py (libpython linking) — the `python` job covers that crate.
- name: cargo clippy
run: cargo clippy --workspace --exclude nameparser-py --all-targets -- -D warnings
# ---- Rust: the test suite across the three tier-1 OSes. ----
# This includes crates/nameparser/tests/parse_golden.rs — the 8,017-name golden corpus that IS
# the self-contained Java-parity gate (no sibling Java checkout needed; testdata is committed),
# plus the ported NameParserImplTest / NameParserGnaTest suites and the FFI struct-ABI tests.
rust-test:
name: rust test (${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: test-${{ matrix.os }}
- name: cargo test
run: cargo test --workspace --exclude nameparser-py --all-targets
# ---- Python binding: build the wheel with maturin, install it, run pytest. ----
python:
name: python binding
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: python
- uses: actions/setup-python@v7
with:
python-version: '3.12'
# test_parity.py prefers the Java shaded jar as an oracle but falls back to this repo's own
# release CLI (target/release/nameparser-cli) when the jar is absent — as it is in CI — so
# build the CLI first to give the parity test its oracle.
- name: Build the CLI (parity-test oracle)
run: cargo build --release -p nameparser-cli
- name: Install maturin + pytest
run: pip install maturin pytest
- name: Build + install the wheel
run: |
maturin build --release -m crates/nameparser-py/Cargo.toml --out dist
pip install --no-index --find-links dist gbif-name-parser
- name: pytest
run: pytest crates/nameparser-py/python/tests -v
# ---- R binding (extendr): compile in place and run the testthat suite. ----
# The newest binding — if the extendr build needs tuning, this is the job to adjust. It compiles
# the Rust via the package's configure/Makevars against the workspace core crate (path dep), so
# it needs both R and a Rust toolchain. test-parity.R skips cleanly without the git-ignored
# oracle; test-parse-names.R runs real assertions.
# Runs on all three OSes because CRAN builds on all three, and the Windows path is the one this
# package can plausibly break on: src/Makevars.win.in targets the GNU ABI, fabricates a libgcc_eh
# stub, and links against ws2_32/advapi32/userenv/bcrypt/ntdll -- none of which the Linux build
# exercises. Before this matrix the R binding had only ever been built on Linux (and a maintainer
# Mac), which is a poor position from which to submit to CRAN.
r:
name: r binding (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
# R on Windows compiles through Rtools' GNU toolchain, so the crate needs the -gnu target;
# the default stable install only carries -msvc.
- name: Add the windows-gnu Rust target
if: runner.os == 'Windows'
run: rustup target add x86_64-pc-windows-gnu
- uses: Swatinem/rust-cache@v2
with:
key: r-${{ matrix.os }}
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
with:
working-directory: bindings/r
extra-packages: |
any::testthat
any::pkgload
# load_all compiles the extendr crate in the working tree (so the ../.. path dep to the core
# crate resolves) and attaches the package namespace; test_dir then runs the suite.
- name: testthat
run: Rscript -e 'pkgload::load_all("bindings/r"); testthat::test_dir("bindings/r/tests/testthat", stop_on_failure = TRUE)'
# ---- Java FFM binding: build the host cdylib, then run the Maven tests (ParityTest + smoke). ----
# Mirrors what the Jenkins snapshot build does, minus the Nexus deploy: build-cdylib.sh stages the
# host cdylib into target/release, and the pom's Linux profile points -Dnameparser.ffi.lib at the
# .so. GitHub's ubuntu image ships Maven; build-cdylib.sh bootstraps rustup if needed.
java:
name: java binding
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
key: java
- uses: actions/setup-java@v6
with:
distribution: temurin
java-version: '25'
cache: maven
- name: Build the host cdylib
run: bash ci/build-cdylib.sh
- name: mvn test
run: mvn -B -f bindings/java/pom.xml test