Skip to content

Commit

Permalink
Add github actions for CI
Browse files Browse the repository at this point in the history
- When a new PR is submitted, autoformat code with autopep8 and remove
  commented out code
- After reformatting, commit back to the pull request
- When reformatted code has been committed, lint it with pycodestyle

On github side we will
- Require all changes to be submitted as PRs
- Require all CI checks to pass before merging PRs

This change partially-fixes #1 and fixes #10
  • Loading branch information
Minion3665 committed Aug 15, 2022
1 parent 745e3ca commit 1a0062f
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
47 changes: 47 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Lint & reformat

on:
pull_request:
branches: ["master"]

workflow_dispatch:

jobs:
reformat:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: |
**/requirements*.txt
- name: Install pip packages
run: python3 -m pip install --upgrade autopep8 pycodestyle eradicate
- name: Run autopep8
run: autopep8 --in-place -aa -r .
- name: Remove commented out code
run: eradicate --in-place ./**/*.py
- name: Push back to repo
uses: actions-go/push@v1
with:
author-email: github-actions[bot]@users.noreply.github.com
author-name: Reformat action
create-commit: true
commit-message: "Reformatted code and removed commented-out code"
lint:
runs-on: ubuntu-latest
needs: reformat
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
cache-dependency-path: |
**/requirements*.txt
- name: Install pip packages
run: python3 -m pip install --upgrade pycodestyle
- name: Run pycodestyle
run: pycodestyle --show-source --show-pep8 ./**/*.py
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pycodestyle]
max-line-length = 120
statistics = True

0 comments on commit 1a0062f

Please sign in to comment.