Skip to content

Add --all-features, cargo fmt --check, cargo check, cargo test, cargo doc, and RUSTFLAGS=-Dwarnings to CI #483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
de96237
Added `--all-features`, `cargo test`, and `cargo doc` to CI.
kkysen Jul 1, 2022
6e051a5
Added `./scripts/check.sh` to easily locally test if you pass the new…
kkysen Jul 9, 2022
be50733
Added all the tests to `azure-pipelines.yml`, but with `cargo test` a…
kkysen Jul 9, 2022
b193803
Enable `cargo test` on Darwin as that appears to be working.
kkysen Jul 9, 2022
fb72201
Added a separate `cargo check` step as we're not running `cargo clipp…
kkysen Jul 9, 2022
fd7c365
Disabling `--all-features` as that might be causing things to link ag…
kkysen Jul 9, 2022
8a118b5
Moved `cargo doc` to the end as it takes longer than the tests and is…
kkysen Jul 9, 2022
4ce3e8d
Trying to re-enable `cargo test` with `--all-features` on Linux now t…
kkysen Jul 9, 2022
57ac489
Don't use `--all-features` with `cargo test` on Arch/Fedora, as that …
kkysen Jul 9, 2022
0b59466
Specify `--features dynamic-instrumentation` instead of `--all-featur…
kkysen Jul 9, 2022
7c8e2ac
`test_translator.py` and `pdg.sh` were inheriting the `RUSTFLAGS=-Dwa…
kkysen Jul 12, 2022
94299d4
Add `--tests` to `cargo check` like it is for `cargo clippy` (though …
kkysen Jul 12, 2022
e2a8ef6
Removed `--all` from `cargo clippy` as `cargo check --help` says it's…
kkysen Jul 12, 2022
90b19a1
Renamed `check.sh` to `run_ci_checks.sh` to be more descriptive.
kkysen Jul 14, 2022
0121d08
Added inline documentation to `run_ci_checks.sh`.
kkysen Jul 14, 2022
a90b2f1
Added mostly the same inline documentation to `azure-pipelines.yml`.
kkysen Jul 14, 2022
ed1de35
`brew install bash` on macOS/Darwin, as it's by default bash 3, which…
kkysen Jul 20, 2022
e9a4317
Merge branch 'master' into kkysen/stricter-ci
kkysen Aug 4, 2022
58e46fe
Merge branch 'master' into kkysen/stricter-ci
kkysen Aug 9, 2022
2e051a5
Removed `--features dynamic-instrumentation` from CI checks as it has…
kkysen Aug 9, 2022
63fe102
Specified `--no-deps` for `cargo doc` as we just want to check, not b…
kkysen Aug 9, 2022
6593b6c
De-duplicate ci checks in `azure-pipelines.yml` and `run_ci_checks.sh…
kkysen Aug 9, 2022
7c326f3
Moved `cargo doc` to after `cargo check` as now it's much faster (wit…
kkysen Aug 9, 2022
b141a36
Exclude `c2rust-analyze` from `cargo test` in CI as it's broken on so…
kkysen Aug 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 61 additions & 9 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,52 @@ 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: |
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'

- 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 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: |
# 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
displayName: 'Fast build against host clang/LLVM'
./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
python3 ./scripts/test_translator.py ./tests
./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
./scripts/run_ci_checks.sh test-translator
displayName: 'Test translator (fast build)'

- job: Darwin
Expand All @@ -73,8 +104,29 @@ jobs:

- script: |
export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config
cargo build --release
displayName: 'Fast build against host clang/LLVM'
./scripts/run_ci_checks.sh fmt
displayName: 'cargo fmt --check'

- script: |
export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config
./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
displayName: 'cargo build against host clang/LLVM (fast build)'

- script: python3 ./scripts/test_translator.py ./tests
- script: |
export LLVM_CONFIG_PATH=$(brew --prefix llvm)/bin/llvm-config
./scripts/run_ci_checks.sh test
displayName: 'cargo test'

- script: |
./scripts/run_ci_checks.sh test-translator
displayName: 'Test translator (fast build)'
1 change: 1 addition & 0 deletions scripts/pdg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ main() {
local metadata="${CWD}/${test_dir}/metadata.bc"

(cd "${test_dir}"
unset RUSTFLAGS # transpiled code has tons of warnings; don't allow `-D warnings`
export RUST_BACKTRACE=1
export INSTRUMENT_BACKEND=log
export INSTRUMENT_OUTPUT=log.bc
Expand Down
3 changes: 2 additions & 1 deletion scripts/provision_mac.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
61 changes: 61 additions & 0 deletions scripts/run_ci_checks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env bash

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"

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.
check() {
cargo check --tests --all-features
# cargo clippy --tests --all-features
}

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,
# but doing so and then re-compiling would flush the caches,
# so we leave them until we're done compiling.

# 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).
build() {
cargo build --release
}

test() {
cargo test --release --exclude c2rust-analyze --workspace
}

# `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.
test-translator() {
unset RUSTFLAGS
./scripts/test_translator.py tests/
}

all() {
fmt
check
doc
build
test
test-translator
}

"${1:-all}"