test-checks.sh 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/usr/bin/env bash
  2. # To prevent usange of `./cargo` without `nightly`
  3. # Introduce cargoNighlty and disable warning to use word splitting
  4. # shellcheck disable=SC2086
  5. set -e
  6. cd "$(dirname "$0")/.."
  7. source ci/_
  8. source ci/rust-version.sh stable
  9. source ci/rust-version.sh nightly
  10. eval "$(ci/channel-info.sh)"
  11. cargoNightly="$(readlink -f "./cargo") nightly"
  12. # check that cargo-hack has been installed
  13. if ! $cargoNightly hack --version >/dev/null 2>&1; then
  14. cat >&2 <<EOF
  15. ERROR: cargo hack failed.
  16. install 'cargo hack' with 'cargo install cargo-hack'
  17. EOF
  18. fi
  19. echo --- build environment
  20. (
  21. set -x
  22. rustup run "$rust_stable" rustc --version --verbose
  23. rustup run "$rust_nightly" rustc --version --verbose
  24. cargo --version --verbose
  25. $cargoNightly --version --verbose
  26. cargo clippy --version --verbose
  27. $cargoNightly clippy --version --verbose
  28. # miri is only available with nightly
  29. $cargoNightly miri --version --verbose
  30. $cargoNightly hack --version --verbose
  31. # audit is done only with "$cargo stable"
  32. cargo audit --version
  33. grcov --version
  34. sccache --version
  35. wasm-pack --version
  36. cargo nextest --version --verbose
  37. $cargoNightly nextest --version --verbose
  38. )
  39. export RUST_BACKTRACE=1
  40. export RUSTFLAGS="-D warnings -A incomplete_features"
  41. # run cargo check for all rust files in this monorepo for faster turnaround in
  42. # case of any compilation/build error for nightly
  43. # Only force up-to-date lock files on edge
  44. if [[ $CI_BASE_BRANCH = "$EDGE_CHANNEL" ]]; then
  45. if _ scripts/cargo-for-all-lock-files.sh "+${rust_nightly}" check \
  46. --locked --workspace --all-targets --features dummy-for-ci-check,frozen-abi; then
  47. true
  48. else
  49. check_status=$?
  50. echo "$0: Some Cargo.lock might be outdated; sync them (or just be a compilation error?)" >&2
  51. echo "$0: protip: $ ./scripts/cargo-for-all-lock-files.sh [--ignore-exit-code] ... \\" >&2
  52. echo "$0: [tree (for outdated Cargo.lock sync)|check (for compilation error)|update -p foo --precise x.y.z (for your Cargo.toml update)] ..." >&2
  53. exit "$check_status"
  54. fi
  55. else
  56. echo "Note: cargo-for-all-lock-files.sh skipped because $CI_BASE_BRANCH != $EDGE_CHANNEL"
  57. fi
  58. _ ci/order-crates-for-publishing.py
  59. _ scripts/cargo-clippy.sh
  60. if [[ -n $CI ]]; then
  61. # exclude from printing "Checking xxx ..."
  62. _ scripts/cargo-for-all-lock-files.sh -- "+${rust_nightly}" sort --workspace --check > /dev/null
  63. else
  64. _ scripts/cargo-for-all-lock-files.sh -- "+${rust_nightly}" sort --workspace --check
  65. fi
  66. _ scripts/check-dev-context-only-utils.sh tree
  67. _ scripts/cargo-for-all-lock-files.sh -- "+${rust_nightly}" fmt --all -- --check
  68. _ ci/do-audit.sh
  69. if [[ -n $CI ]] && [[ $CHANNEL = "stable" ]]; then
  70. _ ci/check-install-all.sh
  71. fi
  72. echo --- ok