summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-07-25 15:45:34 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-09-23 16:00:17 -0400
commitca88d91c055d877412626f92973b1f896bcb8b79 (patch)
treea61079da867b105b513d6777750a7ba84dd2e96e
parentaafda13d3746ca8185c89f2f3eca77470f09b746 (diff)
downloadhaskell-ca88d91c055d877412626f92973b1f896bcb8b79.tar.gz
ci: Consolidate handling of cabal cache
Previously the cache persistence was implemented as various ad-hoc `cp` commands at the end of the individual CI scripts. Here we move all of this logic into `ci.sh`.
-rw-r--r--.gitlab-ci.yml17
-rwxr-xr-x.gitlab/ci.sh17
2 files changed, 24 insertions, 10 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8930a2bbc3..942c11023f 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -299,7 +299,7 @@ lint-release-changelogs:
- git checkout .gitmodules
- "git fetch https://gitlab.haskell.org/ghc/ghc-performance-notes.git refs/notes/perf:refs/notes/perf || true"
after_script:
- - cp -Rf $HOME/.cabal cabal-cache
+ - .gitlab/ci.sh save_cache
- .gitlab/ci.sh clean
tags:
- x86_64-linux
@@ -373,7 +373,7 @@ hadrian-ghc-in-ghci:
# Load ghc-in-ghci then immediately exit and check the modules loaded
- echo ":q" | hadrian/ghci -j`mk/detect-cpu-count.sh`| tail -n2 | grep "Ok,"
after_script:
- - cp -Rf $HOME/.cabal cabal-cache
+ - .gitlab/ci.sh save_cache
cache:
key: hadrian-ghci
paths:
@@ -398,7 +398,7 @@ hadrian-ghc-in-ghci:
- git checkout .gitmodules
- .gitlab/ci.sh setup
after_script:
- - cp -Rf $HOME/.cabal cabal-cache
+ - .gitlab/ci.sh save_cache
variables:
GHC_FLAGS: -Werror
cache:
@@ -492,7 +492,7 @@ lint-libs:
TEST_ENV: "x86_64-freebsd"
BUILD_FLAVOUR: "validate"
after_script:
- - cp -Rf $HOME/.cabal cabal-cache
+ - .gitlab/ci.sh save_cache
- .gitlab/ci.sh clean
artifacts:
when: always
@@ -531,7 +531,7 @@ release-x86_64-freebsd:
TEST_ENV: "x86_64-freebsd-hadrian"
BUILD_FLAVOUR: "validate"
after_script:
- - cp -Rf $HOME/.cabal cabal-cache
+ - .gitlab/ci.sh save_cache
- .gitlab/ci.sh clean
artifacts:
when: always
@@ -644,7 +644,7 @@ validate-x86_64-darwin:
echo "Test took $TIME_TEST_DELTA seconds"
# Important to run this in nix-shell because $HOME is different in there
- runInNixShell ".gitlab/ci.sh save-cache" 2>&1
+ runInNixShell ".gitlab/ci.sh save_cache" 2>&1
echo "=== TIMINGS ==="
echo "Setup | $TIME_SETUP_DELTA"
@@ -740,7 +740,7 @@ validate-aarch64-darwin:
echo "Test took $TIME_TEST_DELTA seconds"
# Important to run this in nix-shell because $HOME is different there
- runInNixShell ".gitlab/ci.sh save-cache" 2>&1
+ runInNixShell ".gitlab/ci.sh save_cache" 2>&1
echo "=== TIMINGS ==="
echo "Setup | $TIME_SETUP_DELTA"
@@ -1200,8 +1200,7 @@ release-x86_64-linux-fedora27-dwarf:
# Setup toolchain
- bash .gitlab/ci.sh setup
after_script:
- - |
- Copy-Item -Recurse -Path $Env:APPDATA\cabal -Destination cabal-cache
+ - bash .gitlab/ci.sh save_cache
- bash .gitlab/ci.sh clean
dependencies: []
variables:
diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh
index a89ec93a93..b3522f59e6 100755
--- a/.gitlab/ci.sh
+++ b/.gitlab/ci.sh
@@ -20,6 +20,20 @@ CABAL_CACHE="$TOP/${CABAL_CACHE:-cabal-cache}"
source "$TOP/.gitlab/common.sh"
+function time_it() {
+ local name="$1"
+ shift
+ local start=$(date +%s)
+ local res=0
+ $@ || res=$?
+ local end=$(date +%s)
+ local delta=$(expr $end - $start)
+
+ echo "$name took $delta seconds"
+ printf "%15s | $delta" > ci-timings
+ return $res
+}
+
function usage() {
cat <<EOF
$0 - GHC continuous integration driver
@@ -31,6 +45,7 @@ Common Modes:
configure Run ./configure.
clean Clean the tree
shell Run an interactive shell with a configured build environment.
+ save_cache Preserve the cabal cache
Make build system:
@@ -610,7 +625,7 @@ case $1 in
perf_test) run_perf_test ;;
cabal_test) cabal_test ;;
clean) clean ;;
- save-cache) save_cache ;;
+ save_cache) save_cache ;;
shell) shell "$@" ;;
*) fail "unknown mode $1" ;;
esac