mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-07-27 22:38:30 +08:00
* Add workload identity federation support to base-action Move the workload identity module into base-action so the standalone action can fetch and refresh the GitHub OIDC identity token itself, and expose the same federation inputs as the outer action. Switch the base-action test workflows from the anthropic_api_key secret to the federation repo variables and grant them id-token: write. * Verify MCP test tool invocation instead of init connection status MCP servers can connect asynchronously, so the init event may report a server as pending. Check that the server is registered at init, then assert the test tool was actually called and returned its response. Also pass the MCP config through claude_args --mcp-config, replacing the removed mcp_config input.
130 lines
4.3 KiB
YAML
130 lines
4.3 KiB
YAML
name: Test Claude Code Action
|
|
|
|
on:
|
|
pull_request:
|
|
workflow_dispatch:
|
|
inputs:
|
|
test_prompt:
|
|
description: "Test prompt for Claude"
|
|
required: false
|
|
default: "List the files in the current directory starting with 'package'"
|
|
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-inline-prompt:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
|
|
- name: Test with inline prompt
|
|
id: inline-test
|
|
uses: ./base-action
|
|
with:
|
|
prompt: ${{ github.event.inputs.test_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 }}
|
|
allowed_tools: "LS,Read"
|
|
|
|
- name: Verify inline prompt output
|
|
run: |
|
|
OUTPUT_FILE="${{ steps.inline-test.outputs.execution_file }}"
|
|
CONCLUSION="${{ steps.inline-test.outputs.conclusion }}"
|
|
|
|
echo "Conclusion: $CONCLUSION"
|
|
echo "Output file: $OUTPUT_FILE"
|
|
|
|
if [ "$CONCLUSION" = "success" ]; then
|
|
echo "✅ Action completed successfully"
|
|
else
|
|
echo "❌ Action failed"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -f "$OUTPUT_FILE" ]; then
|
|
if [ -s "$OUTPUT_FILE" ]; then
|
|
echo "✅ Execution log file created successfully with content"
|
|
echo "Validating JSON format:"
|
|
if jq . "$OUTPUT_FILE" > /dev/null 2>&1; then
|
|
echo "✅ Output is valid JSON"
|
|
echo "Content preview:"
|
|
head -c 200 "$OUTPUT_FILE"
|
|
else
|
|
echo "❌ Output is not valid JSON"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "❌ Execution log file is empty"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "❌ Execution log file not found"
|
|
exit 1
|
|
fi
|
|
|
|
test-prompt-file:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
|
|
|
- name: Create test prompt file
|
|
run: |
|
|
cat > test-prompt.txt << EOF
|
|
${PROMPT}
|
|
EOF
|
|
env:
|
|
PROMPT: ${{ github.event.inputs.test_prompt || 'List the files in the current directory starting with "package"' }}
|
|
|
|
- name: Test with prompt file and allowed tools
|
|
id: prompt-file-test
|
|
uses: ./base-action
|
|
with:
|
|
prompt_file: "test-prompt.txt"
|
|
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 }}
|
|
allowed_tools: "LS,Read"
|
|
|
|
- name: Verify prompt file output
|
|
run: |
|
|
OUTPUT_FILE="${{ steps.prompt-file-test.outputs.execution_file }}"
|
|
CONCLUSION="${{ steps.prompt-file-test.outputs.conclusion }}"
|
|
|
|
echo "Conclusion: $CONCLUSION"
|
|
echo "Output file: $OUTPUT_FILE"
|
|
|
|
if [ "$CONCLUSION" = "success" ]; then
|
|
echo "✅ Action completed successfully"
|
|
else
|
|
echo "❌ Action failed"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -f "$OUTPUT_FILE" ]; then
|
|
if [ -s "$OUTPUT_FILE" ]; then
|
|
echo "✅ Execution log file created successfully with content"
|
|
echo "Validating JSON format:"
|
|
if jq . "$OUTPUT_FILE" > /dev/null 2>&1; then
|
|
echo "✅ Output is valid JSON"
|
|
echo "Content preview:"
|
|
head -c 200 "$OUTPUT_FILE"
|
|
else
|
|
echo "❌ Output is not valid JSON"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "❌ Execution log file is empty"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "❌ Execution log file not found"
|
|
exit 1
|
|
fi
|