From d8ec46062b4fb90f33c4ebef2ffa4651737b1eae Mon Sep 17 00:00:00 2001 From: Robert Jacobson Date: Tue, 11 Feb 2025 16:56:11 -0600 Subject: [PATCH 01/12] Added the script `examples/run_examples.sh`, which runs all examples. Modified `build-test.yaml` to run this script in CI. --- .github/workflows/build-test.yaml | 16 +++++++++------- examples/run_examples.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 7 deletions(-) create mode 100755 examples/run_examples.sh diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index e1e3dee0..d059226b 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -14,10 +14,12 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose - - name: Run examples - run: cargo test --examples + - uses: actions/checkout@v4 + - name: Build + run: cargo build --verbose + - name: Run tests + run: cargo test --verbose + - name: Test examples + run: cargo test --examples + - name: Run examples + run: ./examples/run_examples.sh diff --git a/examples/run_examples.sh b/examples/run_examples.sh new file mode 100755 index 00000000..2347adab --- /dev/null +++ b/examples/run_examples.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# List of commands to run +commands=( + "cargo run --example basic-infection" + "cargo run --example births-deaths" + "cargo run --example load-people" + "cargo run --example network-hhmodel" + "cargo run --example parameter-loading" + "cargo run --example random" + "cargo run --example reports" + "cargo run --example reports-multi-threaded" + "cargo run --example runner" + "cargo run --example time-varying-infection ./examples/time-varying-infection/input.json" +) + +# Iterate over the commands and run them +for cmd in "${commands[@]}"; do + echo "Running: $cmd" + $cmd + # Check the exit code of the last command + if [ $? -ne 0 ]; then + echo "Command failed: $cmd" + exit 1 + fi +done + +echo "All commands executed successfully." +exit 0 From 43607171a17cc53d96614da0398ffc29eaa9fd09 Mon Sep 17 00:00:00 2001 From: Robert Jacobson Date: Wed, 12 Feb 2025 19:51:07 -0600 Subject: [PATCH 02/12] Replaced `run_examples.sh` with `examples.yaml`. --- .github/workflows/build-test.yaml | 3 +- .github/workflows/examples.yaml | 47 +++++++++++++++++++++++++++++++ examples/run_examples.sh | 29 ------------------- 3 files changed, 48 insertions(+), 31 deletions(-) create mode 100644 .github/workflows/examples.yaml delete mode 100755 examples/run_examples.sh diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index d059226b..a21d311f 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -21,5 +21,4 @@ jobs: run: cargo test --verbose - name: Test examples run: cargo test --examples - - name: Run examples - run: ./examples/run_examples.sh + diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml new file mode 100644 index 00000000..1803b740 --- /dev/null +++ b/.github/workflows/examples.yaml @@ -0,0 +1,47 @@ +name: Run examples + +on: + push: + branches: main + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Cache Cargo target directory + uses: actions/cache@v4 + with: + path: target + key: cargo-target-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + cargo-target-${{ runner.os }}- + + - name: Build + run: cargo build --verbose + + run_examples: + needs: build + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + example: [ basic-infection, births-deaths, load-people, network-hhmodel, parameter-loading, random, reports, reports-multi-threaded, runner, time-varying-infection ] + steps: + - uses: actions/checkout@v4 + + - name: Cache Cargo target directory + uses: actions/cache@v4 + with: + path: target + key: cargo-target-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + cargo-target-${{ runner.os }}- + + - name: Run the example + run: cargo run --example ${{ matrix.example }} diff --git a/examples/run_examples.sh b/examples/run_examples.sh deleted file mode 100755 index 2347adab..00000000 --- a/examples/run_examples.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -# List of commands to run -commands=( - "cargo run --example basic-infection" - "cargo run --example births-deaths" - "cargo run --example load-people" - "cargo run --example network-hhmodel" - "cargo run --example parameter-loading" - "cargo run --example random" - "cargo run --example reports" - "cargo run --example reports-multi-threaded" - "cargo run --example runner" - "cargo run --example time-varying-infection ./examples/time-varying-infection/input.json" -) - -# Iterate over the commands and run them -for cmd in "${commands[@]}"; do - echo "Running: $cmd" - $cmd - # Check the exit code of the last command - if [ $? -ne 0 ]; then - echo "Command failed: $cmd" - exit 1 - fi -done - -echo "All commands executed successfully." -exit 0 From 23fdbcc2f00b93e5130a314616ee56f769c72119 Mon Sep 17 00:00:00 2001 From: Robert Jacobson Date: Wed, 12 Feb 2025 20:34:19 -0600 Subject: [PATCH 03/12] Modify `examples.yaml` to accommodate examples that take arguments. --- .github/workflows/build-test.yaml | 1 - .github/workflows/examples.yaml | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index a21d311f..f8ad789d 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -21,4 +21,3 @@ jobs: run: cargo test --verbose - name: Test examples run: cargo test --examples - diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml index 1803b740..e5e832e1 100644 --- a/.github/workflows/examples.yaml +++ b/.github/workflows/examples.yaml @@ -31,7 +31,18 @@ jobs: strategy: fail-fast: false matrix: - example: [ basic-infection, births-deaths, load-people, network-hhmodel, parameter-loading, random, reports, reports-multi-threaded, runner, time-varying-infection ] + include: + - example: basic-infection + - example: births-deaths + - example: load-people + - example: network-hhmodel + - example: parameter-loading + - example: random + - example: reports + - example: reports-multi-threaded + - example: runner + - example: time-varying-infection + args: ./examples/time-varying-infection/input.json steps: - uses: actions/checkout@v4 @@ -44,4 +55,4 @@ jobs: cargo-target-${{ runner.os }}- - name: Run the example - run: cargo run --example ${{ matrix.example }} + run: cargo run --example ${{ matrix.example }} ${{ matrix.args }} From 54e229944c6af4a747d0e405ea174454e6a005c7 Mon Sep 17 00:00:00 2001 From: Robert Jacobson Date: Wed, 12 Feb 2025 22:27:00 -0600 Subject: [PATCH 04/12] Modify `examples.yaml` to reset timestamps of the cached target directory to attempt to prevent recompilation. --- .github/workflows/examples.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml index e5e832e1..fc242350 100644 --- a/.github/workflows/examples.yaml +++ b/.github/workflows/examples.yaml @@ -54,5 +54,8 @@ jobs: restore-keys: | cargo-target-${{ runner.os }}- + - name: Reset timestamps + run: find target -type f -exec touch {} + + - name: Run the example run: cargo run --example ${{ matrix.example }} ${{ matrix.args }} From 09a2ea6ad3e371cf4d6e53b6acda29f830ae20d8 Mon Sep 17 00:00:00 2001 From: Robert Jacobson Date: Wed, 12 Feb 2025 22:37:45 -0600 Subject: [PATCH 05/12] Cache the `.cargo` directory in addition to the `target` directory. --- .github/workflows/examples.yaml | 40 ++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml index fc242350..41573fb3 100644 --- a/.github/workflows/examples.yaml +++ b/.github/workflows/examples.yaml @@ -14,6 +14,16 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Cache Cargo dependencies + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: cargo-deps-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + cargo-deps-${{ runner.os }}- + - name: Cache Cargo target directory uses: actions/cache@v4 with: @@ -25,6 +35,24 @@ jobs: - name: Build run: cargo build --verbose + - name: Save Cargo dependencies cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: cargo-deps-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + cargo-deps-${{ runner.os }}- + + - name: Save Cargo target directory cache + uses: actions/cache@v4 + with: + path: target + key: cargo-target-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + cargo-target-${{ runner.os }}- + run_examples: needs: build runs-on: ubuntu-latest @@ -46,7 +74,17 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Cache Cargo target directory + - name: Restore Cargo dependencies cache + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + key: cargo-deps-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + restore-keys: | + cargo-deps-${{ runner.os }}- + + - name: Restore Cargo target directory cache uses: actions/cache@v4 with: path: target From 8242e2da078ae2c126524d4ede75f861b64fb9e2 Mon Sep 17 00:00:00 2001 From: Robert Jacobson Date: Wed, 12 Feb 2025 22:54:34 -0600 Subject: [PATCH 06/12] Debugging. --- .github/workflows/examples.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml index 41573fb3..960e707f 100644 --- a/.github/workflows/examples.yaml +++ b/.github/workflows/examples.yaml @@ -53,6 +53,14 @@ jobs: restore-keys: | cargo-target-${{ runner.os }}- + - name: Debug target directory + run: ls -lhR target | head -n200 + + - name: Debug .cargo directory + run: | + ls -lhR ~/.cargo/registry | head -n200 + ls -R ~/.cargo/git | head -n200 + run_examples: needs: build runs-on: ubuntu-latest @@ -95,5 +103,13 @@ jobs: - name: Reset timestamps run: find target -type f -exec touch {} + + - name: Debug target directory + run: ls -lhR target | head -n200 + + - name: Debug .cargo directory + run: | + ls -lhR ~/.cargo/registry | head -n200 + ls -R ~/.cargo/git | head -n200 + - name: Run the example run: cargo run --example ${{ matrix.example }} ${{ matrix.args }} From fa413b6e5ebb8d8953968a22890a29f9a0d97b3f Mon Sep 17 00:00:00 2001 From: Robert Jacobson Date: Thu, 13 Feb 2025 14:55:36 -0600 Subject: [PATCH 07/12] Consolidated build steps into `build-test.yaml` and enabled caching of the dependencies and dependency build artifacts. --- .github/workflows/build-test.yaml | 87 +++++++++++++++++++++- .github/workflows/examples.yaml | 115 ------------------------------ 2 files changed, 86 insertions(+), 116 deletions(-) delete mode 100644 .github/workflows/examples.yaml diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index f8ad789d..51da86dd 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -15,9 +15,94 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Build + + - name: Restore Cargo dependencies cache + id: restore-deps + uses: actions/cache/restore@v4 + with: + path: | + ~/.cargo/registry + # To manually invalidate the cash, just bump the "version" `-v0-` substring in the key. Be sure to update + # the other save/restore steps to keep them in sync with the new version. + key: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + # There is no harm in restoring mismatched downloaded dependencies, as cargo will fetch the specific + # versions it needs. + restore-keys: | + cargo-deps-v0-${{ runner.os }}- + + - name: Generate cargo lock file + run: cargo fetch + + - name: Restore Cargo target directory cache + id: restore-target + uses: actions/cache/restore@v4 + with: + path: target + key: cargo-target-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + + - name: Build Ixa run: cargo build --verbose + - name: Run tests run: cargo test --verbose + - name: Test examples run: cargo test --examples + + - name: Build Examples + run: cargo build --verbose --examples + + - name: Save Cargo target directory cache + id: save-target + uses: actions/cache/save@v4 + with: + path: target + key: cargo-target-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + + - name: Save Cargo dependencies cache + id: save-deps + uses: actions/cache/save@v4 + with: + path: ~/.cargo/registry + key: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + + + run_examples: + needs: build + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + include: + - example: basic-infection + - example: births-deaths + - example: load-people + - example: network-hhmodel + - example: parameter-loading + - example: random + - example: reports + - example: reports-multi-threaded + - example: runner + - example: time-varying-infection + args: ./examples/time-varying-infection/input.json + steps: + - uses: actions/checkout@v4 + + - name: Restore Cargo dependencies cache + uses: actions/cache/restore@v4 + with: + path: ~/.cargo/registry + key: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + restore-keys: cargo-deps-v0-${{ runner.os }}- + + - name: Generate cargo lock file + run: cargo fetch + + - name: Restore Cargo target directory cache + uses: actions/cache/restore@v4 + with: + path: target + key: cargo-target-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + + - name: Run the example + run: cargo run --example ${{ matrix.example }} ${{ matrix.args }} diff --git a/.github/workflows/examples.yaml b/.github/workflows/examples.yaml deleted file mode 100644 index 960e707f..00000000 --- a/.github/workflows/examples.yaml +++ /dev/null @@ -1,115 +0,0 @@ -name: Run examples - -on: - push: - branches: main - pull_request: - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - - name: Cache Cargo dependencies - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - key: cargo-deps-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - restore-keys: | - cargo-deps-${{ runner.os }}- - - - name: Cache Cargo target directory - uses: actions/cache@v4 - with: - path: target - key: cargo-target-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - restore-keys: | - cargo-target-${{ runner.os }}- - - - name: Build - run: cargo build --verbose - - - name: Save Cargo dependencies cache - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - key: cargo-deps-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - restore-keys: | - cargo-deps-${{ runner.os }}- - - - name: Save Cargo target directory cache - uses: actions/cache@v4 - with: - path: target - key: cargo-target-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - restore-keys: | - cargo-target-${{ runner.os }}- - - - name: Debug target directory - run: ls -lhR target | head -n200 - - - name: Debug .cargo directory - run: | - ls -lhR ~/.cargo/registry | head -n200 - ls -R ~/.cargo/git | head -n200 - - run_examples: - needs: build - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - include: - - example: basic-infection - - example: births-deaths - - example: load-people - - example: network-hhmodel - - example: parameter-loading - - example: random - - example: reports - - example: reports-multi-threaded - - example: runner - - example: time-varying-infection - args: ./examples/time-varying-infection/input.json - steps: - - uses: actions/checkout@v4 - - - name: Restore Cargo dependencies cache - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - key: cargo-deps-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - restore-keys: | - cargo-deps-${{ runner.os }}- - - - name: Restore Cargo target directory cache - uses: actions/cache@v4 - with: - path: target - key: cargo-target-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - restore-keys: | - cargo-target-${{ runner.os }}- - - - name: Reset timestamps - run: find target -type f -exec touch {} + - - - name: Debug target directory - run: ls -lhR target | head -n200 - - - name: Debug .cargo directory - run: | - ls -lhR ~/.cargo/registry | head -n200 - ls -R ~/.cargo/git | head -n200 - - - name: Run the example - run: cargo run --example ${{ matrix.example }} ${{ matrix.args }} From b6149a24ed6b258f8cf7f51be59e806821eb020e Mon Sep 17 00:00:00 2001 From: Robert Jacobson Date: Fri, 14 Feb 2025 09:47:48 -0600 Subject: [PATCH 08/12] Cache of dependencies is tied to Cargo.toml hash. Only `target/debug/deps` build artifacts are cached. --- .github/workflows/build-test.yaml | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index 51da86dd..ecc5f4a5 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -20,24 +20,22 @@ jobs: id: restore-deps uses: actions/cache/restore@v4 with: - path: | - ~/.cargo/registry + path: ~/.cargo/registry # To manually invalidate the cash, just bump the "version" `-v0-` substring in the key. Be sure to update # the other save/restore steps to keep them in sync with the new version. - key: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + key: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }} # There is no harm in restoring mismatched downloaded dependencies, as cargo will fetch the specific - # versions it needs. - restore-keys: | - cargo-deps-v0-${{ runner.os }}- + # versions it needs. If `Cargo.toml` itself changes, the cache is invalidated. + restore-keys: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}- - name: Generate cargo lock file run: cargo fetch - - name: Restore Cargo target directory cache + - name: Restore Cargo target deps directory cache id: restore-target uses: actions/cache/restore@v4 with: - path: target + path: target/debug/deps key: cargo-target-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - name: Build Ixa @@ -47,16 +45,16 @@ jobs: run: cargo test --verbose - name: Test examples - run: cargo test --examples + run: cargo test --verbose --examples - name: Build Examples run: cargo build --verbose --examples - - name: Save Cargo target directory cache + - name: Save Cargo target deps directory cache id: save-target uses: actions/cache/save@v4 with: - path: target + path: target/debug/deps key: cargo-target-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - name: Save Cargo dependencies cache @@ -64,7 +62,7 @@ jobs: uses: actions/cache/save@v4 with: path: ~/.cargo/registry - key: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + key: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }} run_examples: @@ -92,8 +90,8 @@ jobs: uses: actions/cache/restore@v4 with: path: ~/.cargo/registry - key: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - restore-keys: cargo-deps-v0-${{ runner.os }}- + key: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }} + restore-keys: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}- - name: Generate cargo lock file run: cargo fetch @@ -101,7 +99,7 @@ jobs: - name: Restore Cargo target directory cache uses: actions/cache/restore@v4 with: - path: target + path: target/debug/deps key: cargo-target-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - name: Run the example From d5eb46e7b695bca42715f64d9e9485f8e7d36972 Mon Sep 17 00:00:00 2001 From: Robert Jacobson Date: Fri, 14 Feb 2025 10:04:33 -0600 Subject: [PATCH 09/12] Update the timestamps of `target/debug/deps` build artifacts to prevent recompilation. --- .github/workflows/build-test.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index ecc5f4a5..d74951d1 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -38,6 +38,9 @@ jobs: path: target/debug/deps key: cargo-target-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + - name: Update timestamps of target/debug/deps + run: find target/debug/deps -type f -exec touch {} + + - name: Build Ixa run: cargo build --verbose @@ -102,5 +105,8 @@ jobs: path: target/debug/deps key: cargo-target-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + - name: Update timestamps of target/debug/deps + run: find target/debug/deps -type f -exec touch {} + + - name: Run the example run: cargo run --example ${{ matrix.example }} ${{ matrix.args }} From 985e0bbaa920c8ebbacba8bc3b1fded7135da504 Mon Sep 17 00:00:00 2001 From: Robert Jacobson Date: Fri, 14 Feb 2025 10:34:21 -0600 Subject: [PATCH 10/12] Cache `target/debug/.fingerprint` and update its timestamps as well. Remove unused step ids. --- .github/workflows/build-test.yaml | 48 +++++++++++++++++-------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index d74951d1..45f52b25 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -17,29 +17,31 @@ jobs: - uses: actions/checkout@v4 - name: Restore Cargo dependencies cache - id: restore-deps uses: actions/cache/restore@v4 with: path: ~/.cargo/registry # To manually invalidate the cash, just bump the "version" `-v0-` substring in the key. Be sure to update # the other save/restore steps to keep them in sync with the new version. - key: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }} + key: cargo-deps-v00-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }} # There is no harm in restoring mismatched downloaded dependencies, as cargo will fetch the specific # versions it needs. If `Cargo.toml` itself changes, the cache is invalidated. - restore-keys: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}- + restore-keys: cargo-deps-v00-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}- - name: Generate cargo lock file run: cargo fetch - name: Restore Cargo target deps directory cache - id: restore-target uses: actions/cache/restore@v4 with: - path: target/debug/deps - key: cargo-target-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + path: | + target/debug/.fingerprint + target/debug/deps + key: cargo-target-v00-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - - name: Update timestamps of target/debug/deps - run: find target/debug/deps -type f -exec touch {} + + - name: Update timestamps of deps + run: | + find target/debug/.fingerprint -type f -exec touch {} + + find target/debug/deps -type f -exec touch {} + - name: Build Ixa run: cargo build --verbose @@ -54,18 +56,18 @@ jobs: run: cargo build --verbose --examples - name: Save Cargo target deps directory cache - id: save-target uses: actions/cache/save@v4 with: - path: target/debug/deps - key: cargo-target-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + path: | + target/debug/.fingerprint + target/debug/deps + key: cargo-target-v00-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - name: Save Cargo dependencies cache - id: save-deps uses: actions/cache/save@v4 with: path: ~/.cargo/registry - key: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }} + key: cargo-deps-v00-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }} run_examples: @@ -93,20 +95,24 @@ jobs: uses: actions/cache/restore@v4 with: path: ~/.cargo/registry - key: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }} - restore-keys: cargo-deps-v0-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}- + key: cargo-deps-v00-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }} + restore-keys: cargo-deps-v00-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}- - name: Generate cargo lock file run: cargo fetch - - name: Restore Cargo target directory cache + - name: Restore Cargo target deps directory cache uses: actions/cache/restore@v4 with: - path: target/debug/deps - key: cargo-target-v0-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - - - name: Update timestamps of target/debug/deps - run: find target/debug/deps -type f -exec touch {} + + path: | + target/debug/.fingerprint + target/debug/deps + key: cargo-target-v00-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + + - name: Update timestamps of deps + run: | + find target/debug/.fingerprint -type f -exec touch {} + + find target/debug/deps -type f -exec touch {} + - name: Run the example run: cargo run --example ${{ matrix.example }} ${{ matrix.args }} From 898a6eb0672b899d966c3fd6bd81d14e616a3d45 Mon Sep 17 00:00:00 2001 From: Robert Jacobson Date: Fri, 14 Feb 2025 10:41:12 -0600 Subject: [PATCH 11/12] Ignore error when timestamps can't be updated due to missing directory because of a cache miss. --- .github/workflows/build-test.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index 45f52b25..4b5b2398 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -38,10 +38,12 @@ jobs: target/debug/deps key: cargo-target-v00-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + # Update the timestamps to avoid Cargo recompiling the artifacts, ignoring the error in the case the directory + # doesn't exist due to a cache miss. - name: Update timestamps of deps run: | - find target/debug/.fingerprint -type f -exec touch {} + - find target/debug/deps -type f -exec touch {} + + find target/debug/.fingerprint -type f -exec touch {} + || true + find target/debug/deps -type f -exec touch {} + || true - name: Build Ixa run: cargo build --verbose @@ -111,8 +113,8 @@ jobs: - name: Update timestamps of deps run: | - find target/debug/.fingerprint -type f -exec touch {} + - find target/debug/deps -type f -exec touch {} + + find target/debug/.fingerprint -type f -exec touch {} + || true + find target/debug/deps -type f -exec touch {} + || true - name: Run the example run: cargo run --example ${{ matrix.example }} ${{ matrix.args }} From bd423bb5ffb8cbe550828ee0b9f344415fb8991b Mon Sep 17 00:00:00 2001 From: Robert Jacobson Date: Tue, 18 Feb 2025 08:58:17 -0600 Subject: [PATCH 12/12] Removed caching of `.fingerprints` directory. Manually bumped version to invalidate the cache. --- .github/workflows/build-test.yaml | 38 ++++++++++++------------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build-test.yaml b/.github/workflows/build-test.yaml index 4b5b2398..a9dafce2 100644 --- a/.github/workflows/build-test.yaml +++ b/.github/workflows/build-test.yaml @@ -20,12 +20,12 @@ jobs: uses: actions/cache/restore@v4 with: path: ~/.cargo/registry - # To manually invalidate the cash, just bump the "version" `-v0-` substring in the key. Be sure to update + # To manually invalidate the cash, just bump the "version" `-v1-` substring in the key. Be sure to update # the other save/restore steps to keep them in sync with the new version. - key: cargo-deps-v00-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }} + key: cargo-deps-v1-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }} # There is no harm in restoring mismatched downloaded dependencies, as cargo will fetch the specific # versions it needs. If `Cargo.toml` itself changes, the cache is invalidated. - restore-keys: cargo-deps-v00-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}- + restore-keys: cargo-deps-v1-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}- - name: Generate cargo lock file run: cargo fetch @@ -33,17 +33,13 @@ jobs: - name: Restore Cargo target deps directory cache uses: actions/cache/restore@v4 with: - path: | - target/debug/.fingerprint - target/debug/deps - key: cargo-target-v00-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + path: target/debug/deps + key: cargo-target-v1-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} # Update the timestamps to avoid Cargo recompiling the artifacts, ignoring the error in the case the directory # doesn't exist due to a cache miss. - name: Update timestamps of deps - run: | - find target/debug/.fingerprint -type f -exec touch {} + || true - find target/debug/deps -type f -exec touch {} + || true + run: find target/debug/deps -type f -exec touch {} + || true - name: Build Ixa run: cargo build --verbose @@ -60,16 +56,14 @@ jobs: - name: Save Cargo target deps directory cache uses: actions/cache/save@v4 with: - path: | - target/debug/.fingerprint - target/debug/deps - key: cargo-target-v00-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + path: target/debug/deps + key: cargo-target-v1-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - name: Save Cargo dependencies cache uses: actions/cache/save@v4 with: path: ~/.cargo/registry - key: cargo-deps-v00-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }} + key: cargo-deps-v1-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }} run_examples: @@ -97,8 +91,8 @@ jobs: uses: actions/cache/restore@v4 with: path: ~/.cargo/registry - key: cargo-deps-v00-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }} - restore-keys: cargo-deps-v00-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}- + key: cargo-deps-v1-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}-${{ hashFiles('Cargo.lock') }} + restore-keys: cargo-deps-v1-${{ runner.os }}-${{ hashFiles('Cargo.toml') }}- - name: Generate cargo lock file run: cargo fetch @@ -106,15 +100,11 @@ jobs: - name: Restore Cargo target deps directory cache uses: actions/cache/restore@v4 with: - path: | - target/debug/.fingerprint - target/debug/deps - key: cargo-target-v00-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} + path: target/debug/deps + key: cargo-target-v1-${{ runner.os }}-${{ hashFiles('Cargo.lock') }} - name: Update timestamps of deps - run: | - find target/debug/.fingerprint -type f -exec touch {} + || true - find target/debug/deps -type f -exec touch {} + || true + run: find target/debug/deps -type f -exec touch {} + || true - name: Run the example run: cargo run --example ${{ matrix.example }} ${{ matrix.args }}