This GitHub Action allows you to optimize Rails tests via TestProf and Claude AI.
The action performs the given test file profiling and refactors it to speed up the execution (using let_it_be
and before_all
helpers from TestProf). It opens a PR and shares the refactoring progress as it executes.
Configured testing environment. This action runs your tests during the refactoring (to verify the correctness), so you must configure it as for regular tests.
GitHub token permissions. This action uses the default GITHUB_TOKEN
provided by GitHub Actions. You must configure its permissions (Settings -> Actions -> Workflow permissions): enable "Read and write permissions" and "Allow GitHub Actions to create and approve pull requests".
issue-number
or test-file-path
must be specified.bundle exec rspec
): Command to execute a test file.We suggest to use GitHub Issues to initiate refactoring tasks. Here is an example workflow:
name: TestProf AI
on:
issues:
types: [labeled]
jobs:
optimize:
# IMPORTANT: Only run this workflow for explicitly labeled issues
if: github.event.label.name == 'test-prof'
runs-on: ubuntu-latest
env:
RAILS_ENV: test
# ... here goes your environment setup
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Prepare app
run: |
bundle exec rails db:test:prepare
- name: Run TestProf AI
uses: test-prof/test-prof-aiptimize-action@main
with:
api-key: ${{ secrets.CLAUDE_API_KEY }}
issue-number: ${{ github.event.issue.number }}
Here is also an example issue template.