Skip to content

Commit 70ca0a7

Browse files
An ZhongAn Zhong
authored andcommitted
Fix Cargo offline handling in CI tests
1 parent 507b3e7 commit 70ca0a7

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

.github/workflows/test.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ jobs:
1212
test:
1313
name: Test
1414
runs-on: self-hosted
15+
env:
16+
CARGO_HOME: ${{ github.workspace }}/.cargo-home
1517
steps:
1618
- uses: actions/checkout@v4
1719
with:
@@ -22,6 +24,16 @@ jobs:
2224
toolchain: stable
2325
components: rustfmt, clippy
2426
override: true
27+
28+
- name: Cache Cargo Dependencies
29+
uses: actions/cache@v4
30+
with:
31+
path: |
32+
.cargo-home/registry
33+
.cargo-home/git
34+
key: ${{ runner.os }}-cargo-${{ hashFiles('tools/rust-sim-runtime/Cargo.lock') }}
35+
restore-keys: |
36+
${{ runner.os }}-cargo-
2537
2638
- name: Apply Patches
2739
run: |
@@ -34,12 +46,18 @@ jobs:
3446
echo "verilator-hash=$(git rev-parse HEAD:3rd-party/verilator)" >> $GITHUB_OUTPUT
3547
echo "ramulator2-hash=$(git rev-parse HEAD:3rd-party/ramulator2)" >> $GITHUB_OUTPUT
3648
49+
- name: Prefetch Rust Dependencies
50+
run: |
51+
. setup.sh && cargo fetch --manifest-path tools/rust-sim-runtime/Cargo.toml --locked
52+
3753
- name: Build All Components
3854
run: |
3955
echo "Building all components"
4056
. setup.sh && make build-all
4157
4258
- name: Run All Tests
59+
env:
60+
ASSASSYN_CARGO_NET_OFFLINE: "1"
4361
run: |
4462
. setup.sh && make test-all
4563

python/assassyn/utils/__init__.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,8 @@ def _cmd_wrapper(cmd):
8686
os.makedirs(ccache_dir, exist_ok=True)
8787
env['CCACHE_DIR'] = ccache_dir
8888

89-
# In CI / sandboxed runners, network access may be restricted. If tests are
90-
# running, prefer offline to avoid Cargo trying to touch crates.io.
91-
if 'CARGO_NET_OFFLINE' not in env and (
92-
'PYTEST_CURRENT_TEST' in env or env.get('ASSASSYN_CARGO_NET_OFFLINE') == '1'
93-
):
89+
# Only force Cargo offline when CI or the caller opts in explicitly.
90+
if 'CARGO_NET_OFFLINE' not in env and env.get('ASSASSYN_CARGO_NET_OFFLINE') == '1':
9491
env['CARGO_NET_OFFLINE'] = 'true'
9592

9693
return subprocess.check_output(cmd, env=env).decode('utf-8')

0 commit comments

Comments
 (0)