]> git.lizzy.rs Git - rust.git/blob - ci.sh
Add a working github actions template
[rust.git] / ci.sh
1 #!/bin/bash
2 set -euo pipefail
3
4 # Determine configuration
5 export RUST_TEST_NOCAPTURE=1
6 export RUST_BACKTRACE=1
7 export RUSTFLAGS="-D warnings"
8 export CARGO_INCREMENTAL=0
9 export CARGO_EXTRA_FLAGS="--all-features"
10
11 # Prepare
12 echo "Build and install miri"
13 ./miri build --all-targets --locked
14 ./miri install # implicitly locked
15 echo
16
17 # Test
18 function run_tests {
19   if [ -n "${MIRI_TEST_TARGET+exists}" ]; then
20     echo "Testing foreign architecture $MIRI_TEST_TARGET"
21   else
22     echo "Testing host architecture"
23   fi
24
25   ./miri test --locked
26   if [ -z "${MIRI_TEST_TARGET+exists}" ]; then
27     # Only for host architecture: tests with MIR optimizations
28     #FIXME: Only testing opt level 1 due to <https://github.com/rust-lang/rust/issues/77564>.
29     MIRIFLAGS="-Z mir-opt-level=1" ./miri test --locked
30   fi
31
32   # On Windows, there is always "python", not "python3" or "python2".
33   if command -v python3 > /dev/null; then
34     PYTHON=python3
35   else
36     PYTHON=python
37   fi
38
39   # "miri test" has built the sysroot for us, now this should pass without
40   # any interactive questions.
41   ${PYTHON} test-cargo-miri/run-test.py
42   echo
43 }
44
45 # host
46 run_tests
47
48 case $HOST_TARGET in
49   x86_64-unknown-linux-gnu)
50     MIRI_TEST_TARGET=i686-unknown-linux-gnu run_tests
51     MIRI_TEST_TARGET=x86_64-apple-darwin run_tests
52     MIRI_TEST_TARGET=i686-pc-windows-msvc run_tests
53     ;;
54   x86_64-apple-darwin)
55     MIRI_TEST_TARGET=mips64-unknown-linux-gnuabi64 run_tests # big-endian architecture
56     MIRI_TEST_TARGET=x86_64-pc-windows-msvc run_tests
57     ;;
58   i686-pc-windows-msvc)
59     MIRI_TEST_TARGET=x86_64-unknown-linux-gnu run_tests
60     MIRI_TEST_TARGET=x86_64-apple-darwin run_tests
61     ;;
62   *)
63     echo "FATAL: unknown OS"
64     exit 1
65     ;;
66 esac