summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoritz Angermann <moritz.angermann@gmail.com>2021-05-06 11:00:34 +0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-05-25 05:52:02 -0400
commit527543fc7c6eecd35573090ae64880bdf17c0812 (patch)
tree8fc96a8d3cb681060cfd418205fd1204b3b1fccb
parent544414ba604b13e0992ad87e90b8bdf45c43011c (diff)
downloadhaskell-527543fc7c6eecd35573090ae64880bdf17c0812.tar.gz
[ci/darwin] cabal-cache dir can be specified per arch
Also while we are at it, run shellcheck on ci.sh
-rw-r--r--.gitlab-ci.yml17
-rwxr-xr-x.gitlab/ci.sh40
-rw-r--r--.gitlab/shell.nix4
3 files changed, 38 insertions, 23 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 610deab361..d27be0d969 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -554,8 +554,9 @@ validate-x86_64-darwin:
BUILD_FLAVOUR: "validate"
# Due to #19025
IGNORE_PERF_FAILURES: "all"
+ CABAL_CACHE: "cabal-cache-amd64"
after_script:
- - cp -Rf $HOME/.cabal cabal-cache
+ - cp -Rf $HOME/.cabal cabal-cache-amd64
- .gitlab/ci.sh clean
# I wish we could just use the nix #! logic, but we can't --run and -i bash
@@ -570,7 +571,7 @@ validate-x86_64-darwin:
--pure \
--keep GHC_VERSION --keep CABAL_INSTALL_VERSION --keep BUILD_FLAVOUR \
--keep BIN_DIST_PREP_TAR_COMP --keep CPUS --keep PROJECT_DIR \
- --keep CI_PROJECT_DIR --keep MAKE_ARGS --keep HADRIAN_ARGS \
+ --keep CI_PROJECT_DIR --keep MAKE_ARGS --keep HADRIAN_ARGS --keep CABAL_CACHE \
--keep LANG --keep CONFIGURE_ARGS --keep TEST_ENV --keep BIN_DIST_NAME \
--keep MACOSX_DEPLOYMENT_TARGET --keep ac_cv_func_clock_gettime --keep HACKAGE_INDEX_STATE \
--run "$1" 2>&1
@@ -619,7 +620,8 @@ validate-x86_64-darwin:
cache:
key: "darwin-x86_64-$GHC_VERSION"
paths:
- - cabal-cache
+ - cabal-cache-amd64
+ - cabal-cache-arm64
- toolchain
validate-aarch64-darwin:
@@ -648,6 +650,10 @@ validate-aarch64-darwin:
HADRIAN_ARGS: "--docs=no-sphinx"
BIN_DIST_NAME: "ghc-arm64-apple-darwin"
TEST_ENV: "aarch64-darwin-hadrian"
+ CABAL_CACHE: "cabal-cache-arm64"
+ after_script:
+ - cp -Rf $HOME/.cabal cabal-cache-arm64
+ - .gitlab/ci.sh clean
# I wish we could just use the nix #! logic, but we can't --run and -i bash
# behave very differently. -i bash does not pass any nix related env vars
@@ -661,7 +667,7 @@ validate-aarch64-darwin:
--pure \
--keep GHC_VERSION --keep CABAL_INSTALL_VERSION --keep BUILD_FLAVOUR \
--keep BIN_DIST_PREP_TAR_COMP --keep CPUS --keep PROJECT_DIR \
- --keep CI_PROJECT_DIR --keep MAKE_ARGS --keep HADRIAN_ARGS \
+ --keep CI_PROJECT_DIR --keep MAKE_ARGS --keep HADRIAN_ARGS --keep CABAL_CACHE \
--keep LANG --keep CONFIGURE_ARGS --keep TEST_ENV --keep BIN_DIST_NAME \
--keep HACKAGE_INDEX_STATE \
--run "$1" 2>&1
@@ -709,7 +715,8 @@ validate-aarch64-darwin:
cache:
key: "darwin-aarch64-$GHC_VERSION"
paths:
- - cabal-cache
+ - cabal-cache-amd64
+ - cabal-cache-arm64
- toolchain
.validate-linux:
diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh
index 2f115c2b22..e40c227b08 100755
--- a/.gitlab/ci.sh
+++ b/.gitlab/ci.sh
@@ -1,5 +1,6 @@
#!/usr/bin/env bash
# shellcheck disable=SC2230
+# shellcheck disable=SC1090
# This is the primary driver of the GitLab CI infrastructure.
# Run `ci.sh usage` for usage information.
@@ -15,7 +16,9 @@ if [ ! -d "$TOP/.gitlab" ]; then
echo "This script expects to be run from the root of a ghc checkout"
fi
-source $TOP/.gitlab/common.sh
+CABAL_CACHE="$TOP/${CABAL_CACHE:-cabal-cache}"
+
+source "$TOP/.gitlab/common.sh"
function usage() {
cat <<EOF
@@ -195,10 +198,10 @@ function set_toolchain_paths() {
# Extract GHC toolchain
function setup() {
- if [ -d "$TOP/cabal-cache" ]; then
+ if [ -d "${CABAL_CACHE}" ]; then
info "Extracting cabal cache..."
mkdir -p "$cabal_dir"
- cp -Rf cabal-cache/* "$cabal_dir"
+ cp -Rf "${CABAL_CACHE}"/* "$cabal_dir"
fi
if [[ "$needs_toolchain" = "1" ]]; then
@@ -370,16 +373,15 @@ function configure() {
run python3 boot
end_section "booting"
- local target_args=""
+ read -r -a args <<< "${CONFIGURE_ARGS:-}"
if [[ -n "${target_triple:-}" ]]; then
- target_args="--target=$target_triple"
+ args+=("--target=$target_triple")
fi
start_section "configuring"
run ./configure \
--enable-tarballs-autodownload \
- $target_args \
- ${CONFIGURE_ARGS:-} \
+ "${args[@]}" \
GHC="$GHC" \
HAPPY="$HAPPY" \
ALEX="$ALEX" \
@@ -400,7 +402,7 @@ function build_make() {
echo "include mk/flavours/${BUILD_FLAVOUR}.mk" > mk/build.mk
echo 'GhcLibHcOpts+=-haddock' >> mk/build.mk
- run "$MAKE" -j"$cores" $MAKE_ARGS
+ run "$MAKE" -j"$cores" "$MAKE_ARGS"
run "$MAKE" -j"$cores" binary-dist-prep TAR_COMP_OPTS=-1
ls -lh "$BIN_DIST_PREP_TAR_COMP"
}
@@ -423,7 +425,8 @@ function push_perf_notes() {
# Figure out which commit should be used by the testsuite driver as a
# performance baseline. See Note [The CI Story].
function determine_metric_baseline() {
- export PERF_BASELINE_COMMIT="$(git merge-base $CI_MERGE_REQUEST_TARGET_BRANCH_NAME HEAD)"
+ PERF_BASELINE_COMMIT="$(git merge-base "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" HEAD)"
+ export PERF_BASELINE_COMMIT
info "Using $PERF_BASELINE_COMMIT for performance metric baseline..."
}
@@ -447,7 +450,7 @@ function build_hadrian() {
run_hadrian binary-dist
- mv _build/bindist/ghc*.tar.xz $BIN_DIST_NAME.tar.xz
+ mv _build/bindist/ghc*.tar.xz "$BIN_DIST_NAME.tar.xz"
}
function test_hadrian() {
@@ -480,7 +483,7 @@ function cabal_test() {
-ddump-to-file -dumpdir "$OUT/dumps" -ddump-timings \
+RTS --machine-readable "-t$OUT/rts.log" -RTS \
-package mtl -ilibraries/Cabal/Cabal libraries/Cabal/Cabal/Setup.hs \
- $@
+ "$@"
rm -Rf tmp
end_section "Cabal test: $OUT"
}
@@ -507,23 +510,24 @@ function run_hadrian() {
fail "BUILD_FLAVOUR not set"
fi
if [ -z "${BIGNUM_BACKEND:-}" ]; then BIGNUM_BACKEND="gmp"; fi
- if [ -n "${VERBOSE:-}" ]; then HADRIAN_ARGS="${HADRIAN_ARGS:-} -V"; fi
+ read -r -a args <<< "${HADRIAN_ARGS:-}"
+ if [ -n "${VERBOSE:-}" ]; then args+=("-V"); fi
run hadrian/build-cabal \
--flavour="$BUILD_FLAVOUR" \
-j"$cores" \
--broken-test="${BROKEN_TESTS:-}" \
--bignum=$BIGNUM_BACKEND \
- ${HADRIAN_ARGS:-} \
- $@
+ "${args[@]}" \
+ "$@"
}
# A convenience function to allow debugging in the CI environment.
function shell() {
- local cmd=$@
+ local cmd="*@"
if [ -z "$cmd" ]; then
cmd="bash -i"
fi
- run $cmd
+ run "$cmd"
}
setup_locale
@@ -598,9 +602,9 @@ case $1 in
test_hadrian || res=$?
push_perf_notes
exit $res ;;
- run_hadrian) shift; run_hadrian $@ ;;
+ run_hadrian) shift; run_hadrian "$@" ;;
perf_test) run_perf_test ;;
clean) clean ;;
- shell) shell $@ ;;
+ shell) shell "$@" ;;
*) fail "unknown mode $1" ;;
esac
diff --git a/.gitlab/shell.nix b/.gitlab/shell.nix
index cff0e89b7f..2f138202fd 100644
--- a/.gitlab/shell.nix
+++ b/.gitlab/shell.nix
@@ -43,6 +43,10 @@
# unconditionally add the MacOSX.sdk and TargetConditional.h
export NIX_CFLAGS_COMPILE+=" -isystem /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include"
+
+ # Use an architecture specific home, so cabal for different architectures don't confuse each other.
+ export HOME="$HOME/$(uname -m)-home"
+ mkdir -p $HOME
'';
nativeBuildInputs = (with pkgs; [