Skip to content

Github action to flake8 lint your pull requests

License

Notifications You must be signed in to change notification settings

valentijnscholten/flake8-your-pr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flake8-your-pr

Github Action to flake8 your pull requests

wait, what?

This is a github action to automatically run flake8 on your pull request and add results as annotations.

Screenshot 2019-07-01 at 22 45 50Screenshot 2019-07-01 at 23 02 27

but why?

If you are working in a team you would be better off adding checks on pull requests. Of course you already have linters run automatically through vim and all (right? right?!) but just in case your colleague(s) inadvertently disable them it's good to have them.

The trouble is it's a lot of effort to configure these well. You'd need a CI/CD server with some plugins that needs to be configured, updated etc.

This is where Github Actions comes along. Github basically runs a docker image on several event triggers. These could be pull requests, issues, comments, code pushes etc. etc.

where can i get this?

Easy, tiger. Sign up for beta on Github. And then simply add the following code in your repo root .github/main.workflow:

name: Flake8 your PR
on: [pull_request]
jobs:
  flake8-your-pr:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 2

      - uses: valentijnscholten/flake8-your-pr@master
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

Create a pull request with some Python code and voila, you should see any errors as annotations.

Oh and this is only available for private repos at the moment. I guess Github is testing this, API is changing and they would like to fix all bugs before releasing to the whole wide world. Free plan comes with private repos now, go and test it out.

next up?

  • Once Github Actions is open to public and this gets used more, I want this action to be configurable. Github Actions can use an args field and I can send the errors to be ignored etc.

If you use this and like it let me know and any pull requests are more than welcome.

dev ramblings

I like the idea behind Github Actions very much. It simplifies devops and adds to the overall software development experience really. Thanks to usage of docker images, you can pretty much do anything with it.

My plan originally was to create a Github App, deploy it on AWS using API Gateway and Lambda and use that to run flake8 or anything else I needed. Then I remembered Github Actions. It's much more easier to setup than API Gateways and Lambdas really. What's more, I think it is much more powerful too. With Lambda you are restricted in your environment (Python version this and Node version that etc.) but with Github Actions you can use any docker image you like.

Before deciding to write my own linter integrations, I looked into various SaaS solutions and none of them suited me well. Specifically, a lot of them did not have annotations feature.

Gotchas

About

Github action to flake8 lint your pull requests

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 53.1%
  • Shell 37.2%
  • Dockerfile 9.7%