Skip to content
Rubocop Linter Action: A GitHub Action to run Rubocop against your code!
Ruby Shell Dockerfile
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github
bin
lib
screenshots
spec
.all-contributorsrc
.gitignore
.rubocop.yml
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
Dockerfile
Gemfile
Gemfile.lock
LICENSE
README.md
action.yml

README.md

Linters Tests Build Changelog Version Number All Contributors

Rubocop Linter Action

A GitHub Action to run Rubocop against your code and create annotations in the GitHub UI.

📄 Introduction

GitHub Actions are an amazing new tool that can dramatically improve productivity while using the GitHub platform. While it is not hard to write a custom GitHub action to run Rubocop on your codebase, this action takes that functionality one step further using the checks API. After the Rubocop Linter Action runs Rubocop against your code, it will create annotations that you can easily view, matched up with the offending code.

Since GitHub actions and the checks API are continually changing, it is possible that there will be breaking API changes that affect this action. If so, please open an issue and I will look into it as soon as I can.

💡 Usage

Add the following to your GitHub action workflow to use Rubocop Linter Action:

- name: Rubocop Linter
  uses: andrewmcodes/rubocop-linter-action@v2.0.0
  with:
    additional_gems: 'rubocop-rails rubocop-performance'
    fail_level: 'warning'
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

It is highly recommend you tie yourself to a version and do not do the following. I promise your life will be much easier. 😇

# ❌ Danger, sometimes I break things!
uses: andrewmcodes/rubocop-linter-action@master

# ✅ Much better.
uses: andrewmcodes/rubocop-linter-action@v2.0.0

📦 Example Workflow

Here is an example workflow file incorporating Rubocop Linter Action:

name: Rubocop

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Rubocop Linter
      uses: andrewmcodes/rubocop-linter-action@v2.0.0
      with:
        additional_gems: 'rubocop-rails rubocop-performance'
        fail_level: 'warning'
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Go here to see more examples!

💰 Available Inputs

Input Parm Name Required Default Value Description Examples of Equivalent Local Commands
bundle false false If you would like to run bundle install on your project instead of gem install bundle install --deployment --jobs 4 --retry 3
version false latest GA Define a later version of rubocop if latest is not needed gem install rubocop -v 0.76.0
additional_gems false Additional Gems can be installed via one line with spaces and commands are supported like a version gem install rubocop-rails rubocop-performance 'rubocop-i18n:2.0.0'
config_path false repo ./ If the config path is another spot in the repo or not named .rubocop.yml rubocop -c .rubocop_config_test.yml
exclude_cops false Define a list of paths to exclude from being linted. rubocop --except 'Style/FrozenStringLiteralComment Style/StringLiterals'
fail_level false 'warning' Can define refactor, convention, warning, error and 'fatal' to cause Rubocop to error out on. rubocop --fail-level 'warning'

⚠️ Gotchas

  1. Due to the GitHub Check Runs API, we can only return 50 annotations per run. See here for more info.
  2. There is a bug with the Checks API that might cause your runs to get jumbled in the UI, but they will all still run and render annotations in the diff correctly.
  3. You can't use --version with multiple gems. You can specify multiple gems with version requirements using gem install 'my_gem:1.0.0' 'my_other_gem:~>2.0.0'

📸 Screenshots

Rubocop Linter Checks Overview Rubocop Linter File Annotation

🔖 Changelog

View our Changelog

🆘 Contributing

Contributing Guide

🚨 Code of Conduct

Code of Conduct

©️ License

MIT

🥇 Recognition

This project was originally forked from gimenete/rubocop-action. Many thanks to Alberto Gimeno for creating this project.

🤖 Check Out My Other Ruby GitHub Actions

Contributors

Thanks goes to these wonderful people (emoji key):

Andrew Mason
Andrew Mason

🚇 👀 📖 💻
Miguel Savignano
Miguel Savignano

🚇 ⚠️ 💻
Dan McGregor
Dan McGregor

📖
amerritt14
amerritt14

💻
Brian Bugh
Brian Bugh

💻 ⚠️
Reid Beels
Reid Beels

💻 ⚠️
Christopher Pezza
Christopher Pezza

💻 📖 🚇
Mark Havekes
Mark Havekes

🐛

This project follows the all-contributors specification. Contributions of any kind welcome!

You can’t perform that action at this time.