Skip to content

Commit

Permalink
Merge pull request fedimint#6446 from dpc/24-11-22-fs-dir-cache-update
Browse files Browse the repository at this point in the history
chore(ci): use newly added `fs-dir-cache exec`
  • Loading branch information
dpc authored Dec 2, 2024
2 parents c319879 + 9dbda99 commit 535a390
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-backwards-compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
CARGO_PROFILE=ci \
PERFIT_ACCESS_TOKEN="${{ secrets.PERFIT_ACCESS_TOKEN }}" \
nix develop -c \
nix shell github:rustshop/fs-dir-cache -c \
nix shell 'github:rustshop/fs-dir-cache?rev=e9752d00ee16778c9d3d0b93a09c49c44013ac17' -c \
nix run 'github:rustshop/perfit?rev=a2ea3bae86b0e70d2ebdbca1fd16a843b7f0a3bd#perfit' -- \
run \
--metric aPuCAjrFT7uE5Oax_T4sMw \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-fuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
CARGO_PROFILE=ci \
PERFIT_ACCESS_TOKEN="${{ secrets.PERFIT_ACCESS_TOKEN }}" \
nix develop .#fuzz -c \
nix shell github:rustshop/fs-dir-cache -c \
nix shell 'github:rustshop/fs-dir-cache?rev=e9752d00ee16778c9d3d0b93a09c49c44013ac17' -c \
nix run 'github:rustshop/perfit?rev=a2ea3bae86b0e70d2ebdbca1fd16a843b7f0a3bd#perfit' -- \
run \
--metric EOKLCdk0SRWnjmA0sLRFKQ \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/upgrade-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
CARGO_PROFILE=ci \
PERFIT_ACCESS_TOKEN="${{ secrets.PERFIT_ACCESS_TOKEN }}" \
nix develop -c \
nix shell github:rustshop/fs-dir-cache -c \
nix shell 'github:rustshop/fs-dir-cache?rev=e9752d00ee16778c9d3d0b93a09c49c44013ac17' -c \
nix run 'github:rustshop/perfit?rev=a2ea3bae86b0e70d2ebdbca1fd16a843b7f0a3bd#perfit' -- \
run \
--metric 5pReH96mSsqIeh513jJQGg \
Expand Down
37 changes: 23 additions & 14 deletions scripts/ci/run-in-fs-dir-cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,34 @@ log_file="$FS_DIR_CACHE_ROOT/log"

fs-dir-cache gc unused --seconds "$((5 * 24 * 60 * 60))" # delete caches not used in more than a 5 days

# create/reuse cache (sub-directory) and lock it (wait if already locked)
cache_dir=$(fs-dir-cache lock --key-file Cargo.lock --key-str "${CARGO_PROFILE-:dev}" --key-file flake.lock)
export log_file
export job_name
src_dir=$(pwd)
export src_dir

export TARGET_DIR="$cache_dir/target"
export CARGO_BUILD_TARGET_DIR="$TARGET_DIR"
function run_in_cache() {
echo "$(date --rfc-3339=seconds) RUN job=$job_name dir=$(pwd)" >> "$log_file"
>&2 echo "$(date --rfc-3339=seconds) RUN job=$job_name dir=$(pwd)"
CARGO_BUILD_TARGET_DIR="$(pwd)"
export CARGO_BUILD_TARGET_DIR
cd "$src_dir"

>&2 echo "Starting a job=$job_name in cache_dir=$cache_dir"
function on_exit() {
local exit_code=$?

echo "$(date --rfc-3339=seconds) RUN $cache_dir job=$job_name" >> "$log_file"
echo "$(date --rfc-3339=seconds) END job=$job_name code=$exit_code" >> "$log_file"
>&2 echo "$(date --rfc-3339=seconds) END job=$job_name code=$exit_code"

on_exit() {
local exit_code=$?
exit $exit_code
}
trap on_exit EXIT

fs-dir-cache unlock --dir "${cache_dir}"
echo "$(date --rfc-3339=seconds) END $cache_dir job=$job_name code=$exit_code" >> "$log_file"

exit $exit_code
"$@"
}
trap on_exit EXIT
export -f run_in_cache


"$@"
fs-dir-cache exec \
--key-file Cargo.lock --key-str "${CARGO_PROFILE-:dev}" --key-file flake.lock \
-- \
bash -c 'run_in_cache "$@"' _ "$@"

0 comments on commit 535a390

Please sign in to comment.