Skip to content

Commit 2c7fe60

Browse files
mldangeloclaude
andcommitted
test: add CI tests for npx fallback without global install
Added test-npx-fallback job that verifies the wrapper works correctly when promptfoo is NOT installed globally. This ensures both code paths are tested: 1. test job: Tests with global promptfoo installation (preferred path) 2. test-npx-fallback job: Tests npx fallback (no global install) The npx fallback job runs on a subset of configurations (Python 3.10 and 3.12 on all three OS platforms) to verify the fallback works cross-platform without making CI too slow. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent ac708ba commit 2c7fe60

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

.github/workflows/test.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,41 @@ jobs:
9797
- name: Test Node.js detection
9898
run: uv run python -c "from promptfoo.cli import check_node_installed, check_npx_installed; assert check_node_installed(); assert check_npx_installed()"
9999

100+
test-npx-fallback:
101+
name: Test npx fallback (Python ${{ matrix.python-version }} on ${{ matrix.os }})
102+
runs-on: ${{ matrix.os }}
103+
timeout-minutes: 15
104+
strategy:
105+
matrix:
106+
# Test a subset of configurations to verify npx fallback works
107+
os: [ubuntu-latest, macos-latest, windows-latest]
108+
python-version: ["3.10", "3.12"]
109+
steps:
110+
- uses: actions/checkout@v6
111+
112+
- uses: actions/setup-node@v6
113+
with:
114+
node-version: "24"
115+
116+
# Intentionally skip installing promptfoo globally
117+
# This tests the npx fallback path
118+
119+
- uses: astral-sh/setup-uv@v7
120+
with:
121+
enable-cache: true
122+
123+
- name: Pin Python version
124+
run: uv python pin ${{ matrix.python-version }}
125+
126+
- name: Install package
127+
run: uv sync
128+
129+
- name: Test CLI fallback to npx (no global install)
130+
run: uv run promptfoo --version
131+
132+
- name: Test Node.js detection
133+
run: uv run python -c "from promptfoo.cli import check_node_installed, check_npx_installed; assert check_node_installed(); assert check_npx_installed()"
134+
100135
build:
101136
name: Build Package
102137
runs-on: ubuntu-latest
@@ -122,7 +157,7 @@ jobs:
122157

123158
ci-success:
124159
name: CI Success
125-
needs: [lint, type-check, test, build]
160+
needs: [lint, type-check, test, test-npx-fallback, build]
126161
if: always()
127162
runs-on: ubuntu-latest
128163
steps:
@@ -131,17 +166,20 @@ jobs:
131166
LINT_RESULT="${{ needs.lint.result }}"
132167
TYPE_CHECK_RESULT="${{ needs.type-check.result }}"
133168
TEST_RESULT="${{ needs.test.result }}"
169+
TEST_NPX_FALLBACK_RESULT="${{ needs.test-npx-fallback.result }}"
134170
BUILD_RESULT="${{ needs.build.result }}"
135171
136172
echo "Job results:"
137173
echo " lint: $LINT_RESULT"
138174
echo " type-check: $TYPE_CHECK_RESULT"
139175
echo " test: $TEST_RESULT"
176+
echo " test-npx-fallback: $TEST_NPX_FALLBACK_RESULT"
140177
echo " build: $BUILD_RESULT"
141178
142179
if [[ "$LINT_RESULT" == "failure" || "$LINT_RESULT" == "cancelled" ||
143180
"$TYPE_CHECK_RESULT" == "failure" || "$TYPE_CHECK_RESULT" == "cancelled" ||
144181
"$TEST_RESULT" == "failure" || "$TEST_RESULT" == "cancelled" ||
182+
"$TEST_NPX_FALLBACK_RESULT" == "failure" || "$TEST_NPX_FALLBACK_RESULT" == "cancelled" ||
145183
"$BUILD_RESULT" == "failure" || "$BUILD_RESULT" == "cancelled" ]]; then
146184
echo "Some CI checks failed!"
147185
exit 1

0 commit comments

Comments
 (0)