Skip to content

Claude Auto Testing Coverage #4

Claude Auto Testing Coverage

Claude Auto Testing Coverage #4

name: Claude Auto Testing Coverage
description: Automatically add unit tests to improve code coverage
on:
schedule:
# Run daily at 05:30 UTC (13:30 Beijing Time)
- cron: '30 5 * * *'
workflow_dispatch:
inputs:
target_module:
description: 'Specific module to add tests (e.g., packages/database, src/services/user)'
required: false
type: string
concurrency:
group: auto-testing
cancel-in-progress: false
jobs:
add-tests:
runs-on: ubuntu-latest
timeout-minutes: 45
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Bun
uses: oven-sh/setup-bun@v2
- name: Install dependencies
run: bun install --frozen-lockfile
- name: Configure Git
run: |
git config --global user.name "claude-bot[bot]"
git config --global user.email "claude-bot[bot]@users.noreply.github.com"
- name: Copy prompts
run: |
mkdir -p /tmp/claude-prompts
cp .claude/prompts/auto-testing.md /tmp/claude-prompts/
cp .claude/prompts/security-rules.md /tmp/claude-prompts/
- name: Run Claude Code for Auto Testing
uses: anthropics/claude-code-action@v1
with:
github_token: ${{ secrets.GH_TOKEN }}
allowed_non_write_users: '*'
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
claude_args: |
--allowedTools "Bash,Read,Edit,Write,Glob,Grep"
--append-system-prompt "$(cat /tmp/claude-prompts/security-rules.md)"
prompt: |
Follow the auto testing guide located at:
```bash
cat /tmp/claude-prompts/auto-testing.md
```
## Task Assignment
${{ inputs.target_module && format('Process the specified module: {0}', inputs.target_module) || 'Automatically select one module from the target directories that needs test coverage' }}
## Environment Information
- Repository: ${{ github.repository }}
- Branch: ${{ github.ref_name }}
- Target Module: ${{ inputs.target_module || 'Auto-select' }}
- Run ID: ${{ github.run_id }}
**Start the auto testing process now.**