Skip to content

Commit 9ad47f3

Browse files
dguidoclaude
andcommitted
Use idiomatic uv run approach in CI
Instead of adding .venv/bin to PATH (a hack), properly use uv's designed approach: 1. CI sets UV_RUN="uv run" environment variable 2. Test scripts source ci_test_common.sh which wraps commands 3. Commands are executed with $RUN prefix (uv run in CI, empty locally) This approach: - Is idiomatic for uv (explicit environment management) - Works in CI with uv run prefix - Works locally without prefix when venv is activated - Maintains backward compatibility for local development The wrapper functions in ci_test_common.sh ensure all slither commands and tools work correctly in both environments. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent f36545e commit 9ad47f3

25 files changed

+134
-17
lines changed

.github/scripts/integration_test_runner.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#!/usr/bin/env bash
22

3+
# Use UV_RUN if set (for CI), otherwise run directly (for local dev)
4+
RUN="${UV_RUN:-}"
5+
36
# used to pass --cov=$path and --cov-append to pytest
47
if [ "$1" != "" ]; then
5-
pytest "$1" tests/e2e/ -n auto
8+
$RUN pytest "$1" tests/e2e/ -n auto
69
status_code=$?
7-
python -m coverage report
10+
$RUN python -m coverage report
811
else
9-
pytest tests/e2e/ -n auto
12+
$RUN pytest tests/e2e/ -n auto
1013
status_code=$?
1114
fi
1215

.github/scripts/tool_test_runner.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#!/usr/bin/env bash
22

3+
# Use UV_RUN if set (for CI), otherwise run directly (for local dev)
4+
RUN="${UV_RUN:-}"
5+
36
# used to pass --cov=$path and --cov-append to pytest
47
if [ "$1" != "" ]; then
5-
pytest "$1" tests/tools
8+
$RUN pytest "$1" tests/tools
69
status_code=$?
7-
python -m coverage report
10+
$RUN python -m coverage report
811
else
9-
pytest tests/tools
12+
$RUN pytest tests/tools
1013
status_code=$?
1114
fi
1215

.github/scripts/unit_test_runner.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#!/usr/bin/env bash
22

3+
# Use UV_RUN if set (for CI), otherwise run directly (for local dev)
4+
RUN="${UV_RUN:-}"
5+
36
# used to pass --cov=$path and --cov-append to pytest
47
if [ "$1" != "" ]; then
5-
pytest "$1" tests/unit/ -n auto
8+
$RUN pytest "$1" tests/unit/ -n auto
69
status_code=$?
7-
python -m coverage report
10+
$RUN python -m coverage report
811
else
9-
pytest tests/unit/ -n auto
12+
$RUN pytest tests/unit/ -n auto
1013
status_code=$?
1114
fi
1215

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ jobs:
5858
run: |
5959
pip install uv
6060
uv sync --group dev
61-
# Add venv to PATH so scripts can find slither commands
62-
echo "$PWD/.venv/bin" >> $GITHUB_PATH
6361
uv run solc-select use 0.4.25 --always-install
6462
uv run solc-select use 0.8.0 --always-install
6563
uv run solc-select use 0.5.1 --always-install
@@ -79,5 +77,7 @@ jobs:
7977
PYTHONUTF8: 1
8078
TEST_TYPE: ${{ matrix.type }}
8179
GITHUB_ETHERSCAN: ${{ secrets.GITHUB_ETHERSCAN }}
80+
# Export UV_RUN to use in scripts
81+
UV_RUN: "uv run"
8282
run: |
8383
bash "scripts/ci_test_${TEST_TYPE}.sh"

.github/workflows/docs.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ jobs:
3737
- run: |
3838
pip install uv
3939
uv sync --group dev
40-
# Add venv to PATH so pdoc can be found
41-
echo "$PWD/.venv/bin" >> $GITHUB_PATH
42-
- run: pdoc -o html/ slither '!slither.tools' # TODO fix import errors on pdoc run
40+
- run: uv run pdoc -o html/ slither '!slither.tools' # TODO fix import errors on pdoc run
4341
- name: Upload artifact
4442
uses: actions/upload-pages-artifact@v4
4543
with:

.github/workflows/test.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ jobs:
4343
run: |
4444
pip install uv
4545
uv sync --group dev
46-
# Add venv to PATH so tests can find slither commands
47-
echo "$PWD/.venv/bin" >> $GITHUB_PATH
4846
4947
- name: Setup node
5048
uses: actions/setup-node@v4
@@ -91,7 +89,7 @@ jobs:
9189
elif [ ${{ matrix.os }} = "windows-2025" ]; then
9290
TEST_ARGS=()
9391
fi
94-
bash "./.github/scripts/${TEST_TYPE}_test_runner.sh" "${TEST_ARGS[@]}"
92+
UV_RUN="uv run" bash "./.github/scripts/${TEST_TYPE}_test_runner.sh" "${TEST_ARGS[@]}"
9593
9694
9795
- name: Upload coverage

scripts/ci_test_cli.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
### Test
44

5+
# Source common CI test setup
6+
source "$(dirname "$0")/ci_test_common.sh"
7+
58
solc-select use 0.7.0
69

710
if ! slither "tests/e2e/config/test_json_config/test.sol" --solc-ast --no-fail-pedantic; then

scripts/ci_test_common.sh

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#!/usr/bin/env bash
2+
3+
# Common setup for CI test scripts
4+
# Use UV_RUN if set (for CI), otherwise run directly (for local dev)
5+
RUN="${UV_RUN:-}"
6+
7+
# Export wrapper functions for commonly used commands
8+
slither() {
9+
$RUN slither "$@"
10+
}
11+
12+
slither-check-upgradeability() {
13+
$RUN slither-check-upgradeability "$@"
14+
}
15+
16+
slither-check-kspec() {
17+
$RUN slither-check-kspec "$@"
18+
}
19+
20+
slither-check-erc() {
21+
$RUN slither-check-erc "$@"
22+
}
23+
24+
slither-flat() {
25+
$RUN slither-flat "$@"
26+
}
27+
28+
slither-simil() {
29+
$RUN slither-simil "$@"
30+
}
31+
32+
slither-interface() {
33+
$RUN slither-interface "$@"
34+
}
35+
36+
slither-find-paths() {
37+
$RUN slither-find-paths "$@"
38+
}
39+
40+
slither-prop() {
41+
$RUN slither-prop "$@"
42+
}
43+
44+
solc-select() {
45+
$RUN solc-select "$@"
46+
}
47+
48+
# Export the functions
49+
export -f slither
50+
export -f slither-check-upgradeability
51+
export -f slither-check-kspec
52+
export -f slither-check-erc
53+
export -f slither-flat
54+
export -f slither-simil
55+
export -f slither-interface
56+
export -f slither-find-paths
57+
export -f slither-prop
58+
export -f solc-select

scripts/ci_test_dapp.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env bash
22

3+
# Source common CI test setup
4+
source "$(dirname "$0")/ci_test_common.sh"
5+
36
### Test Dapp integration
47

58
# work around having two python versions loading libraries from each other in CI

scripts/ci_test_data_dependency.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/usr/bin/env bash
22

3+
# Source common CI test setup
4+
source "$(dirname "$0")/ci_test_common.sh"
5+
36
### Test data dependency
47

58
if ! python ./examples/scripts/data_dependency.py ./examples/scripts/data_dependency.sol; then

0 commit comments

Comments
 (0)