Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Research GitHub Actions + Code Suggester for linters #6

Closed
grayside opened this issue May 14, 2021 · 3 comments · Fixed by #20
Closed

Research GitHub Actions + Code Suggester for linters #6

grayside opened this issue May 14, 2021 · 3 comments · Fixed by #20
Assignees
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: cleanup An internal cleanup or hygiene concern.
Milestone

Comments

@grayside
Copy link
Collaborator

Linting is a great way to enforce standards, but the work churn created by linting mistakes is frustrating. Investigate how to use googleapis/code-suggester with GitHub Actions to automatically "suggest" lint fixes to PRs so contributors can accept corrections with a couple clicks.

I consider this a P1 because I want to establish this as a key element of project productivity early.

@grayside grayside added type: cleanup An internal cleanup or hygiene concern. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels May 14, 2021
@grayside grayside self-assigned this May 14, 2021
@grayside
Copy link
Collaborator Author

grayside commented May 15, 2021

Example Workflow

This workflow uses the official hashicorp action to working with Terraform in GitHub Action to send terraform fmt corrections.

on:
  pull_request_target:
    types: [opened, synchronize]
    branches:
      - main
name: ci
jobs:
  terraform-fmt:
    runs-on: ubuntu-latest
    env:
      ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{github.event.pull_request.head.ref}}
          repository: ${{github.event.pull_request.head.repo.full_name}}
      - uses: hashicorp/setup-terraform@v1
      - run: terraform init
      - name: Terraform Fmt
        run: terraform fmt --recursive
      - uses: googleapis/code-suggester@v1 # takes the changes from git directory
        with:
          command: review
          pull_number: ${{ github.event.pull_request.number }}
          git_dir: '.'

When a PR is sent with a "dirty" change, actions creates PR comments like so:

Screen Shot 2021-05-14 at 8 59 18 PM

@grayside
Copy link
Collaborator Author

Exit criteria on this issue is:

  • Guidelines on creating linter actions, including how to handle access tokens
  • Documentation on actions/workflow tools that have been enabled

@dinagraves
Copy link
Contributor

I recommend using black and/or flake8 for Python files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: cleanup An internal cleanup or hygiene concern.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants