From 3e8d72c8c6164680ad3201dee57c440fb6d1b9a5 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 25 Dec 2025 10:20:31 +0000 Subject: [PATCH 1/5] 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. --- .github/workflows/tests.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..948f16e --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,36 @@ +name: Tests + +on: + pull_request: + branches: ['*'] + +jobs: + unit-tests: + name: Unit Tests + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Run unit tests + run: bash tests/test_update_pr_stack.sh + + e2e-tests: + name: E2E Tests + runs-on: ubuntu-latest + # Only run if secrets are available (not available on forks) + if: github.event.pull_request.head.repo.full_name == github.repository + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install uv + uses: astral-sh/setup-uv@v4 + with: + version: "latest" + + - name: Run e2e tests + env: + GH_APP_ID: ${{ secrets.GH_APP_ID }} + GH_APP_PRIVATE_KEY_PEM_B64: ${{ secrets.GH_APP_PRIVATE_KEY_PEM_B64 }} + run: bash .claude/run-e2e-tests.sh From 04e56c5b06f6a293688ee66cad5ace4e958dc368 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 25 Dec 2025 10:26:03 +0000 Subject: [PATCH 2/5] 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. --- .github/workflows/tests.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 948f16e..6e69cc1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,8 +29,22 @@ jobs: with: version: "latest" - - name: Run e2e tests + - name: Generate GitHub App token + id: app-token env: GH_APP_ID: ${{ secrets.GH_APP_ID }} GH_APP_PRIVATE_KEY_PEM_B64: ${{ secrets.GH_APP_PRIVATE_KEY_PEM_B64 }} - run: bash .claude/run-e2e-tests.sh + run: | + TOKEN=$(uv run .claude/get_github_app_token.py) + echo "::add-mask::$TOKEN" + echo "token=$TOKEN" >> "$GITHUB_OUTPUT" + + - name: Setup gh authentication + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + run: gh auth setup-git + + - name: Run e2e tests + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + run: bash tests/test_e2e.sh From 9767228e1b2e691d9acb19745ec6de5a52ab8c77 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 25 Dec 2025 10:31:22 +0000 Subject: [PATCH 3/5] 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. --- .github/workflows/tests.yml | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6e69cc1..150b397 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,22 +29,11 @@ jobs: with: version: "latest" - - name: Generate GitHub App token - id: app-token + - name: Run e2e tests env: GH_APP_ID: ${{ secrets.GH_APP_ID }} GH_APP_PRIVATE_KEY_PEM_B64: ${{ secrets.GH_APP_PRIVATE_KEY_PEM_B64 }} run: | - TOKEN=$(uv run .claude/get_github_app_token.py) - echo "::add-mask::$TOKEN" - echo "token=$TOKEN" >> "$GITHUB_OUTPUT" - - - name: Setup gh authentication - env: - GH_TOKEN: ${{ steps.app-token.outputs.token }} - run: gh auth setup-git - - - name: Run e2e tests - env: - GH_TOKEN: ${{ steps.app-token.outputs.token }} - run: bash tests/test_e2e.sh + export GH_TOKEN=$(uv run .claude/get_github_app_token.py) + gh auth setup-git + bash tests/test_e2e.sh From c480ad11079ba89304a870df35fe4668ad714c70 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 25 Dec 2025 10:32:03 +0000 Subject: [PATCH 4/5] 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/. --- .claude/run-e2e-tests.sh | 2 +- .github/workflows/tests.yml | 2 +- {.claude => tests}/get_github_app_token.py | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename {.claude => tests}/get_github_app_token.py (100%) diff --git a/.claude/run-e2e-tests.sh b/.claude/run-e2e-tests.sh index b81bf48..444bf11 100755 --- a/.claude/run-e2e-tests.sh +++ b/.claude/run-e2e-tests.sh @@ -69,7 +69,7 @@ acquire_token() { fi # Generate token using the Python script - if ! uv run "$SCRIPT_DIR/get_github_app_token.py" > "$TOKEN_FILE" 2>/dev/null; then + if ! uv run "$PROJECT_ROOT/tests/get_github_app_token.py" > "$TOKEN_FILE" 2>/dev/null; then log_error "Failed to generate GitHub App token" return 1 fi diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 150b397..570bfdc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -34,6 +34,6 @@ jobs: GH_APP_ID: ${{ secrets.GH_APP_ID }} GH_APP_PRIVATE_KEY_PEM_B64: ${{ secrets.GH_APP_PRIVATE_KEY_PEM_B64 }} run: | - export GH_TOKEN=$(uv run .claude/get_github_app_token.py) + export GH_TOKEN=$(uv run tests/get_github_app_token.py) gh auth setup-git bash tests/test_e2e.sh diff --git a/.claude/get_github_app_token.py b/tests/get_github_app_token.py similarity index 100% rename from .claude/get_github_app_token.py rename to tests/get_github_app_token.py From c78c2ea62ae9ea11db1d0967b5b4819b3fb865fb Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 25 Dec 2025 10:38:01 +0000 Subject: [PATCH 5/5] Use vars.GH_APP_ID instead of secrets (App ID is public) --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 570bfdc..bbc3dbe 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -31,7 +31,7 @@ jobs: - name: Run e2e tests env: - GH_APP_ID: ${{ secrets.GH_APP_ID }} + GH_APP_ID: ${{ vars.GH_APP_ID }} GH_APP_PRIVATE_KEY_PEM_B64: ${{ secrets.GH_APP_PRIVATE_KEY_PEM_B64 }} run: | export GH_TOKEN=$(uv run tests/get_github_app_token.py)