From 1b343e845dd6278261779d2da390e6e1056d68bf Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 25 Aug 2025 15:44:24 +0800 Subject: [PATCH 01/12] test: run rpc snapshots with `cargo test` instead of `nextest` --- .config/nextest.toml | 1 + Makefile | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index 0ed0952fa6a2..4ca2132acc56 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -1,5 +1,6 @@ [profile.default] slow-timeout = { period = "10s", terminate-after = 3 } +run-extra-args = ["--skip", "rpc_test_"] # This test downloads bundles from the network, which can take a while. # It is only run on CI, so we can afford to be more patient. diff --git a/Makefile b/Makefile index abdf1497d1c0..6a6070fb7f20 100644 --- a/Makefile +++ b/Makefile @@ -100,13 +100,14 @@ docker-run: test: cargo nextest run --workspace --no-fail-fast - + cargo test --lib rpc_test # nextest doesn't run doctests https://github.com/nextest-rs/nextest/issues/16 # see also lib.rs::doctest_private cargo test --doc --features doctest-private test-release: cargo nextest run --cargo-profile quick --workspace --no-fail-fast + cargo test --profile quick --lib rpc_test test-all: test test-release From a52c947df765b9c550ceec5f7b1e5b10e1c170fa Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 25 Aug 2025 15:58:09 +0800 Subject: [PATCH 02/12] update test prefix to avoid false positive in filter --- .config/nextest.toml | 1 - Makefile | 8 ++++---- build.rs | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index 4ca2132acc56..0ed0952fa6a2 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -1,6 +1,5 @@ [profile.default] slow-timeout = { period = "10s", terminate-after = 3 } -run-extra-args = ["--skip", "rpc_test_"] # This test downloads bundles from the network, which can take a while. # It is only run on CI, so we can afford to be more patient. diff --git a/Makefile b/Makefile index 6a6070fb7f20..3dd5e608a7cb 100644 --- a/Makefile +++ b/Makefile @@ -99,15 +99,15 @@ docker-run: docker build -t forest:latest -f ./Dockerfile . && docker run forest test: - cargo nextest run --workspace --no-fail-fast - cargo test --lib rpc_test + cargo nextest run --workspace --no-fail-fast -- --skip rpc_snapshot_test_ + cargo test --lib rpc_snapshot_test_ # nextest doesn't run doctests https://github.com/nextest-rs/nextest/issues/16 # see also lib.rs::doctest_private cargo test --doc --features doctest-private test-release: - cargo nextest run --cargo-profile quick --workspace --no-fail-fast - cargo test --profile quick --lib rpc_test + cargo nextest run --cargo-profile quick --workspace --no-fail-fast -- --skip rpc_snapshot_test_ + cargo test --profile quick --lib rpc_snapshot_test_ test-all: test test-release diff --git a/build.rs b/build.rs index 7c748c7d93e9..f467e5f161d2 100644 --- a/build.rs +++ b/build.rs @@ -79,7 +79,7 @@ fn rpc_regression_tests_gen() { w, r#" #[tokio::test(flavor = "multi_thread")] - async fn rpc_test_{ident}() {{ + async fn rpc_snapshot_test_{ident}() {{ rpc_regression_test_run("{test}").await }} "#, From c48a67dbf5a4afb693986e9e413c3afc0741a34c Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 25 Aug 2025 16:04:34 +0800 Subject: [PATCH 03/12] apply AI suggestion --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3dd5e608a7cb..d69e972cfd85 100644 --- a/Makefile +++ b/Makefile @@ -100,14 +100,14 @@ docker-run: test: cargo nextest run --workspace --no-fail-fast -- --skip rpc_snapshot_test_ - cargo test --lib rpc_snapshot_test_ + cargo test --package forest-filecoin --lib rpc_snapshot_test_ # nextest doesn't run doctests https://github.com/nextest-rs/nextest/issues/16 # see also lib.rs::doctest_private cargo test --doc --features doctest-private test-release: cargo nextest run --cargo-profile quick --workspace --no-fail-fast -- --skip rpc_snapshot_test_ - cargo test --profile quick --lib rpc_snapshot_test_ + cargo test --package forest-filecoin --profile quick --lib rpc_snapshot_test_ test-all: test test-release From 671f5c2cc2f78b9b98b3644cca92f5ecd5962e96 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 25 Aug 2025 16:50:36 +0800 Subject: [PATCH 04/12] CI cache for rpc snapshots --- .github/workflows/unit-tests.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index f740ef31a6d8..6aa2a593a735 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -42,6 +42,11 @@ jobs: steps: - name: Checkout Sources uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: ~/.cache/forest/test/rpc-snapshots + key: rpcsnap-${{ hashFiles('~/.cache/forest/test/rpc-snapshots/**') }} + enableCrossOsArchive: true - name: Setup sccache uses: mozilla-actions/sccache-action@v0.0.9 timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }} @@ -64,6 +69,11 @@ jobs: continue-on-error: true - name: Checkout Sources uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: ~/.cache/forest/test/rpc-snapshots + key: rpcsnap-${{ hashFiles('~/.cache/forest/test/rpc-snapshots/**') }} + enableCrossOsArchive: true - name: Setup sccache uses: mozilla-actions/sccache-action@v0.0.9 timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }} From 0e902af5a1c23546562a70749668ca61976ac1bf Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 25 Aug 2025 17:16:52 +0800 Subject: [PATCH 05/12] switch back to nextest --- Makefile | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index d69e972cfd85..abdf1497d1c0 100644 --- a/Makefile +++ b/Makefile @@ -99,15 +99,14 @@ docker-run: docker build -t forest:latest -f ./Dockerfile . && docker run forest test: - cargo nextest run --workspace --no-fail-fast -- --skip rpc_snapshot_test_ - cargo test --package forest-filecoin --lib rpc_snapshot_test_ + cargo nextest run --workspace --no-fail-fast + # nextest doesn't run doctests https://github.com/nextest-rs/nextest/issues/16 # see also lib.rs::doctest_private cargo test --doc --features doctest-private test-release: - cargo nextest run --cargo-profile quick --workspace --no-fail-fast -- --skip rpc_snapshot_test_ - cargo test --package forest-filecoin --profile quick --lib rpc_snapshot_test_ + cargo nextest run --cargo-profile quick --workspace --no-fail-fast test-all: test test-release From d1c270f55c884d6886bbb26920eb55438fbeed45 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 25 Aug 2025 17:41:37 +0800 Subject: [PATCH 06/12] fix nextest config --- .config/nextest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index 0ed0952fa6a2..2d8d6bf6affa 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -38,6 +38,6 @@ slow-timeout = { period = "120s", terminate-after = 3 } # There might be some network issues, so we allow some retries with backoff. # Jitter is enabled to avoid [thundering herd issues](https://en.wikipedia.org/wiki/Thundering_herd_problem). [[profile.default.overrides]] -filter = 'test(rpc_test_)' +filter = 'test(rpc_snapshot_test_)' slow-timeout = { period = "120s", terminate-after = 3 } retries = { backoff = "exponential", count = 4, delay = "5s", jitter = true } From d1bf0fcfab8b1d750350ad06c5f67c2a6bf9dbaa Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 25 Aug 2025 18:07:31 +0800 Subject: [PATCH 07/12] fix cache path --- .github/workflows/unit-tests.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 6aa2a593a735..48fc4a3c2b64 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -42,11 +42,6 @@ jobs: steps: - name: Checkout Sources uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: ~/.cache/forest/test/rpc-snapshots - key: rpcsnap-${{ hashFiles('~/.cache/forest/test/rpc-snapshots/**') }} - enableCrossOsArchive: true - name: Setup sccache uses: mozilla-actions/sccache-action@v0.0.9 timeout-minutes: ${{ fromJSON(env.CACHE_TIMEOUT_MINUTES) }} @@ -71,8 +66,8 @@ jobs: uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: ~/.cache/forest/test/rpc-snapshots - key: rpcsnap-${{ hashFiles('~/.cache/forest/test/rpc-snapshots/**') }} + path: /home/runner/.cache/forest/test/rpc-snapshots + key: rpcsnap-${{ hashFiles('/home/runner/.cache/forest/test/rpc-snapshots/**') }} enableCrossOsArchive: true - name: Setup sccache uses: mozilla-actions/sccache-action@v0.0.9 @@ -87,3 +82,4 @@ jobs: env: # To minimize compile times: https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times RUSTFLAGS: "-C linker=clang -C link-arg=-fuse-ld=lld" + - run: ls -lhR /home/runner/.cache/forest/test/rpc-snapshots \ No newline at end of file From cf76ac20e5213c33eaa41f7e30a241b5d4f66228 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 25 Aug 2025 18:14:03 +0800 Subject: [PATCH 08/12] yml fmt --- .github/workflows/unit-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 48fc4a3c2b64..a90e241cb015 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -67,7 +67,7 @@ jobs: - uses: actions/cache@v4 with: path: /home/runner/.cache/forest/test/rpc-snapshots - key: rpcsnap-${{ hashFiles('/home/runner/.cache/forest/test/rpc-snapshots/**') }} + key: rpcsnap-${{ hashFiles('/home/runner/.cache/forest/test/rpc-snapshots/**/*') }} enableCrossOsArchive: true - name: Setup sccache uses: mozilla-actions/sccache-action@v0.0.9 @@ -82,4 +82,4 @@ jobs: env: # To minimize compile times: https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times RUSTFLAGS: "-C linker=clang -C link-arg=-fuse-ld=lld" - - run: ls -lhR /home/runner/.cache/forest/test/rpc-snapshots \ No newline at end of file + - run: ls -lhR /home/runner/.cache/forest/test/rpc-snapshots From 0f351a1a81818c2c2027f927e9e75a56648bd5cd Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 25 Aug 2025 19:12:16 +0800 Subject: [PATCH 09/12] fix cache key --- .github/workflows/unit-tests.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index a90e241cb015..5b382ca63bff 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -64,10 +64,11 @@ jobs: continue-on-error: true - name: Checkout Sources uses: actions/checkout@v4 - - uses: actions/cache@v4 + - uses: actions/cache/restore@v4 with: - path: /home/runner/.cache/forest/test/rpc-snapshots - key: rpcsnap-${{ hashFiles('/home/runner/.cache/forest/test/rpc-snapshots/**/*') }} + path: | + /home/runner/.cache/forest/test/rpc-snapshots/rpc_test + key: rpcsnap- enableCrossOsArchive: true - name: Setup sccache uses: mozilla-actions/sccache-action@v0.0.9 @@ -82,4 +83,14 @@ jobs: env: # To minimize compile times: https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times RUSTFLAGS: "-C linker=clang -C link-arg=-fuse-ld=lld" - - run: ls -lhR /home/runner/.cache/forest/test/rpc-snapshots + - id: get-hash + run: | + ls -lhR ~/.cache/forest/test/rpc-snapshots/rpc_test/* + echo "hash=$(openssl md5 ~/.cache/forest/test/rpc-snapshots/rpc_test/* | sort | openssl md5 | cut -d ' ' -f 2)" >> $GITHUB_OUTPUT + shell: bash + - uses: actions/cache/restore@v4 + with: + path: | + /home/runner/.cache/forest/test/rpc-snapshots/rpc_test + key: rpcsnap-${{ steps.get-hash.outputs.hash }} + enableCrossOsArchive: true From d472ae82836496f7677cc45ce99316dab6e73125 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 25 Aug 2025 19:12:52 +0800 Subject: [PATCH 10/12] enable for draft for testing --- .config/nextest.toml | 2 +- .github/workflows/unit-tests.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index 2d8d6bf6affa..11d1a92cc3e9 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -40,4 +40,4 @@ slow-timeout = { period = "120s", terminate-after = 3 } [[profile.default.overrides]] filter = 'test(rpc_snapshot_test_)' slow-timeout = { period = "120s", terminate-after = 3 } -retries = { backoff = "exponential", count = 4, delay = "5s", jitter = true } +retries = { backoff = "exponential", count = 3, delay = "5s", jitter = true } diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 5b382ca63bff..39ccaca3d1f8 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -56,7 +56,7 @@ jobs: runs-on: ubuntu-24.04-arm # Run the job only if the PR is not a draft. # This is done to limit the runner cost. - if: github.event.pull_request.draft == false + # if: github.event.pull_request.draft == false steps: # find the nearest S3 space for storing cache files - name: Show IP @@ -83,14 +83,14 @@ jobs: env: # To minimize compile times: https://nnethercote.github.io/perf-book/build-configuration.html#minimizing-compile-times RUSTFLAGS: "-C linker=clang -C link-arg=-fuse-ld=lld" - - id: get-hash + - id: get-cache-hash run: | ls -lhR ~/.cache/forest/test/rpc-snapshots/rpc_test/* echo "hash=$(openssl md5 ~/.cache/forest/test/rpc-snapshots/rpc_test/* | sort | openssl md5 | cut -d ' ' -f 2)" >> $GITHUB_OUTPUT shell: bash - - uses: actions/cache/restore@v4 + - uses: actions/cache/save@v4 with: path: | /home/runner/.cache/forest/test/rpc-snapshots/rpc_test - key: rpcsnap-${{ steps.get-hash.outputs.hash }} + key: rpcsnap-${{ steps.get-cache-hash.outputs.hash }} enableCrossOsArchive: true From 38bd144b4573bda3a8f273e243282a6594f3ad4f Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 25 Aug 2025 21:25:24 +0800 Subject: [PATCH 11/12] revert --- .github/workflows/unit-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 39ccaca3d1f8..e884b9824a45 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -56,7 +56,7 @@ jobs: runs-on: ubuntu-24.04-arm # Run the job only if the PR is not a draft. # This is done to limit the runner cost. - # if: github.event.pull_request.draft == false + if: github.event.pull_request.draft == false steps: # find the nearest S3 space for storing cache files - name: Show IP From fa8478011071b4c65e131e7cae05e3a8a12b3cf2 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Mon, 25 Aug 2025 22:13:11 +0800 Subject: [PATCH 12/12] apply AI comments --- .github/workflows/unit-tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index e884b9824a45..7f9ff7518516 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -68,6 +68,7 @@ jobs: with: path: | /home/runner/.cache/forest/test/rpc-snapshots/rpc_test + # Broad key + prefix-based restore so the latest rpcsnap- is picked up. key: rpcsnap- enableCrossOsArchive: true - name: Setup sccache