From de96237be8859526067ead2161fcf3ba889369f2 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Fri, 1 Jul 2022 15:16:16 -0700 Subject: [PATCH 01/22] Added `--all-features`, `cargo test`, and `cargo doc` to CI. --- azure-pipelines.yml | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 33db9c9207..e6248be022 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -41,9 +41,23 @@ jobs: export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - cargo build --release + cargo build --release --all-features displayName: 'Fast build against host clang/LLVM' + - script: | + export PATH="/home/docker/.cargo/bin:$PATH" + export RUSTUP_HOME=/home/docker/.rustup + export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo + cargo test --release --all-features + displayName: 'cargo test' + + - script: | + export PATH="/home/docker/.cargo/bin:$PATH" + export RUSTUP_HOME=/home/docker/.rustup + export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo + RUSTDOCFLAGS='-D warnings' cargo doc --all-features --document-private-items + displayName: 'cargo doc' + - script: | export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup @@ -73,8 +87,18 @@ jobs: - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - cargo build --release + cargo build --release --all-features displayName: 'Fast build against host clang/LLVM' + + - script: | + export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config + cargo test --release --all-features + displayName: 'cargo test' + + - script: | + export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config + RUSTDOCFLAGS='-D warnings' cargo doc --all-features --document-private-items + displayName: 'cargo doc' - script: python3 ./scripts/test_translator.py ./tests displayName: 'Test translator (fast build)' From 6e051a5ed2891a050291562a0fa3c613f4354514 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Fri, 8 Jul 2022 20:47:18 -0700 Subject: [PATCH 02/22] Added `./scripts/check.sh` to easily locally test if you pass the new CI checks. --- scripts/check.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100755 scripts/check.sh diff --git a/scripts/check.sh b/scripts/check.sh new file mode 100755 index 0000000000..b2cff212a8 --- /dev/null +++ b/scripts/check.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -euox pipefail + +export RUSTFLAGS="-D warnings" +export RUSTDOCFLAGS="-D warnings" + +cargo fmt --check +cargo build --all-features +cargo doc --all-features --document-private-items +cargo test --all-features +cargo clippy --tests --all --all-features +./scripts/test_translator.py tests/ From be507334ba1a88d27ce5b6bf957d08aa1e77d9ee Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Fri, 8 Jul 2022 20:56:20 -0700 Subject: [PATCH 03/22] Added all the tests to `azure-pipelines.yml`, but with `cargo test` and `cargo clippy` commented out as they currently don't work yet. --- azure-pipelines.yml | 74 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 14 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e6248be022..645a494e33 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -34,29 +34,55 @@ jobs: containerImage: immunant/c2rust:ubuntu-bionic-latest container: $[ variables['containerImage'] ] steps: + + # rust was installed for the `docker` user, not the user azure creates + # but cargo and rustup can be controlled via $CARGO_HOME and $RUSTUP_HOME. + # NOTE: $HOME is not set correctly for the azure user; don't rely on it. + - script: | - # rust was installed for the `docker` user, not the user azure creates - # but cargo and rustup can be controlled via $CARGO_HOME and $RUSTUP_HOME. - # NOTE: $HOME is not set correctly for the azure user; don't rely on it. export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - cargo build --release --all-features - displayName: 'Fast build against host clang/LLVM' + export RUSTFLAGS="-D warnings" + export RUSTDOCFLAGS="-D warnings" + cargo fmt --check + displayName: 'cargo fmt --check' + + # - script: | + # export PATH="/home/docker/.cargo/bin:$PATH" + # export RUSTUP_HOME=/home/docker/.rustup + # export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo + # export RUSTFLAGS="-D warnings" + # export RUSTDOCFLAGS="-D warnings" + # cargo clippy --tests --all --all-features + # displayName: 'cargo clippy' - script: | export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - cargo test --release --all-features - displayName: 'cargo test' + export RUSTFLAGS="-D warnings" + export RUSTDOCFLAGS="-D warnings" + cargo build --release --all-features + displayName: 'cargo build against host clang/LLVM (fast build)' - script: | export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - RUSTDOCFLAGS='-D warnings' cargo doc --all-features --document-private-items + export RUSTFLAGS="-D warnings" + export RUSTDOCFLAGS="-D warnings" + cargo doc --all-features --document-private-items displayName: 'cargo doc' + + # - script: | + # export PATH="/home/docker/.cargo/bin:$PATH" + # export RUSTUP_HOME=/home/docker/.rustup + # export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo + # export RUSTFLAGS="-D warnings" + # export RUSTDOCFLAGS="-D warnings" + # cargo test --release --all-features + # displayName: 'cargo test' - script: | export PATH="/home/docker/.cargo/bin:$PATH" @@ -87,18 +113,38 @@ jobs: - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - cargo build --release --all-features - displayName: 'Fast build against host clang/LLVM' + export RUSTFLAGS="-D warnings" + export RUSTDOCFLAGS="-D warnings" + cargo fmt --check + displayName: 'cargo fmt --check' + # - script: | + # export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config + # export RUSTFLAGS="-D warnings" + # export RUSTDOCFLAGS="-D warnings" + # cargo clippy --tests --all --all-features + # displayName: 'cargo clippy' + - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - cargo test --release --all-features - displayName: 'cargo test' + export RUSTFLAGS="-D warnings" + export RUSTDOCFLAGS="-D warnings" + cargo build --release --all-features + displayName: 'cargo build against host clang/LLVM (fast build)' - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - RUSTDOCFLAGS='-D warnings' cargo doc --all-features --document-private-items + export RUSTFLAGS="-D warnings" + export RUSTDOCFLAGS="-D warnings" + cargo doc --all-features --document-private-items displayName: 'cargo doc' - - script: python3 ./scripts/test_translator.py ./tests + # - script: | + # export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config + # export RUSTFLAGS="-D warnings" + # export RUSTDOCFLAGS="-D warnings" + # cargo test --release --all-features + # displayName: 'cargo test' + + - script: python3 ./scripts/test_translator.py ./tests displayName: 'Test translator (fast build)' From b19380344a2fe270f18604aee5b72a278cb0fd73 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Fri, 8 Jul 2022 21:40:58 -0700 Subject: [PATCH 04/22] Enable `cargo test` on Darwin as that appears to be working. --- azure-pipelines.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 645a494e33..e758db4319 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -139,12 +139,12 @@ jobs: cargo doc --all-features --document-private-items displayName: 'cargo doc' - # - script: | - # export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - # export RUSTFLAGS="-D warnings" - # export RUSTDOCFLAGS="-D warnings" - # cargo test --release --all-features - # displayName: 'cargo test' + - script: | + export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config + export RUSTFLAGS="-D warnings" + export RUSTDOCFLAGS="-D warnings" + cargo test --release --all-features + displayName: 'cargo test' - script: python3 ./scripts/test_translator.py ./tests displayName: 'Test translator (fast build)' From fb722016cf5ac32c0c7b30337335dff5f199857c Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Fri, 8 Jul 2022 21:44:36 -0700 Subject: [PATCH 05/22] Added a separate `cargo check` step as we're not running `cargo clippy` yet. --- azure-pipelines.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e758db4319..dcc57753b1 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -48,6 +48,15 @@ jobs: cargo fmt --check displayName: 'cargo fmt --check' + - script: | + export PATH="/home/docker/.cargo/bin:$PATH" + export RUSTUP_HOME=/home/docker/.rustup + export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo + export RUSTFLAGS="-D warnings" + export RUSTDOCFLAGS="-D warnings" + cargo check --all-features + displayName: 'cargo check' + # - script: | # export PATH="/home/docker/.cargo/bin:$PATH" # export RUSTUP_HOME=/home/docker/.rustup @@ -118,6 +127,13 @@ jobs: cargo fmt --check displayName: 'cargo fmt --check' + - script: | + export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config + export RUSTFLAGS="-D warnings" + export RUSTDOCFLAGS="-D warnings" + cargo check --all-features + displayName: 'cargo check' + # - script: | # export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config # export RUSTFLAGS="-D warnings" From fd7c365792955b4be3a2c221accb60f8f9dc5cab Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Fri, 8 Jul 2022 21:45:25 -0700 Subject: [PATCH 06/22] Disabling `--all-features` as that might be causing things to link against different LLVM libraries/versions, which may cause the errors I'm seeing? --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index dcc57753b1..6d5a6dd56d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -72,7 +72,7 @@ jobs: export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo export RUSTFLAGS="-D warnings" export RUSTDOCFLAGS="-D warnings" - cargo build --release --all-features + cargo build --release displayName: 'cargo build against host clang/LLVM (fast build)' - script: | From 8a118b5b2383373af316b62ec3a2d195284b0340 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Fri, 8 Jul 2022 22:14:51 -0700 Subject: [PATCH 07/22] Moved `cargo doc` to the end as it takes longer than the tests and is probably less likely to have an important failure. --- azure-pipelines.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6d5a6dd56d..428476c178 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -75,15 +75,6 @@ jobs: cargo build --release displayName: 'cargo build against host clang/LLVM (fast build)' - - script: | - export PATH="/home/docker/.cargo/bin:$PATH" - export RUSTUP_HOME=/home/docker/.rustup - export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - export RUSTFLAGS="-D warnings" - export RUSTDOCFLAGS="-D warnings" - cargo doc --all-features --document-private-items - displayName: 'cargo doc' - # - script: | # export PATH="/home/docker/.cargo/bin:$PATH" # export RUSTUP_HOME=/home/docker/.rustup @@ -100,6 +91,15 @@ jobs: python3 ./scripts/test_translator.py ./tests displayName: 'Test translator (fast build)' + - script: | + export PATH="/home/docker/.cargo/bin:$PATH" + export RUSTUP_HOME=/home/docker/.rustup + export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo + export RUSTFLAGS="-D warnings" + export RUSTDOCFLAGS="-D warnings" + cargo doc --all-features --document-private-items + displayName: 'cargo doc' + - job: Darwin timeoutInMinutes: 180 pool: @@ -148,13 +148,6 @@ jobs: cargo build --release --all-features displayName: 'cargo build against host clang/LLVM (fast build)' - - script: | - export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - export RUSTFLAGS="-D warnings" - export RUSTDOCFLAGS="-D warnings" - cargo doc --all-features --document-private-items - displayName: 'cargo doc' - - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config export RUSTFLAGS="-D warnings" @@ -164,3 +157,10 @@ jobs: - script: python3 ./scripts/test_translator.py ./tests displayName: 'Test translator (fast build)' + + - script: | + export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config + export RUSTFLAGS="-D warnings" + export RUSTDOCFLAGS="-D warnings" + cargo doc --all-features --document-private-items + displayName: 'cargo doc' From 4ce3e8dd4f3e943c2fc6434f7e3f0b731f001df7 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Fri, 8 Jul 2022 22:15:39 -0700 Subject: [PATCH 08/22] Trying to re-enable `cargo test` with `--all-features` on Linux now that it works again (though the `--all-features` might fail). --- azure-pipelines.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 428476c178..4e01ce2901 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -75,14 +75,14 @@ jobs: cargo build --release displayName: 'cargo build against host clang/LLVM (fast build)' - # - script: | - # export PATH="/home/docker/.cargo/bin:$PATH" - # export RUSTUP_HOME=/home/docker/.rustup - # export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - # export RUSTFLAGS="-D warnings" - # export RUSTDOCFLAGS="-D warnings" - # cargo test --release --all-features - # displayName: 'cargo test' + - script: | + export PATH="/home/docker/.cargo/bin:$PATH" + export RUSTUP_HOME=/home/docker/.rustup + export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo + export RUSTFLAGS="-D warnings" + export RUSTDOCFLAGS="-D warnings" + cargo test --release --all-features + displayName: 'cargo test' - script: | export PATH="/home/docker/.cargo/bin:$PATH" From 57ac4892efa67bf5c36907bcc70ee60c70fae6cd Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Fri, 8 Jul 2022 22:35:35 -0700 Subject: [PATCH 09/22] Don't use `--all-features` with `cargo test` on Arch/Fedora, as that breaks, too. --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4e01ce2901..28ce9ac877 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -81,7 +81,7 @@ jobs: export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo export RUSTFLAGS="-D warnings" export RUSTDOCFLAGS="-D warnings" - cargo test --release --all-features + cargo test --release displayName: 'cargo test' - script: | From 0b59466bb033352bc5eb68cc2558091013260f45 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Sat, 9 Jul 2022 01:25:40 -0700 Subject: [PATCH 10/22] Specify `--features dynamic-instrumentation` instead of `--all-features` for commands that run (`cargo build`, `cargo test`) as we don't want `--features llvm-static` in those cases. --- azure-pipelines.yml | 8 ++++---- scripts/check.sh | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 28ce9ac877..d0a1a139f9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -72,7 +72,7 @@ jobs: export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo export RUSTFLAGS="-D warnings" export RUSTDOCFLAGS="-D warnings" - cargo build --release + cargo build --release --features dynamic-instrumentation displayName: 'cargo build against host clang/LLVM (fast build)' - script: | @@ -81,7 +81,7 @@ jobs: export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo export RUSTFLAGS="-D warnings" export RUSTDOCFLAGS="-D warnings" - cargo test --release + cargo test --release --features dynamic-instrumentation displayName: 'cargo test' - script: | @@ -145,14 +145,14 @@ jobs: export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config export RUSTFLAGS="-D warnings" export RUSTDOCFLAGS="-D warnings" - cargo build --release --all-features + cargo build --release --features dynamic-instrumentation displayName: 'cargo build against host clang/LLVM (fast build)' - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config export RUSTFLAGS="-D warnings" export RUSTDOCFLAGS="-D warnings" - cargo test --release --all-features + cargo test --release --features dynamic-instrumentation displayName: 'cargo test' - script: python3 ./scripts/test_translator.py ./tests diff --git a/scripts/check.sh b/scripts/check.sh index b2cff212a8..c120507361 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -6,8 +6,9 @@ export RUSTFLAGS="-D warnings" export RUSTDOCFLAGS="-D warnings" cargo fmt --check -cargo build --all-features +cargo check --all-features +cargo build --features dynamic-instrumentation cargo doc --all-features --document-private-items -cargo test --all-features +cargo test --features dynamic-instrumentation cargo clippy --tests --all --all-features ./scripts/test_translator.py tests/ From 7c8e2ac9ec3d2c92961af85f9c008d8d574016e7 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Tue, 12 Jul 2022 11:26:58 -0700 Subject: [PATCH 11/22] `test_translator.py` and `pdg.sh` were inheriting the `RUSTFLAGS=-Dwarnings` from `check.sh` causing them to fail, so now `unset RUSTFLAGS` before them. Now `check.sh` passes. Also, build with `--release` now as `test_translator.py` uses that. --- scripts/check.sh | 7 ++++--- scripts/pdg.sh | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/check.sh b/scripts/check.sh index c120507361..98b47e6ca0 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -7,8 +7,9 @@ export RUSTDOCFLAGS="-D warnings" cargo fmt --check cargo check --all-features -cargo build --features dynamic-instrumentation +# cargo clippy --tests --all --all-features cargo doc --all-features --document-private-items -cargo test --features dynamic-instrumentation -cargo clippy --tests --all --all-features +cargo build --features dynamic-instrumentation --release +cargo test --features dynamic-instrumentation --release +unset RUSTFLAGS # transpiled code has tons of warnings; don't allow `-D warnings` ./scripts/test_translator.py tests/ diff --git a/scripts/pdg.sh b/scripts/pdg.sh index 8b7a51fa49..e0cd32c47f 100755 --- a/scripts/pdg.sh +++ b/scripts/pdg.sh @@ -95,6 +95,7 @@ main() { if [[ "${c2rust_instrument}" -nt "${metadata}" ]]; then cargo clean --profile dev # always dev/debug for now + unset RUSTFLAGS # transpiled code has tons of warnings; don't allow `-D warnings` if ! "${c2rust}" instrument \ "${metadata}" "${runtime}" \ -- "${profile_args[@]}" \ From 94299d4c3ea36a387bcdc83b36379ac059bcc871 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Tue, 12 Jul 2022 11:36:48 -0700 Subject: [PATCH 12/22] Add `--tests` to `cargo check` like it is for `cargo clippy` (though currently commented out). --- azure-pipelines.yml | 4 ++-- scripts/check.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index d0a1a139f9..01d6ae432a 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -54,7 +54,7 @@ jobs: export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo export RUSTFLAGS="-D warnings" export RUSTDOCFLAGS="-D warnings" - cargo check --all-features + cargo check --tests --all-features displayName: 'cargo check' # - script: | @@ -131,7 +131,7 @@ jobs: export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config export RUSTFLAGS="-D warnings" export RUSTDOCFLAGS="-D warnings" - cargo check --all-features + cargo check --tests --all-features displayName: 'cargo check' # - script: | diff --git a/scripts/check.sh b/scripts/check.sh index 98b47e6ca0..eb6979f0a4 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -6,7 +6,7 @@ export RUSTFLAGS="-D warnings" export RUSTDOCFLAGS="-D warnings" cargo fmt --check -cargo check --all-features +cargo check --tests --all-features # cargo clippy --tests --all --all-features cargo doc --all-features --document-private-items cargo build --features dynamic-instrumentation --release From e2a8ef6318437f9c547b8586af5b862c90322e46 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Tue, 12 Jul 2022 11:38:00 -0700 Subject: [PATCH 13/22] Removed `--all` from `cargo clippy` as `cargo check --help` says it's deprecated. --- azure-pipelines.yml | 4 ++-- scripts/check.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 01d6ae432a..e4ad8608b9 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -63,7 +63,7 @@ jobs: # export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo # export RUSTFLAGS="-D warnings" # export RUSTDOCFLAGS="-D warnings" - # cargo clippy --tests --all --all-features + # cargo clippy --tests --all-features # displayName: 'cargo clippy' - script: | @@ -138,7 +138,7 @@ jobs: # export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config # export RUSTFLAGS="-D warnings" # export RUSTDOCFLAGS="-D warnings" - # cargo clippy --tests --all --all-features + # cargo clippy --tests --all-features # displayName: 'cargo clippy' - script: | diff --git a/scripts/check.sh b/scripts/check.sh index eb6979f0a4..4d9eef3897 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -7,7 +7,7 @@ export RUSTDOCFLAGS="-D warnings" cargo fmt --check cargo check --tests --all-features -# cargo clippy --tests --all --all-features +# cargo clippy --tests --all-features cargo doc --all-features --document-private-items cargo build --features dynamic-instrumentation --release cargo test --features dynamic-instrumentation --release From 90b19a19d95eec6f2fdfae9d0fbb7d65613a044f Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Wed, 13 Jul 2022 17:28:44 -0700 Subject: [PATCH 14/22] Renamed `check.sh` to `run_ci_checks.sh` to be more descriptive. --- scripts/{check.sh => run_ci_checks.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{check.sh => run_ci_checks.sh} (100%) diff --git a/scripts/check.sh b/scripts/run_ci_checks.sh similarity index 100% rename from scripts/check.sh rename to scripts/run_ci_checks.sh From 0121d08f0b9b863c8085bcfc8a616da54f2b4786 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Wed, 13 Jul 2022 17:42:29 -0700 Subject: [PATCH 15/22] Added inline documentation to `run_ci_checks.sh`. --- scripts/run_ci_checks.sh | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/scripts/run_ci_checks.sh b/scripts/run_ci_checks.sh index 4d9eef3897..16ea2ce760 100755 --- a/scripts/run_ci_checks.sh +++ b/scripts/run_ci_checks.sh @@ -2,14 +2,38 @@ set -euox pipefail +# Run the same checks that are run in CI in `azure-pipelines.yml`. + +# Deny all warnings, including in documentation. export RUSTFLAGS="-D warnings" export RUSTDOCFLAGS="-D warnings" cargo fmt --check + +# Soon to be superceded by the commented out `cargo clippy` below. +# This is different from `cargo build` +# as that uses `--features dynamic-instrumention` (see below) +# and this uses `--all-features` to check everything. cargo check --tests --all-features # cargo clippy --tests --all-features + cargo doc --all-features --document-private-items + +# At this point, we could unset `RUSTFLAGS` and `RUSTDOCFLAGS`, +# as we've already checked all the code, +# but doing so and then re-compiling would flush the caches, +# so we leave them until we're done compiling. + +# Build these with `--features dynamic-instrumentation` +# instead of `--all-features` as `--all-features` includes `--features llvm-static`, +# which we don't want to test here (it doesn't work out of the box on Arch and Fedora; +# see https://github.com/immunant/c2rust/issues/500). cargo build --features dynamic-instrumentation --release cargo test --features dynamic-instrumentation --release -unset RUSTFLAGS # transpiled code has tons of warnings; don't allow `-D warnings` + +# `test_translatory.py` compiles translated code, +# which has tons of warnings. +# `RUSTFLAGS="-D warnings"` would be inherited by that, +# causing tons of errors, so unset that. +unset RUSTFLAGS ./scripts/test_translator.py tests/ From a90b2f10b1f26d69d8f3a9edc38975149819ca06 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Wed, 13 Jul 2022 17:49:23 -0700 Subject: [PATCH 16/22] Added mostly the same inline documentation to `azure-pipelines.yml`. --- azure-pipelines.yml | 45 ++++++++++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index e4ad8608b9..dd012ed30f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -43,8 +43,6 @@ jobs: export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - export RUSTFLAGS="-D warnings" - export RUSTDOCFLAGS="-D warnings" cargo fmt --check displayName: 'cargo fmt --check' @@ -52,8 +50,11 @@ jobs: export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo + # Soon to be superceded by the commented out `cargo clippy` below. + # This is different from `cargo build` + # as that uses `--features dynamic-instrumention` (see below) + # and this uses `--all-features` to check everything. export RUSTFLAGS="-D warnings" - export RUSTDOCFLAGS="-D warnings" cargo check --tests --all-features displayName: 'cargo check' @@ -62,7 +63,6 @@ jobs: # export RUSTUP_HOME=/home/docker/.rustup # export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo # export RUSTFLAGS="-D warnings" - # export RUSTDOCFLAGS="-D warnings" # cargo clippy --tests --all-features # displayName: 'cargo clippy' @@ -70,8 +70,11 @@ jobs: export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo + # Build these with `--features dynamic-instrumentation` + # instead of `--all-features` as `--all-features` includes `--features llvm-static`, + # which we don't want to test here (it doesn't work out of the box on Arch and Fedora; + # see https://github.com/immunant/c2rust/issues/500). export RUSTFLAGS="-D warnings" - export RUSTDOCFLAGS="-D warnings" cargo build --release --features dynamic-instrumentation displayName: 'cargo build against host clang/LLVM (fast build)' @@ -79,8 +82,11 @@ jobs: export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo + # Build these with `--features dynamic-instrumentation` + # instead of `--all-features` as `--all-features` includes `--features llvm-static`, + # which we don't want to test here (it doesn't work out of the box on Arch and Fedora; + # see https://github.com/immunant/c2rust/issues/500). export RUSTFLAGS="-D warnings" - export RUSTDOCFLAGS="-D warnings" cargo test --release --features dynamic-instrumentation displayName: 'cargo test' @@ -88,6 +94,9 @@ jobs: export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo + # `test_translatory.py` compiles translated code, + # which has tons of warnings, so don't set `RUSTFLAGS="-D warnings"`, + # which would be inherited by that, causing tons of errors. python3 ./scripts/test_translator.py ./tests displayName: 'Test translator (fast build)' @@ -122,40 +131,50 @@ jobs: - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - export RUSTFLAGS="-D warnings" - export RUSTDOCFLAGS="-D warnings" cargo fmt --check displayName: 'cargo fmt --check' - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config + # Soon to be superceded by the commented out `cargo clippy` below. + # This is different from `cargo build` + # as that uses `--features dynamic-instrumention` (see below) + # and this uses `--all-features` to check everything. export RUSTFLAGS="-D warnings" - export RUSTDOCFLAGS="-D warnings" cargo check --tests --all-features displayName: 'cargo check' # - script: | # export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config # export RUSTFLAGS="-D warnings" - # export RUSTDOCFLAGS="-D warnings" # cargo clippy --tests --all-features # displayName: 'cargo clippy' - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config + # Build these with `--features dynamic-instrumentation` + # instead of `--all-features` as `--all-features` includes `--features llvm-static`, + # which we don't want to test here (it doesn't work out of the box on Arch and Fedora; + # see https://github.com/immunant/c2rust/issues/500). export RUSTFLAGS="-D warnings" - export RUSTDOCFLAGS="-D warnings" cargo build --release --features dynamic-instrumentation displayName: 'cargo build against host clang/LLVM (fast build)' - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config + # Build these with `--features dynamic-instrumentation` + # instead of `--all-features` as `--all-features` includes `--features llvm-static`, + # which we don't want to test here (it doesn't work out of the box on Arch and Fedora; + # see https://github.com/immunant/c2rust/issues/500). export RUSTFLAGS="-D warnings" - export RUSTDOCFLAGS="-D warnings" cargo test --release --features dynamic-instrumentation displayName: 'cargo test' - - script: python3 ./scripts/test_translator.py ./tests + - script: | + # `test_translatory.py` compiles translated code, + # which has tons of warnings, so don't set `RUSTFLAGS="-D warnings"`, + # which would be inherited by that, causing tons of errors. + python3 ./scripts/test_translator.py ./tests displayName: 'Test translator (fast build)' - script: | From ed1de35ed9135e59bba2873d98abbab9ced40917 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Wed, 20 Jul 2022 10:53:50 -0700 Subject: [PATCH 17/22] `brew install bash` on macOS/Darwin, as it's by default bash 3, which doesn't support arrays properly. Plus, it'd be a good idea to keep bash versions similar so features like arrays don't become a problem in the future, too. --- scripts/provision_mac.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/provision_mac.sh b/scripts/provision_mac.sh index d6c1e64958..2991577fe4 100755 --- a/scripts/provision_mac.sh +++ b/scripts/provision_mac.sh @@ -21,7 +21,8 @@ export HOMEBREW_NO_AUTO_UPDATE=1 # NOTE: Pin LLVM to a known good version since new releases # tend not to be backwards compatible -hb_packages=(python cmake ninja gpg llvm) +# `bash` needed b/c macOS ships with bash 3, which doesn't support arrays properly +hb_packages=(python cmake ninja gpg llvm bash) for item in "${hb_packages[@]}"; do brew info "${item}" | grep 'Not installed' > /dev/null && brew install "${item}" done From 2e051a5967e195c5b04170acc05f34cb0c543508 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Mon, 8 Aug 2022 22:15:28 -0700 Subject: [PATCH 18/22] Removed `--features dynamic-instrumentation` from CI checks as it has now been removed. --- azure-pipelines.yml | 30 ++++++++++++------------------ scripts/run_ci_checks.sh | 10 ++++------ 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index dd012ed30f..c0d6014516 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -51,9 +51,8 @@ jobs: export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo # Soon to be superceded by the commented out `cargo clippy` below. - # This is different from `cargo build` - # as that uses `--features dynamic-instrumention` (see below) - # and this uses `--all-features` to check everything. + # This is different from `cargo build`, + # as this uses `--all-features` to check everything. export RUSTFLAGS="-D warnings" cargo check --tests --all-features displayName: 'cargo check' @@ -70,24 +69,22 @@ jobs: export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - # Build these with `--features dynamic-instrumentation` - # instead of `--all-features` as `--all-features` includes `--features llvm-static`, + # Don't build with `--all-features` as `--all-features` includes `--features llvm-static`, # which we don't want to test here (it doesn't work out of the box on Arch and Fedora; # see https://github.com/immunant/c2rust/issues/500). export RUSTFLAGS="-D warnings" - cargo build --release --features dynamic-instrumentation + cargo build --release displayName: 'cargo build against host clang/LLVM (fast build)' - script: | export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - # Build these with `--features dynamic-instrumentation` - # instead of `--all-features` as `--all-features` includes `--features llvm-static`, + # Don't build with `--all-features` as `--all-features` includes `--features llvm-static`, # which we don't want to test here (it doesn't work out of the box on Arch and Fedora; # see https://github.com/immunant/c2rust/issues/500). export RUSTFLAGS="-D warnings" - cargo test --release --features dynamic-instrumentation + cargo test --release displayName: 'cargo test' - script: | @@ -137,9 +134,8 @@ jobs: - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config # Soon to be superceded by the commented out `cargo clippy` below. - # This is different from `cargo build` - # as that uses `--features dynamic-instrumention` (see below) - # and this uses `--all-features` to check everything. + # This is different from `cargo build`, + # as this uses `--all-features` to check everything. export RUSTFLAGS="-D warnings" cargo check --tests --all-features displayName: 'cargo check' @@ -152,22 +148,20 @@ jobs: - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - # Build these with `--features dynamic-instrumentation` - # instead of `--all-features` as `--all-features` includes `--features llvm-static`, + # Don't build with `--all-features` as `--all-features` includes `--features llvm-static`, # which we don't want to test here (it doesn't work out of the box on Arch and Fedora; # see https://github.com/immunant/c2rust/issues/500). export RUSTFLAGS="-D warnings" - cargo build --release --features dynamic-instrumentation + cargo build --release displayName: 'cargo build against host clang/LLVM (fast build)' - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - # Build these with `--features dynamic-instrumentation` - # instead of `--all-features` as `--all-features` includes `--features llvm-static`, + # Don't build with `--all-features` as `--all-features` includes `--features llvm-static`, # which we don't want to test here (it doesn't work out of the box on Arch and Fedora; # see https://github.com/immunant/c2rust/issues/500). export RUSTFLAGS="-D warnings" - cargo test --release --features dynamic-instrumentation + cargo test --release displayName: 'cargo test' - script: | diff --git a/scripts/run_ci_checks.sh b/scripts/run_ci_checks.sh index 16ea2ce760..ec8e442ee4 100755 --- a/scripts/run_ci_checks.sh +++ b/scripts/run_ci_checks.sh @@ -12,8 +12,7 @@ cargo fmt --check # Soon to be superceded by the commented out `cargo clippy` below. # This is different from `cargo build` -# as that uses `--features dynamic-instrumention` (see below) -# and this uses `--all-features` to check everything. +# as this uses `--all-features` to check everything. cargo check --tests --all-features # cargo clippy --tests --all-features @@ -24,12 +23,11 @@ cargo doc --all-features --document-private-items # but doing so and then re-compiling would flush the caches, # so we leave them until we're done compiling. -# Build these with `--features dynamic-instrumentation` -# instead of `--all-features` as `--all-features` includes `--features llvm-static`, +# Don't build with `--all-features` as `--all-features` includes `--features llvm-static`, # which we don't want to test here (it doesn't work out of the box on Arch and Fedora; # see https://github.com/immunant/c2rust/issues/500). -cargo build --features dynamic-instrumentation --release -cargo test --features dynamic-instrumentation --release +cargo build --release +cargo test --release # `test_translatory.py` compiles translated code, # which has tons of warnings. From 63fe1021527dcf1652490ac2896f1ee79d25f335 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Mon, 8 Aug 2022 22:16:02 -0700 Subject: [PATCH 19/22] Specified `--no-deps` for `cargo doc` as we just want to check, not build documentation. --- azure-pipelines.yml | 4 ++-- scripts/run_ci_checks.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index c0d6014516..fcae47967e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -103,7 +103,7 @@ jobs: export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo export RUSTFLAGS="-D warnings" export RUSTDOCFLAGS="-D warnings" - cargo doc --all-features --document-private-items + cargo doc --all-features --document-private-items --no-deps displayName: 'cargo doc' - job: Darwin @@ -175,5 +175,5 @@ jobs: export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config export RUSTFLAGS="-D warnings" export RUSTDOCFLAGS="-D warnings" - cargo doc --all-features --document-private-items + cargo doc --all-features --document-private-items --no-deps displayName: 'cargo doc' diff --git a/scripts/run_ci_checks.sh b/scripts/run_ci_checks.sh index ec8e442ee4..e2d1894ba9 100755 --- a/scripts/run_ci_checks.sh +++ b/scripts/run_ci_checks.sh @@ -16,7 +16,7 @@ cargo fmt --check cargo check --tests --all-features # cargo clippy --tests --all-features -cargo doc --all-features --document-private-items +cargo doc --all-features --document-private-items --no-deps # At this point, we could unset `RUSTFLAGS` and `RUSTDOCFLAGS`, # as we've already checked all the code, From 6593b6c53c6b7c9517aa863f14358a7c65b65c4b Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Mon, 8 Aug 2022 22:35:01 -0700 Subject: [PATCH 20/22] De-duplicate ci checks in `azure-pipelines.yml` and `run_ci_checks.sh` and force them to be in sync. --- azure-pipelines.yml | 71 +++++++--------------------------------- scripts/run_ci_checks.sh | 40 +++++++++++++++++----- 2 files changed, 44 insertions(+), 67 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fcae47967e..fc5f2d0465 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -43,6 +43,7 @@ jobs: export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo + ./scripts/run_ci_checks.sh fmt cargo fmt --check displayName: 'cargo fmt --check' @@ -50,60 +51,35 @@ jobs: export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - # Soon to be superceded by the commented out `cargo clippy` below. - # This is different from `cargo build`, - # as this uses `--all-features` to check everything. - export RUSTFLAGS="-D warnings" - cargo check --tests --all-features + ./scripts/run_ci_checks.sh check displayName: 'cargo check' - - # - script: | - # export PATH="/home/docker/.cargo/bin:$PATH" - # export RUSTUP_HOME=/home/docker/.rustup - # export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - # export RUSTFLAGS="-D warnings" - # cargo clippy --tests --all-features - # displayName: 'cargo clippy' - script: | export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - # Don't build with `--all-features` as `--all-features` includes `--features llvm-static`, - # which we don't want to test here (it doesn't work out of the box on Arch and Fedora; - # see https://github.com/immunant/c2rust/issues/500). - export RUSTFLAGS="-D warnings" - cargo build --release + ./scripts/run_ci_checks.sh build displayName: 'cargo build against host clang/LLVM (fast build)' - script: | export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - # Don't build with `--all-features` as `--all-features` includes `--features llvm-static`, - # which we don't want to test here (it doesn't work out of the box on Arch and Fedora; - # see https://github.com/immunant/c2rust/issues/500). - export RUSTFLAGS="-D warnings" - cargo test --release + ./scripts/run_ci_checks.sh test displayName: 'cargo test' - script: | export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - # `test_translatory.py` compiles translated code, - # which has tons of warnings, so don't set `RUSTFLAGS="-D warnings"`, - # which would be inherited by that, causing tons of errors. - python3 ./scripts/test_translator.py ./tests + ./scripts/run_ci_checks.sh test-translator displayName: 'Test translator (fast build)' - script: | export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - export RUSTFLAGS="-D warnings" - export RUSTDOCFLAGS="-D warnings" - cargo doc --all-features --document-private-items --no-deps + ./scripts/run_ci_checks.sh doc displayName: 'cargo doc' - job: Darwin @@ -128,52 +104,29 @@ jobs: - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - cargo fmt --check + ./scripts/run_ci_checks.sh fmt displayName: 'cargo fmt --check' - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - # Soon to be superceded by the commented out `cargo clippy` below. - # This is different from `cargo build`, - # as this uses `--all-features` to check everything. - export RUSTFLAGS="-D warnings" - cargo check --tests --all-features + ./scripts/run_ci_checks.sh check displayName: 'cargo check' - - # - script: | - # export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - # export RUSTFLAGS="-D warnings" - # cargo clippy --tests --all-features - # displayName: 'cargo clippy' - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - # Don't build with `--all-features` as `--all-features` includes `--features llvm-static`, - # which we don't want to test here (it doesn't work out of the box on Arch and Fedora; - # see https://github.com/immunant/c2rust/issues/500). - export RUSTFLAGS="-D warnings" - cargo build --release + ./scripts/run_ci_checks.sh build displayName: 'cargo build against host clang/LLVM (fast build)' - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - # Don't build with `--all-features` as `--all-features` includes `--features llvm-static`, - # which we don't want to test here (it doesn't work out of the box on Arch and Fedora; - # see https://github.com/immunant/c2rust/issues/500). - export RUSTFLAGS="-D warnings" - cargo test --release + ./scripts/run_ci_checks.sh test displayName: 'cargo test' - script: | - # `test_translatory.py` compiles translated code, - # which has tons of warnings, so don't set `RUSTFLAGS="-D warnings"`, - # which would be inherited by that, causing tons of errors. - python3 ./scripts/test_translator.py ./tests + ./scripts/run_ci_checks.sh test-translator displayName: 'Test translator (fast build)' - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - export RUSTFLAGS="-D warnings" - export RUSTDOCFLAGS="-D warnings" - cargo doc --all-features --document-private-items --no-deps + ./scripts/run_ci_checks.sh doc displayName: 'cargo doc' diff --git a/scripts/run_ci_checks.sh b/scripts/run_ci_checks.sh index e2d1894ba9..391c72f9f6 100755 --- a/scripts/run_ci_checks.sh +++ b/scripts/run_ci_checks.sh @@ -8,15 +8,21 @@ set -euox pipefail export RUSTFLAGS="-D warnings" export RUSTDOCFLAGS="-D warnings" -cargo fmt --check +fmt() { + cargo fmt --check +} # Soon to be superceded by the commented out `cargo clippy` below. # This is different from `cargo build` # as this uses `--all-features` to check everything. -cargo check --tests --all-features -# cargo clippy --tests --all-features +check() { + cargo check --tests --all-features + # cargo clippy --tests --all-features +} -cargo doc --all-features --document-private-items --no-deps +doc() { + cargo doc --all-features --document-private-items --no-deps +} # At this point, we could unset `RUSTFLAGS` and `RUSTDOCFLAGS`, # as we've already checked all the code, @@ -26,12 +32,30 @@ cargo doc --all-features --document-private-items --no-deps # Don't build with `--all-features` as `--all-features` includes `--features llvm-static`, # which we don't want to test here (it doesn't work out of the box on Arch and Fedora; # see https://github.com/immunant/c2rust/issues/500). -cargo build --release -cargo test --release +build() { + cargo build --release +} + +test() { + cargo test --release +} # `test_translatory.py` compiles translated code, # which has tons of warnings. # `RUSTFLAGS="-D warnings"` would be inherited by that, # causing tons of errors, so unset that. -unset RUSTFLAGS -./scripts/test_translator.py tests/ +test-translator() { + unset RUSTFLAGS + ./scripts/test_translator.py tests/ +} + +all() { + fmt + check + doc + build + test + test-translator +} + +"${1:-all}" From 7c326f3d91475837538cf28ddac3322e23523c96 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Mon, 8 Aug 2022 22:36:26 -0700 Subject: [PATCH 21/22] Moved `cargo doc` to after `cargo check` as now it's much faster (with `--no-deps`) so pushing it to the end (since it's less likely to fail) isn't that important. --- azure-pipelines.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fc5f2d0465..45850ebe08 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -54,6 +54,13 @@ jobs: ./scripts/run_ci_checks.sh check displayName: 'cargo check' + - script: | + export PATH="/home/docker/.cargo/bin:$PATH" + export RUSTUP_HOME=/home/docker/.rustup + export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo + ./scripts/run_ci_checks.sh doc + displayName: 'cargo doc' + - script: | export PATH="/home/docker/.cargo/bin:$PATH" export RUSTUP_HOME=/home/docker/.rustup @@ -75,13 +82,6 @@ jobs: ./scripts/run_ci_checks.sh test-translator displayName: 'Test translator (fast build)' - - script: | - export PATH="/home/docker/.cargo/bin:$PATH" - export RUSTUP_HOME=/home/docker/.rustup - export CARGO_HOME=$AGENT_TEMPDIRECTORY/.cargo - ./scripts/run_ci_checks.sh doc - displayName: 'cargo doc' - - job: Darwin timeoutInMinutes: 180 pool: @@ -112,6 +112,11 @@ jobs: ./scripts/run_ci_checks.sh check displayName: 'cargo check' + - script: | + export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config + ./scripts/run_ci_checks.sh doc + displayName: 'cargo doc' + - script: | export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config ./scripts/run_ci_checks.sh build @@ -125,8 +130,3 @@ jobs: - script: | ./scripts/run_ci_checks.sh test-translator displayName: 'Test translator (fast build)' - - - script: | - export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config - ./scripts/run_ci_checks.sh doc - displayName: 'cargo doc' From b141a36d668583ec015598aa639906ec62ccc645 Mon Sep 17 00:00:00 2001 From: Khyber Sen Date: Tue, 9 Aug 2022 14:26:37 -0700 Subject: [PATCH 22/22] Exclude `c2rust-analyze` from `cargo test` in CI as it's broken on some OSes (https://github.com/immunant/c2rust/issues/593) and we want things to work now. --- scripts/run_ci_checks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/run_ci_checks.sh b/scripts/run_ci_checks.sh index 391c72f9f6..9d3bf46912 100755 --- a/scripts/run_ci_checks.sh +++ b/scripts/run_ci_checks.sh @@ -37,7 +37,7 @@ build() { } test() { - cargo test --release + cargo test --release --exclude c2rust-analyze --workspace } # `test_translatory.py` compiles translated code,