Skip to content
check-square

GitHub Action

Rspec reporter

v1.1.1 Latest version

Rspec reporter

check-square

Rspec reporter

Report Rspec result on Pull Request comment

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Rspec reporter

uses: xi-jjun/[email protected]

Learn more about this action in xi-jjun/rspec-reporter

Choose a version

Rspec Reporter action

This is rspec result reporter.
You can easily report on your pull request comment only if rspec is failed.

⚠︎ Prerequisites

You need to generate github token for using this actions. (see GitHub Docs)

  • “Issues” repository permissions (read & write)
  • “Pull requests” repository permissions (read & write)

Inputs

filepath

  • filepath is rspec result filepath.
  • REQUIRED
  • Your rspec result file must be in JSON format. Please generate the rspec result in JSON format.

report-mode

  • report-mode provides information on how you want your RSpec results to be reported in pull request comments.
  • NOT REQUIRED
  • mode option
    • default : Report all files in your project. This is default value.
    • onlyPRFiles : Report only in pull request ruby files. If product.rb or product_spec.rb file is in your PR, then report only product_spec.rb result.

Outputs

There is no output here.

Example usage

Common - Permissions

You should declare permissions if you want to use my action script.

name: "Run Rails Rspec"
on:
  ...
jobs:
  run-rspec:
    runs-on: ubuntu-latest

    services:
      ...

    # Add this permission to allow the role to comment on pull requests.
    permissions:
      issues: write
      pull-requests: write
    ...

default mode example

    ...
    steps:
      - name: ...
      
      # Run rspec and output the results in a JSON file. (Only JSON format is valid)
      - name: Run rspec and make rspec_result.json file
        run: |
          mkdir -p tmp
          bundle exec rspec . --format j --out tmp/rspec_result.json

      - name: Add rspec failure result on Pull Request comment
        if: failure() # Generate a report in pull request comment when rspec is failed.
        uses: xi-jjun/[email protected]
        with:
          filepath: 'tmp/rspec_result.json'
          report-mode: 'default' # optional. default value is 'default'.
        env:
          # Set the GitHub token that you generated earlier.
          GITHUB_TOKEN: ${{ secrets.CREATE_ISSUE_GITHUB_TOKEN }} 

onlyPRFiles mode example

    ...
    steps:
      - name: ...
      
      # Run rspec and output the results in a JSON file. (Only JSON format is valid)
      - name: Run rspec and make rspec_result.json file
        run: |
          mkdir -p tmp
          bundle exec rspec . --format j --out tmp/rspec_result.json

      - name: Add rspec failure result on Pull Request comment
        if: failure() # Generate a report in pull request comment when rspec is failed.
        uses: xi-jjun/[email protected]
        with:
          filepath: 'tmp/rspec_result.json'
          report-mode: 'onlyPRFiles' # report only pull request files
        env:
          # Set the GitHub token that you generated earlier.
          GITHUB_TOKEN: ${{ secrets.CREATE_ISSUE_GITHUB_TOKEN }}