claude-code-action/.github/workflows/test-custom-executables.yml
Ashwin Bhat 420335da51
Add workload identity federation support to base-action (#1378)
* 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.
2026-06-02 11:52:23 -07:00

97 lines
3.2 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:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- 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
allowed_tools: "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