summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/format_and_lint.yml41
1 files changed, 41 insertions, 0 deletions
diff --git a/.github/workflows/format_and_lint.yml b/.github/workflows/format_and_lint.yml
new file mode 100644
index 0000000..2f4f41f
--- /dev/null
+++ b/.github/workflows/format_and_lint.yml
@@ -0,0 +1,41 @@
+name: Format and Lint
+
+on:
+ push:
+ branches:
+ - main, develop
+ paths:
+ - '**.py'
+ pull_request:
+ paths:
+ - '**.py'
+
+jobs:
+ format_and_lint:
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout HEAD
+ uses: actions/checkout@v3
+ with:
+ ref: ${{ github.head_ref }}
+ - name: Run flake8
+ uses: microsoft/[email protected]
+ with:
+ flake8: true
+ fail_on_error: true
+ - name: Run yapf
+ uses: mritunjaysharma394/autoyapf@v2
+ with:
+ args: --in-place --recursive .
+
+ - name: Check for Modified Files
+ id: git-check
+ run: echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
+
+ - name: Push Changes
+ if: steps.git-check.outputs.modified == 'true'
+ run: |
+ git config --global user.name 'github-actions'
+ git config --global user.email '[email protected]'
+ git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
+ git commit -am "chore: format and lint"