aboutsummaryrefslogtreecommitdiff
path: root/ci
diff options
context:
space:
mode:
authorHugo van der Wijst <hvanderwijst@tesla.com>2019-01-15 22:42:50 -0800
committerJorge Aparicio <jorge@japaric.io>2019-02-16 00:22:22 +0100
commit2f89688ca974944781878a74873801597c0b1f11 (patch)
treee837ee30f5ccdfaa62c83791fd4544f6f861b2f3 /ci
parentfdba26525c4a190d0275dd3b5f3a154fa189a799 (diff)
Make builds reproducible
This is done by using `BTreeMap`s and `BTreeSet`s to get deterministic ordering. Also updated the CI job to check reproducibility of all examples.
Diffstat (limited to 'ci')
-rw-r--r--ci/script.sh45
1 files changed, 35 insertions, 10 deletions
diff --git a/ci/script.sh b/ci/script.sh
index 645db3a..ab7f34b 100644
--- a/ci/script.sh
+++ b/ci/script.sh
@@ -81,20 +81,45 @@ main() {
continue
fi
- if [ $ex != types ]; then
- cargo run --example $ex --target $T | \
- diff -u ci/expected/$ex.run -
+ test_arm_example() {
+ local EXAMPLE=$1
+ local TARGET=$2
+ local BUILD_MODE=$3
+ local FEATURES=$4
+
+ if [ $BUILD_MODE = "release" ]; then
+ local RELEASE_FLAG="--release"
+ else
+ local RELEASE_FLAG=""
+ fi
+
+ if [ -n "$FEATURES" ]; then
+ local FEATURES_FLAG="--features $FEATURES"
+ else
+ local FEATURES_FLAG=""
+ fi
+ local CARGO_FLAGS="--example $EXAMPLE --target $TARGET $RELEASE_FLAG $FEATURES_FLAG"
+
+ cargo run $CARGO_FLAGS | diff -u ci/expected/$EXAMPLE.run -
+ arm-none-eabi-objcopy -O ihex target/$TARGET/$BUILD_MODE/examples/$EXAMPLE ${EXAMPLE}_1.hex
+
+ # build again to ensure that the build is reproducable
+ cargo clean
+ cargo build $CARGO_FLAGS
+ arm-none-eabi-objcopy -O ihex target/$TARGET/$BUILD_MODE/examples/$EXAMPLE ${EXAMPLE}_2.hex
+
+ # compare results of both builds
+ cmp ${EXAMPLE}_1.hex ${EXAMPLE}_2.hex
+ }
- cargo run --example $ex --target $T --release | \
- diff -u ci/expected/$ex.run -
+ if [ $ex != types ]; then
+ test_arm_example $ex $T "debug" ""
+ test_arm_example $ex $T "release" ""
fi
if [ $TARGET != thumbv6m-none-eabi ]; then
- cargo run --features timer-queue --example $ex --target $T | \
- diff -u ci/expected/$ex.run -
-
- cargo run --features timer-queue --example $ex --target $T --release | \
- diff -u ci/expected/$ex.run -
+ test_arm_example $ex $T "debug" "timer-queue"
+ test_arm_example $ex $T "release" "timer-queue"
fi
done
esac