From e82d30b956fe1fd3b7940d008d7a367643bbf05f Mon Sep 17 00:00:00 2001 From: Nora Widdecke Date: Tue, 25 Oct 2022 11:53:06 +0200 Subject: [PATCH 1/3] ci: Extract subplot into its own job - Subplot requires the presence of virtual cards, so it needs an image where they are present. However this interferes with the intentions of the cargo-test and cargo-test-debian-bookworm jobs. - Revert the cargo-test and cargo-test-debian-bookworm jobs to the environments they used to test, rust:latest and debain:bookworm-slim, respectively. - Add a test "subplot" that runs the subplot tests as part of the virtual-test stage. --- .gitlab-ci.yml | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 93a4855..0b52c8f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -83,16 +83,15 @@ udeps: cargo-test: stage: test - image: registry.gitlab.com/openpgp-card/virtual-cards/smartpgp-builddeps + image: rust:latest before_script: - mkdir -p /run/user/$UID - apt update -y -qq - apt install -y -qq --no-install-recommends git clang make pkg-config nettle-dev libssl-dev capnproto ca-certificates libpcsclite-dev - apt clean - - /etc/init.d/pcscd start - - su - -c "sh /home/jcardsim/run-card.sh >/dev/null" jcardsim script: - - touch tools/virtual-card-available + # there is no virtual card in this image, so subplot does not generate tests + # that would require one. - cargo test cache: # inherit all general cache settings @@ -102,16 +101,15 @@ cargo-test: cargo-test-debian-bookworm: stage: test - image: registry.gitlab.com/openpgp-card/virtual-cards/smartpgp-builddeps + image: debian:bookworm-slim before_script: - mkdir -p /run/user/$UID - apt update -y -qq - apt install -y -qq --no-install-recommends git rustc cargo clang make pkg-config nettle-dev libssl-dev capnproto ca-certificates libpcsclite-dev - apt clean - - /etc/init.d/pcscd start - - su - -c "sh /home/jcardsim/run-card.sh >/dev/null" jcardsim script: - - touch tools/virtual-card-available + # there is no virtual card in this image, so subplot does not generate tests + # that would require one. - cargo test cache: # inherit all general cache settings @@ -119,6 +117,27 @@ cargo-test-debian-bookworm: # override the key key: "bookworm" +subplot: + stage: virtual-test + image: registry.gitlab.com/openpgp-card/virtual-cards/smartpgp-builddeps + before_script: + - mkdir -p /run/user/$UID + - apt update -y -qq + - apt install -y -qq --no-install-recommends git clang make pkg-config nettle-dev libssl-dev capnproto ca-certificates libpcsclite-dev + - apt clean + - /etc/init.d/pcscd start + - su - -c "sh /home/jcardsim/run-card.sh >/dev/null" jcardsim + script: + # make sure a virtual card is available, so that the subplot tests are + # generated + - touch tools/virtual-card-available + - cargo test + cache: + # inherit all general cache settings + <<: *general_cache_config + # override the key + key: "rust-latest" + run_cardtest_smartpgp: stage: virtual-test image: registry.gitlab.com/openpgp-card/virtual-cards/smartpgp-builddeps From baf7895024e62ba3eeb75cab87064d3858eac654 Mon Sep 17 00:00:00 2001 From: Nora Widdecke Date: Tue, 25 Oct 2022 11:58:26 +0200 Subject: [PATCH 2/3] ci: Report rust and cargo versions --- .gitlab-ci.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0b52c8f..8e11d1d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,6 +21,10 @@ cache: &general_cache_config - target/ - $CARGO_HOME +.report-rust: &report-rust + - cargo --version + - rustc --version + reuse: stage: lint image: @@ -34,8 +38,10 @@ reuse: cargo-fmt: stage: lint image: rust:latest - script: + before_script: - rustup component add rustfmt + - *report-rust + script: - cargo fmt -- --check cache: [ ] @@ -44,6 +50,7 @@ cargo-deny: image: rust:latest before_script: - cargo install --locked cargo-deny + - *report-rust script: - cargo deny check cache: [ ] @@ -56,6 +63,7 @@ cargo-clippy: - apt update -y -qq - apt install -y -qq --no-install-recommends git clang make pkg-config nettle-dev libssl-dev capnproto ca-certificates libpcsclite-dev - apt clean + - *report-rust script: - rustup component add clippy - rm tools/tests/opgpcard.rs # otherwise build fails @@ -89,6 +97,7 @@ cargo-test: - apt update -y -qq - apt install -y -qq --no-install-recommends git clang make pkg-config nettle-dev libssl-dev capnproto ca-certificates libpcsclite-dev - apt clean + - *report-rust script: # there is no virtual card in this image, so subplot does not generate tests # that would require one. @@ -107,6 +116,7 @@ cargo-test-debian-bookworm: - apt update -y -qq - apt install -y -qq --no-install-recommends git rustc cargo clang make pkg-config nettle-dev libssl-dev capnproto ca-certificates libpcsclite-dev - apt clean + - *report-rust script: # there is no virtual card in this image, so subplot does not generate tests # that would require one. @@ -127,6 +137,7 @@ subplot: - apt clean - /etc/init.d/pcscd start - su - -c "sh /home/jcardsim/run-card.sh >/dev/null" jcardsim + - *report-rust script: # make sure a virtual card is available, so that the subplot tests are # generated @@ -141,6 +152,8 @@ subplot: run_cardtest_smartpgp: stage: virtual-test image: registry.gitlab.com/openpgp-card/virtual-cards/smartpgp-builddeps + before_script: + - *report-rust script: - sh /start.sh - RUST_BACKTRACE=1 cargo run -p openpgp-card-tools --bin opgpcard -- status @@ -159,6 +172,8 @@ run_cardtest_smartpgp: run_cardtest_opcard_rs: stage: virtual-test image: registry.gitlab.com/openpgp-card/virtual-cards/opcard-rs-builddeps + before_script: + - *report-rust script: - sh /start.sh - RUST_BACKTRACE=1 cargo run -p openpgp-card-tools --bin opgpcard -- status @@ -177,6 +192,8 @@ run_cardtest_opcard_rs: run_cardtest_ykneo: stage: virtual-test image: registry.gitlab.com/openpgp-card/virtual-cards/ykneo-builddeps + before_script: + - *report-rust script: - sh /start.sh - RUST_BACKTRACE=1 cargo run -p openpgp-card-tools --bin opgpcard -- status @@ -195,6 +212,8 @@ run_cardtest_ykneo: run_cardtest_fluffypgp: stage: virtual-test image: registry.gitlab.com/openpgp-card/virtual-cards/fluffypgp-builddeps + before_script: + - *report-rust script: - sh /start.sh - RUST_BACKTRACE=1 cargo run -p openpgp-card-tools --bin opgpcard -- status @@ -252,6 +271,8 @@ hardware-builddeps: - "card-functionality/ci/nitro-pro1.toml" - "card-functionality/ci/nitro-pro2.toml" - "card-functionality/ci/nitro-start.toml" + before_script: + - *report-rust script: - RUST_BACKTRACE=1 RUST_LOG=debug cargo run --bin $ARG -- $CONFIG cache: From 7113de821e218b5cc41ed359a2f7fa9112a4d0f5 Mon Sep 17 00:00:00 2001 From: Nora Widdecke Date: Tue, 25 Oct 2022 12:12:48 +0200 Subject: [PATCH 3/3] ci: Remove superflous workaround --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8e11d1d..220971e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -66,7 +66,6 @@ cargo-clippy: - *report-rust script: - rustup component add clippy - - rm tools/tests/opgpcard.rs # otherwise build fails - cargo clippy --verbose --tests -- -D warnings cache: # inherit all general cache settings @@ -85,7 +84,6 @@ udeps: - curl --location --output /tmp/cargo-udeps.tar.gz https://github.com/est31/cargo-udeps/releases/download/v0.1.26/cargo-udeps-v0.1.26-x86_64-unknown-linux-gnu.tar.gz - tar --extract --verbose --gzip --file /tmp/cargo-udeps.tar.gz --directory /usr/local/bin/ --strip-components=2 ./cargo-udeps-v0.1.26-x86_64-unknown-linux-gnu/cargo-udeps script: - - rm tools/tests/opgpcard.rs # otherwise build fails - cargo udeps --workspace --all-features --all-targets cache: [ ]