Skip to content

Commit 986f9a7

Browse files
Phlogistiqueclaude
andauthored
Add GitHub Actions workflow to run tests on pull requests (#11)
* Add GitHub Actions workflow to run tests on pull requests Run unit tests and e2e tests automatically when a PR is opened or updated. E2E tests only run on PRs from the same repository (not forks) since they require GitHub App credentials. * Refactor e2e tests workflow to run directly in GHA The .claude/run-e2e-tests.sh script was designed for Claude Code environment which requires installing gh CLI. In GitHub Actions, gh is pre-installed. Now the workflow directly: - Generates the GitHub App token using the Python script - Sets up gh authentication - Runs the e2e tests This avoids unnecessary gh installation and keeps the Claude-specific script separate from CI. * Simplify e2e tests workflow by merging shell steps Combine token generation, gh auth setup, and test execution into a single step to avoid step dependencies with inputs/outputs. * Move get_github_app_token.py to tests directory The script is shared test infrastructure used by both Claude Code and GitHub Actions, so it belongs in tests/ rather than .claude/. * Use vars.GH_APP_ID instead of secrets (App ID is public) --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent b31ace1 commit 986f9a7

3 files changed

Lines changed: 40 additions & 1 deletion

File tree

.claude/run-e2e-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ acquire_token() {
6969
fi
7070

7171
# Generate token using the Python script
72-
if ! uv run "$SCRIPT_DIR/get_github_app_token.py" > "$TOKEN_FILE" 2>/dev/null; then
72+
if ! uv run "$PROJECT_ROOT/tests/get_github_app_token.py" > "$TOKEN_FILE" 2>/dev/null; then
7373
log_error "Failed to generate GitHub App token"
7474
return 1
7575
fi

.github/workflows/tests.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Tests
2+
3+
on:
4+
pull_request:
5+
branches: ['*']
6+
7+
jobs:
8+
unit-tests:
9+
name: Unit Tests
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout repository
13+
uses: actions/checkout@v4
14+
15+
- name: Run unit tests
16+
run: bash tests/test_update_pr_stack.sh
17+
18+
e2e-tests:
19+
name: E2E Tests
20+
runs-on: ubuntu-latest
21+
# Only run if secrets are available (not available on forks)
22+
if: github.event.pull_request.head.repo.full_name == github.repository
23+
steps:
24+
- name: Checkout repository
25+
uses: actions/checkout@v4
26+
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v4
29+
with:
30+
version: "latest"
31+
32+
- name: Run e2e tests
33+
env:
34+
GH_APP_ID: ${{ vars.GH_APP_ID }}
35+
GH_APP_PRIVATE_KEY_PEM_B64: ${{ secrets.GH_APP_PRIVATE_KEY_PEM_B64 }}
36+
run: |
37+
export GH_TOKEN=$(uv run tests/get_github_app_token.py)
38+
gh auth setup-git
39+
bash tests/test_e2e.sh

0 commit comments

Comments
 (0)