summaryrefslogtreecommitdiffhomepage
path: root/ci/ci-rust-script.sh
blob: 90042307ce89ebf53015f6da527d30e0648ff380 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env bash

set -eu

RUST_TOOLCHAIN_CHANNEL=$1
RUSTFLAGS="--deny unused_imports --deny dead_code"

source env.sh ""

rustup update $RUST_TOOLCHAIN_CHANNEL
rustup default $RUST_TOOLCHAIN_CHANNEL

case "$(uname -s)" in
  MINGW*|MSYS_NT*)
    ./build_windows_modules.sh --dev-build
    ;;
esac

# FIXME: Becaues of our old jsonrpc dependency our Rust code won't build
# on latest nightly.
if [ "${RUST_TOOLCHAIN_CHANNEL}" != "nightly" ]; then
  cargo build --verbose
  cargo test --verbose
fi

if [ "${RUST_TOOLCHAIN_CHANNEL}" = "nightly" ]; then
  if rustup component add rustfmt-preview; then
    rustfmt --version;
    cargo fmt -- --check --unstable-features;
  else
    echo "There seems to not be any rustfmt for the current nighly. Skipping formatting check!"
  fi
fi

if ! git diff-index --quiet HEAD; then
  echo "!!! Working directory is dirty !!!";
  git diff-index HEAD
  exit 1;
fi