aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2023-11-07 12:43:17 +0000
committerNick Mathewson <nickm@torproject.org>2023-11-07 12:43:17 +0000
commit0ce2e4099a8f91f90b6da2bf43049abcb8763149 (patch)
treea9b3c48bb45a53c8e2855354d384eff19acefadb
parent897072238d84a8609b07905548dd7ff1602f568d (diff)
parent59ff015aa550dd553771a5b767c9cb173502142d (diff)
downloadtorspec-0ce2e4099a8f91f90b6da2bf43049abcb8763149.tar.gz
torspec-0ce2e4099a8f91f90b6da2bf43049abcb8763149.zip
Merge branch 'cache' into 'main'
Cache the built copy of mdbook See merge request tpo/core/torspec!193
-rw-r--r--.gitlab-ci.yml5
-rwxr-xr-xbin/via-cargo-install-in-ci20
2 files changed, 24 insertions, 1 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index f01e598..1b82c3c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -5,7 +5,7 @@ variables:
build:
image: rust:bookworm
script:
- - cargo install mdbook
+ - ./bin/via-cargo-install-in-ci mdbook
- apt-get update && apt-get install -y git python3 python3-yaml
- ./bin/check_index
- ./bin/build_html
@@ -13,6 +13,9 @@ build:
artifacts:
paths:
- public
+ cache:
+ paths:
+ - cache
include:
project: tpo/tpa/ci-templates
diff --git a/bin/via-cargo-install-in-ci b/bin/via-cargo-install-in-ci
new file mode 100755
index 0000000..c104ff9
--- /dev/null
+++ b/bin/via-cargo-install-in-ci
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+# Bump this to "clear" the cache.
+# Actually, it just causes us to ignore previous cached results.
+cache_clear_token=2023-09-11
+
+cache_dir=cache/"$CI_JOB_IMAGE","$cache_clear_token"
+
+mkdir -p "$cache_dir"
+
+for cmd in "$@"; do
+ cache="$cache_dir/$cmd"
+
+ if cp "$cache" "$CARGO_HOME"/bin/; then continue; fi
+
+ cargo install --locked "$cmd"
+ cp -v "$CARGO_HOME/bin/$cmd" "$cache"
+done