mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-08-22 03:18:54 +08:00
* ci: skip Claude-backed test jobs on fork PRs Jobs that run the action against the Claude API authenticate via workload identity federation, which fork PRs cannot mint an OIDC token for, so they always failed on external contributions. Gate each such job on the PR head repo matching the base repo; push and workflow_dispatch runs are unaffected. No-Verification-Needed: CI workflow config only, exercised by Actions on the PR * test: pin the bare remote's initial branch in fetch-depth test The shallow-clone case created its bare remote with a plain git init, so HEAD pointed at whatever init.defaultBranch resolves to (master on CI) while the test only pushed main. git clone --depth=1 implies --single-branch, and with a dangling remote HEAD it produces an empty, non-shallow clone, so the is-shallow assertion failed on runners whose default branch is not main. No-Verification-Needed: test-only change
99 lines
3.5 KiB
YAML
99 lines
3.5 KiB
YAML
name: Test Custom Executables
|
|
|
|
on:
|
|
pull_request:
|
|
workflow_dispatch:
|
|
workflow_call:
|
|
|
|
# The Claude API is authenticated via workload identity federation: id-token
|
|
# lets the action mint the GitHub OIDC token it exchanges for a short-lived
|
|
# access token. See docs/setup.md.
|
|
permissions:
|
|
contents: read
|
|
id-token: write
|
|
|
|
jobs:
|
|
test-custom-executables:
|
|
# Skip on fork PRs since they can't mint the OIDC token used for Claude API auth
|
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
|
|
- name: Install Bun manually
|
|
run: |
|
|
echo "Installing Bun..."
|
|
curl -fsSL https://bun.sh/install | bash
|
|
echo "Bun installed at: $HOME/.bun/bin/bun"
|
|
|
|
# Verify Bun installation
|
|
if [ -f "$HOME/.bun/bin/bun" ]; then
|
|
echo "✅ Bun executable found"
|
|
$HOME/.bun/bin/bun --version
|
|
else
|
|
echo "❌ Bun executable not found"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Install Claude Code manually
|
|
run: |
|
|
echo "Installing Claude Code..."
|
|
curl -fsSL https://claude.ai/install.sh | bash -s latest
|
|
echo "Claude Code installed at: $HOME/.local/bin/claude"
|
|
|
|
# Verify Claude installation
|
|
if [ -f "$HOME/.local/bin/claude" ]; then
|
|
echo "✅ Claude executable found"
|
|
ls -la "$HOME/.local/bin/claude"
|
|
else
|
|
echo "❌ Claude executable not found"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Test with both custom executables
|
|
id: custom-test
|
|
uses: ./base-action
|
|
with:
|
|
prompt: |
|
|
List the files in the current directory starting with "package"
|
|
anthropic_federation_rule_id: ${{ vars.ANTHROPIC_FEDERATION_RULE_ID }}
|
|
anthropic_organization_id: ${{ vars.ANTHROPIC_ORGANIZATION_ID }}
|
|
anthropic_service_account_id: ${{ vars.ANTHROPIC_SERVICE_ACCOUNT_ID }}
|
|
path_to_claude_code_executable: /home/runner/.local/bin/claude
|
|
path_to_bun_executable: /home/runner/.bun/bin/bun
|
|
claude_args: '--allowedTools "LS,Read"'
|
|
|
|
- name: Verify custom executables worked
|
|
run: |
|
|
OUTPUT_FILE="${{ steps.custom-test.outputs.execution_file }}"
|
|
CONCLUSION="${{ steps.custom-test.outputs.conclusion }}"
|
|
|
|
echo "Conclusion: $CONCLUSION"
|
|
echo "Output file: $OUTPUT_FILE"
|
|
|
|
if [ "$CONCLUSION" = "success" ]; then
|
|
echo "✅ Action completed successfully with both custom executables"
|
|
else
|
|
echo "❌ Action failed with custom executables"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -f "$OUTPUT_FILE" ] && [ -s "$OUTPUT_FILE" ]; then
|
|
echo "✅ Execution log file created successfully"
|
|
if jq . "$OUTPUT_FILE" > /dev/null 2>&1; then
|
|
echo "✅ Output is valid JSON"
|
|
# Verify the task was completed
|
|
if grep -q "package" "$OUTPUT_FILE"; then
|
|
echo "✅ Claude successfully listed package files"
|
|
else
|
|
echo "⚠️ Could not verify if package files were listed"
|
|
fi
|
|
else
|
|
echo "❌ Output is not valid JSON"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "❌ Execution log file not found or empty"
|
|
exit 1
|
|
fi
|