From f9f55913d61be40541b54b30659e4dbf69518585 Mon Sep 17 00:00:00 2001 From: Tommy Gatti Date: Fri, 29 Sep 2023 11:16:53 +1000 Subject: [PATCH] Python PR checks (#44) * Added py-checks.yml workflow for PR python syntax checking * Added .ruff.toml for PR python error/warning classes to check * py-checks.yml: checks only run on python files changed --- .github/workflows/py-checks.yml | 25 +++++++++++++++++++++++++ .ruff.toml | 5 +++++ 2 files changed, 30 insertions(+) create mode 100644 .github/workflows/py-checks.yml create mode 100644 .ruff.toml diff --git a/.github/workflows/py-checks.yml b/.github/workflows/py-checks.yml new file mode 100644 index 0000000..b2dd2b4 --- /dev/null +++ b/.github/workflows/py-checks.yml @@ -0,0 +1,25 @@ +name: Python Checks +on: + pull_request: + paths: + - '**.py' + push: + branches: + - main + paths: + - '**.py' +jobs: + ruff-check: + name: Check syntax + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Get py files changed + id: get-files + # In this step, we get the names of all the *.py files changed before the push/pull_request event + # and replaces the newlines with spaces so github actions understands the input in the next step + run: echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.event.after }} -- '*.py' | tr '\n' ' ')" >> $GITHUB_OUTPUT + - uses: chartboost/ruff-action@v1 + with: + src: "${{ steps.get-files.outputs.files }}" + args: "check --format github --preview --config .ruff.toml" \ No newline at end of file diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..39955ba --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,5 @@ +select = ["E","F"] +ignore = ["E221","E241","E272","E731","F405","F821"] +line-length = 80 + +# "E129", "F999" aren't supported \ No newline at end of file