[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [RFC PATCH 25/25] ci: Add a CI checker for Rust-related helpful properties
Checks in both xenbindgen and xen-sys (including autogenerated headers) that: * Autogenerated files are in sync with the specification files. * Specification files abide by certain ABI rules (e.g: no padding). * Clippy and rustfmt are happy with the every .rs file. * All transitive licences are accounted for (cargo-deny). * No transitive dependency has outstanding security advisories (cargo-deny) Signed-off-by: Alejandro Vallejo <alejandro.vallejo@xxxxxxxxx> --- automation/gitlab-ci/analyze.yaml | 14 ++++++++++++++ tools/rust/Makefile | 26 +++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/automation/gitlab-ci/analyze.yaml b/automation/gitlab-ci/analyze.yaml index 02e0ea692c66..c63c909fe175 100644 --- a/automation/gitlab-ci/analyze.yaml +++ b/automation/gitlab-ci/analyze.yaml @@ -72,3 +72,17 @@ eclair-ARM64:on-schedule: ANALYSIS_KIND: "${RULESET}-scheduled" LOGFILE: "eclair-${VARIANT}-${RULESET}.log" allow_failure: true + +rust-verify: + stage: analyze + image: rust:latest # FIXME: Create and use dedicated container + script: + - rustup component add clippy rustfmt + - cargo install cargo-deny + - make -C tools/rust verify 2>&1 | tee rust-verify.log + artifacts: + when: always + paths: + - '*.log' + needs: [] + diff --git a/tools/rust/Makefile b/tools/rust/Makefile index 4f064c37f45c..602722f9d9cc 100644 --- a/tools/rust/Makefile +++ b/tools/rust/Makefile @@ -45,8 +45,33 @@ update: clean-autogen --indir "${XENBINDGEN}/extra" --outdir "${AUTOGEN_C}" # Verify Rust crates pass lint checks. This is enforced in CI +# +# Also ensures autogenerated files are up to date with TOML files. Generation +# is done at commit time rather than build time to avoid a hard dependency on +# the Rust toolchain. .PHONY: verify verify: + @echo "Checking autogenerated C headers to be consistent with TOML" + OUTDIR=`mktemp -d /tmp/xenbindgen-XXXXXXX`; \ + cargo run --manifest-path "${XENBINDGEN}/Cargo.toml" -- --lang c \ + --indir "${XENBINDGEN}/extra" --outdir "$${OUTDIR}"; \ + if ! diff -r "$${OUTDIR}" "${AUTOGEN_C}"; then \ + rm -rf "$${OUTDIR}"; \ + exit 1; \ + fi; \ + rm -rf "$${OUTDIR}" + + @echo "Checking autogenerated Rust files to be consistent with TOML" + OUTDIR=`mktemp -d /tmp/xenbindgen-XXXXXXX`; \ + cargo run --manifest-path "${XENBINDGEN}/Cargo.toml" -- --lang rust \ + --indir "${XENBINDGEN}/extra" --outdir "$${OUTDIR}"; \ + rustfmt $$( find "$${OUTDIR}" -name "*.rs" ); \ + if ! diff -r "$${OUTDIR}" "${AUTOGEN_RS}"; then \ + rm -rf "$${OUTDIR}"; \ + exit 1; \ + fi; \ + rm -rf "$${OUTDIR}" + set -eu; \ for i in "${CRATE_XENSYS}" "${XENBINDGEN}"; do \ echo "Verifying $$i"; \ @@ -56,4 +81,3 @@ verify: cargo deny check; \ cd -; \ done - -- 2.47.0
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |