RSpec Integration with CI Insights
Report your test results from RSpec to CI Insights
This guide explains how to integrate RSpec with CI Insights using the
rspec-mergify gem. Once installed, test results are automatically uploaded to
CI Insights without any extra workflow changes.
Installation
Section titled InstallationYou need to install the
rspec-mergify gem to automatically
upload your test results to CI Insights.
Gemfile
Section titled GemfileAdd the gem to your Gemfile:
group :test do gem 'rspec-mergify'endThen run:
bundle installGem Install
Section titled Gem InstallAlternatively, install it directly:
gem install rspec-mergifyModify Your Workflow
Section titled Modify Your WorkflowYour workflow should run your tests as usual while exporting the secret
MERGIFY_TOKEN as an environment variable. You’ll need to add the following
code to the GitHub Actions step running your tests:
env: MERGIFY_TOKEN: ${{ secrets.MERGIFY_TOKEN }}For example:
- name: Run RSpec Tests 🧪 env: MERGIFY_TOKEN: ${{ secrets.MERGIFY_TOKEN }} run: bundle exec rspecThe gem automatically collects your test results and sends them to CI Insights.
Check the CI Insights dashboard afterward to view execution metrics, detect flaky tests, and gather actionable feedback.
Environment Variables
Section titled Environment Variables| Variable | Purpose | Default |
|---|---|---|
MERGIFY_TOKEN | API authentication token | Required |
MERGIFY_API_URL | API endpoint location | https://api.mergify.com |
RSPEC_MERGIFY_ENABLE | Force-enable outside CI | false |
RSPEC_MERGIFY_DEBUG | Print spans to console | false |
MERGIFY_TRACEPARENT | W3C distributed trace context | Optional |
MERGIFY_TEST_JOB_NAME | Test job name identifier | Optional |
Alternative: Manual JUnit XML Upload
Section titled Alternative: Manual JUnit XML UploadIf you prefer not to use the rspec-mergify gem, you can manually generate
JUnit XML reports and upload them using the Mergify CI action.
Generate a JUnit Report
Section titled Generate a JUnit ReportInstall the JUnit formatter gem:
# Gemfilegroup :test do gem 'rspec-junit-formatter'endConfigure RSpec to output JUnit reports in your .rspec file:
--format RspecJunitFormatter--out junit.xmlUpload with GitHub Actions
Section titled Upload with GitHub Actions- name: Run RSpec Tests continue-on-error: true run: bundle exec rspec --format RspecJunitFormatter --out junit.xml
- name: Upload test results to Mergify if: success() || failure() uses: mergifyio/gha-mergify-ci@v14 with: token: ${{ secrets.MERGIFY_TOKEN }} report_path: "junit.xml"Was this page helpful?
Thanks for your feedback!