diff --git a/.github/workflows/ci-backwards-compatibility.yml b/.github/workflows/ci-backwards-compatibility.yml index 919fb4009da..5c23a64b9a8 100644 --- a/.github/workflows/ci-backwards-compatibility.yml +++ b/.github/workflows/ci-backwards-compatibility.yml @@ -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 \ diff --git a/.github/workflows/ci-fuzz.yml b/.github/workflows/ci-fuzz.yml index bd34462982f..b6828fd6d0e 100644 --- a/.github/workflows/ci-fuzz.yml +++ b/.github/workflows/ci-fuzz.yml @@ -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 \ diff --git a/.github/workflows/upgrade-tests.yml b/.github/workflows/upgrade-tests.yml index 75e4a5e026e..6ae13f7b0f2 100644 --- a/.github/workflows/upgrade-tests.yml +++ b/.github/workflows/upgrade-tests.yml @@ -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 \ diff --git a/scripts/ci/run-in-fs-dir-cache.sh b/scripts/ci/run-in-fs-dir-cache.sh index de6e7f05ba6..3f3471f1f41 100755 --- a/scripts/ci/run-in-fs-dir-cache.sh +++ b/scripts/ci/run-in-fs-dir-cache.sh @@ -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 "$@"' _ "$@"