From 85e735797366b7272cd36cd81b7fd5aff8418d86 Mon Sep 17 00:00:00 2001 From: jif-oai Date: Fri, 10 Oct 2025 14:57:47 +0100 Subject: [PATCH] fix: workflow cache (#5050) Decouple cache saving to fix the `verify` steps never being run due to a cache saving issue --- .github/workflows/rust-ci.yml | 42 +++++++++++++++++++++-- codex-rs/core/tests/suite/unified_exec.rs | 2 +- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml index 846408f3..cbf62f72 100644 --- a/.github/workflows/rust-ci.yml +++ b/.github/workflows/rust-ci.yml @@ -148,15 +148,26 @@ jobs: targets: ${{ matrix.target }} components: clippy - - uses: actions/cache@v4 + # Explicit cache restore: split cargo home vs target, so we can + # avoid caching the large target dir on the gnu-dev job. + - name: Restore cargo home cache + id: cache_cargo_home_restore + uses: actions/cache/restore@v4 with: path: | ~/.cargo/bin/ ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ - ${{ github.workspace }}/codex-rs/target/ - key: cargo-${{ matrix.runner }}-${{ matrix.target }}-${{ matrix.profile }}-${{ hashFiles('**/Cargo.lock') }} + key: cargo-home-${{ matrix.runner }}-${{ matrix.target }}-${{ matrix.profile }}-${{ hashFiles('**/Cargo.lock') }} + + - name: Restore target cache (except gnu-dev) + id: cache_target_restore + if: ${{ !(matrix.target == 'x86_64-unknown-linux-gnu' && matrix.profile != 'release') }} + uses: actions/cache/restore@v4 + with: + path: ${{ github.workspace }}/codex-rs/target/ + key: cargo-target-${{ matrix.runner }}-${{ matrix.target }}-${{ matrix.profile }}-${{ hashFiles('**/Cargo.lock') }} - if: ${{ matrix.target == 'x86_64-unknown-linux-musl' || matrix.target == 'aarch64-unknown-linux-musl'}} name: Install musl build tools @@ -194,6 +205,31 @@ jobs: env: RUST_BACKTRACE: 1 + # Save caches explicitly; make non-fatal so cache packaging + # never fails the overall job. Only save when key wasn't hit. + - name: Save cargo home cache + if: always() && !cancelled() && steps.cache_cargo_home_restore.outputs.cache-hit != 'true' + continue-on-error: true + uses: actions/cache/save@v4 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + key: cargo-home-${{ matrix.runner }}-${{ matrix.target }}-${{ matrix.profile }}-${{ hashFiles('**/Cargo.lock') }} + + - name: Save target cache (except gnu-dev) + if: >- + always() && !cancelled() && + (steps.cache_target_restore.outputs.cache-hit != 'true') && + !(matrix.target == 'x86_64-unknown-linux-gnu' && matrix.profile != 'release') + continue-on-error: true + uses: actions/cache/save@v4 + with: + path: ${{ github.workspace }}/codex-rs/target/ + key: cargo-target-${{ matrix.runner }}-${{ matrix.target }}-${{ matrix.profile }}-${{ hashFiles('**/Cargo.lock') }} + # Fail the job if any of the previous steps failed. - name: verify all steps passed if: | diff --git a/codex-rs/core/tests/suite/unified_exec.rs b/codex-rs/core/tests/suite/unified_exec.rs index b8c0fadb..cfa96dd7 100644 --- a/codex-rs/core/tests/suite/unified_exec.rs +++ b/codex-rs/core/tests/suite/unified_exec.rs @@ -213,7 +213,7 @@ PY let second_args = serde_json::json!({ "input": Vec::::new(), "session_id": "0", - "timeout_ms": 800, + "timeout_ms": 2_000, }); let responses = vec![