Coder Social home page Coder Social logo

tamdilip / eslint-review-action Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 1.88 MB

Github Action to review code changes on a Pull-Request and add corresponding review comments with eslint issues, test coverage and vulnerabilities for a clean code promotion.

JavaScript 100.00%
eslint-review-action eslint coverage review ember github-actions coverage-report linting vulnerability-report

eslint-review-action's Introduction

Github Action to review code changes on a Pull-Request and add corresponding review comments for a clean Merge process.

This action repo mainly targets on Ember app, does eslint on only changed set of files in a pull-request and cosecutive commits. Also does ember testing along with code coverage for entire app, if ember-cli-code-coverage setup is configured. Together runs npm audit check to get the vulnerability report.

๐Ÿ•น Usage:

Add the following to your workflow .yml file in app (secrets.GITHUB_TOKEN is the default Personal Access Token(PAT) generated):

name: Run eslint review action repo
uses: tamdilip/eslint-review-action@v1
with:
  repo-token: ${{ secrets.GITHUB_TOKEN }}

Incase of consuming this action by moving to private repo (secrets.ACTION_TOKEN should be a new private token to clone action):

name: Checkout GitHub Action Repo
uses: actions/checkout@v2
with:
  repository: tamdilip/eslint-review-action
  ref: v1
  token: ${{ secrets.ACTION_TOKEN }}
  path: .github/actions/eslint-review-action
name: Run eslint-review-action action
uses: ./.github/actions/eslint-review-action
with:
  repo-token: ${{ secrets.ACTION_TOKEN }}

Complete working sample .github/workflow/action.yml:

name: Pull request review

on:
  pull_request:
    branches: [ master ]

jobs:
  eslint:
    name: ESLINT REVIEW ACTION
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v2
      - name: Install Dependencies
        uses: actions/setup-node@v1
        with:
          node-version: 12.x
      - name: Cache node modules
        uses: actions/cache@v2
        with:
          path: |
            **/node_modules
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
      - run: npm install
      - name: Checkout GitHub Action Repo
        uses: tamdilip/eslint-review-action@v1
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}

Dynamic inputs and configurations ( add under with:)

Most of the action items can be configured dynamically as per the need with all these available set of config inputs here - action.yml.

All available inputs

  repo-token:
    description: 'Token used to interact with the Github API.'
    required: true
  bot-user-name:
    description: 'Set username of the token provide to filter out comments'
    required: false
    default: ''
  disable-eslint:
    description: 'Set true to stop linting.'
    required: false
    default: 'false'
  disable-ember-test:
    description: 'Set true to stop ember testing.'
    required: false
    default: 'false'
  disable-npm-audit:
    description: 'Set true to stop npm auditing.'
    required: false
    default: 'false'
  fail-on-test:
    description: 'Set true to fail the pull-request merge status, if ember test has failing test cases.'
    required: false
    default: 'false'
  disable-test-coverage:
    description: 'Set true to stop ember coverage execution, when ember test is enabled.'
    required: false
    default: 'false'
  test-coverage-threshold:
    description: 'Minimum test coverage percentage to pass the pull-request.'
    required: false
    default: '0'
  vulnerability-fail-on:
    description: 'Set vulnerability criteria to fail the pull-request merge status, OPTIONS: INFO/LOW/MODERATE/HIGH/CRITICAL'
    required: false
    default: ''
  pass-emoji:
    description: 'Emoji to indicate fixed eslint issue.'
    required: false
    default: 'โœ”๏ธ'
  fail-emoji:
    description: 'Emoji to indicate failed eslint issue.'
    required: false
    default: 'โŒ'
  info-emoji:
    description: 'Emoji to indicate status message.'
    required: false
    default: '๐Ÿ“ข'
  eslint-emoji:
    description: 'Emoji for eslint header label.'
    required: false
    default: '๐Ÿ› '
  test-emoji:
    description: 'Emoji for test header label.'
    required: false
    default: '๐Ÿ”ฌ'
  vulnerability-emoji:
    description: 'Emoji for vulnerability header label.'
    required: false
    default: '๐Ÿ‘ฝ'
  eslint-report-header:
    description: 'Header text for Eslint issues.'
    required: false
    default: 'ESLINT ISSUES'
  test-report-header:
    description: 'Header text for Test case report.'
    required: false
    default: 'TEST CASE REPORT'
  vulnerability-report-header:
    description: 'Header text for node dependencies vulnerability report.'
    required: false
    default: 'VULNERABILITY REPORT'
  eslint-common-issues-disclaimer:
    description: 'Disclaimer text to explain about the common grouped set of eslint issue comment.'
    required: false
    default: 'issues listed below are in areas other than visible changed portion of lines'

Actions Output Visuals

๐Ÿ’ฌ Inline comment

For eslint issues occurred at actual changed portion of lines part of the pull-request and the visible diff section as below -

Inline Comment

๐Ÿ’ฌ Grouped common issue comment

For eslint issues occurred at other than changed portion of lines part of the pull-request and not at the visible diff section, along with test coverage and vulnerability report as below -

Grouped common issue comment

๐Ÿ’ฌ Pull request action run status

Incase of any issues, the pull-request merge status will be displayed as below from the action run -

Pull request action run status

Local setup and development

$ git clone https://github.com/tamdilip/eslint-review-action.git
$ cd eslint-review-action
$ npm install
$ ncc build index.js

References

Happy coding :) !!

eslint-review-action's People

Contributors

dependabot[bot] avatar tamdilip avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.