@@ -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: []
+
@@ -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
-
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@cloud.com> --- automation/gitlab-ci/analyze.yaml | 14 ++++++++++++++ tools/rust/Makefile | 26 +++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-)