From 04037aefe830b52d5b8efb643d81d9a7737bd72b Mon Sep 17 00:00:00 2001 From: Jun Komoda <45822440+junkmd@users.noreply.github.com> Date: Mon, 9 Jan 2023 06:37:21 +0900 Subject: [PATCH] add `black` style checking to GHA settings (#465) --- .github/workflows/autofmt.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/autofmt.yml b/.github/workflows/autofmt.yml index f915a6b91..52eac7607 100644 --- a/.github/workflows/autofmt.yml +++ b/.github/workflows/autofmt.yml @@ -6,9 +6,6 @@ jobs: formatter: name: auto-formatter runs-on: windows-latest - # Because auto-commit to the branch from a forked repository will fail, - # so this GHA will be triggered by PRs from the source repository only. - if: github.repository == github.event.pull_request.head.repo.full_name steps: - name: Checkout uses: actions/checkout@v3 @@ -18,9 +15,19 @@ jobs: python-version: 3.7 - name: Install black run: pip install black==22.12.0 - - name: Format + # PRs from the forked repo will trigger format-checking only. + # Auto-commit to the branch from a forked repo will fail without + # any access tokens or permissions. + # So formatting and auto-commit will be triggered by PRs from the + # base repo only. + - if: github.repository != github.event.pull_request.head.repo.full_name + name: Check style + run: python -m black comtypes/. --check --diff --color + - if: github.repository == github.event.pull_request.head.repo.full_name + name: Format run: python -m black comtypes/. - - name: Auto-commit + - if: github.repository == github.event.pull_request.head.repo.full_name + name: Auto-commit uses: stefanzweifel/git-auto-commit-action@v4 with: branch: ${{ github.head_ref }}