summaryrefslogtreecommitdiff
path: root/.gitlab/ci.sh
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2022-09-23 12:13:25 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-12-08 22:45:27 -0500
commit5d0a311f28b96e8be2e051ae8cb08cc654d0b63e (patch)
treec94eb0eaa3fe7b8dff68a3845de144729f6c606e /.gitlab/ci.sh
parent216deefd377cf495f07f05a9b355e8d842ccb5b6 (diff)
downloadhaskell-5d0a311f28b96e8be2e051ae8cb08cc654d0b63e.tar.gz
ci: Add job to test interface file determinism guarantees
In this job we can run on every commit we add a test which builds the Cabal library twice and checks that the ABI hash and interface hash is stable across the two builds. * We run the test 20 times to try to weed out any race conditions due to `-j` * We run the builds in different temporary directories to try to weed out anything related to build directory affecting ABI or interface file hash. Fixes #22180
Diffstat (limited to '.gitlab/ci.sh')
-rwxr-xr-x.gitlab/ci.sh60
1 files changed, 60 insertions, 0 deletions
diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh
index b840500aa4..5a9097aaab 100755
--- a/.gitlab/ci.sh
+++ b/.gitlab/ci.sh
@@ -663,6 +663,36 @@ function test_hadrian() {
}
+function summarise_hi_files() {
+ for iface in $(find . -type f -name "*.hi" | sort); do echo "$iface $($HC --show-iface $iface | grep " ABI hash:")"; done | tee $OUT/abis
+ for iface in $(find . -type f -name "*.hi" | sort); do echo "$iface $($HC --show-iface $iface | grep " interface hash:")"; done | tee $OUT/interfaces
+ for iface in $(find . -type f -name "*.hi" | sort); do
+ fname="$OUT/$(dirname $iface)"
+ mkdir -p $fname
+ $HC --show-iface $iface > "$OUT/$iface"
+ done
+}
+
+function cabal_abi_test() {
+ if [ -z "$OUT" ]; then
+ fail "OUT not set"
+ fi
+
+ cp -r libraries/Cabal $DIR
+ pushd $DIR
+ echo $PWD
+
+ start_section "Cabal test: $OUT"
+ mkdir -p "$OUT"
+ run "$HC" \
+ -hidir tmp -odir tmp -fforce-recomp -haddock \
+ -iCabal/Cabal/src -XNoPolyKinds Distribution.Simple -j"$cores" \
+ "$@" 2>&1 | tee $OUT/log
+ summarise_hi_files
+ popd
+ end_section "Cabal test: $OUT"
+}
+
function cabal_test() {
if [ -z "$OUT" ]; then
fail "OUT not set"
@@ -693,6 +723,35 @@ function run_perf_test() {
OUT=out/Cabal-O2 cabal_test -O2
}
+function check_interfaces(){
+ difference=$(diff "$1/$3" "$2/$3") || warn "diff failed"
+ if [ -z "$difference" ]
+ then
+ info "$1 and $2 $3 match"
+ else
+ echo $difference
+ for line in $(echo "$difference" | tr ' ' '\n' | grep ".hi" | sort | uniq); do
+ diff "$1/$line" "$2/$line"
+ done
+ fail "$3"
+ fi
+}
+
+function abi_test() {
+ for i in {1..20}; do info "iteration $i"; run_abi_test; done
+}
+
+function run_abi_test() {
+ if [ -z "$HC" ]; then
+ fail "HC not set"
+ fi
+ mkdir -p out
+ OUT="$PWD/out/run1" DIR=$(mktemp -d XXXX-looooooooong) cabal_abi_test -O0
+ OUT="$PWD/out/run2" DIR=$(mktemp -d XXXX-short) cabal_abi_test -O0
+ check_interfaces out/run1 out/run2 abis "Mismatched ABI hash"
+ check_interfaces out/run1 out/run2 interfaces "Mismatched interface hashes"
+}
+
function save_cache () {
info "Storing cabal cache from $CABAL_DIR to $CABAL_CACHE..."
rm -Rf "$CABAL_CACHE"
@@ -837,6 +896,7 @@ case $1 in
exit $res ;;
run_hadrian) shift; run_hadrian "$@" ;;
perf_test) run_perf_test ;;
+ abi_test) abi_test ;;
cabal_test) cabal_test ;;
lint_author) shift; lint_author "$@" ;;
clean) clean ;;