From 732080e26f468fadab9f64ffe6061da953b2634f Mon Sep 17 00:00:00 2001 From: Cameron Wade Date: Thu, 17 Aug 2023 11:41:45 -0300 Subject: [PATCH] Configure repository to automatically use Black formatter This commit ensures that all new pull requests are Black compliant. --- .github/workflows/black.yml | 25 +++++++++++++++++++++++++ .pre-commit-config.yaml.yml | 17 +++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 .github/workflows/black.yml create mode 100644 .pre-commit-config.yaml.yml diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 00000000..edf42c13 --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,25 @@ +name: black-action +on: [pull_request] +jobs: + linter_name: + name: runner / black + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Check files using the black formatter + uses: rickstaa/action-black@v1 + id: action_black + with: + black_args: "." + - name: Create Pull Request + if: steps.action_black.outputs.is_formatted == 'true' + uses: peter-evans/create-pull-request@v3 + with: + token: ${{ secrets.GITHUB_TOKEN }} + title: "Format Python code with psf/black push" + commit-message: ":art: Format Python code with psf/black" + body: | + There appear to be some python formatting errors in ${{ github.sha }}. This pull request + uses the [psf/black](https://github.com/psf/black) formatter to fix these issues. + base: ${{ github.head_ref }} # Creates pull request onto pull request or commit branch + branch: actions/black diff --git a/.pre-commit-config.yaml.yml b/.pre-commit-config.yaml.yml new file mode 100644 index 00000000..1d38df10 --- /dev/null +++ b/.pre-commit-config.yaml.yml @@ -0,0 +1,17 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: check-yaml + # - id: end-of-file-fixer + - id: trailing-whitespace + - id: check-added-large-files + args: ['--maxkb=80000'] +- repo: https://github.com/psf/black + rev: 23.3.0 + hooks: + - id: black +- repo: https://github.com/PyCQA/isort + rev: 5.12.0 + hooks: + - id: isort