From 60ea167f76be9cf4ea4eb3479b6f1912cbdfe8bb Mon Sep 17 00:00:00 2001 From: coco875 Date: Wed, 11 Sep 2024 19:50:06 +0200 Subject: [PATCH 1/6] Create black-suggest.yml --- .github/workflows/black-suggest.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .github/workflows/black-suggest.yml diff --git a/.github/workflows/black-suggest.yml b/.github/workflows/black-suggest.yml new file mode 100644 index 000000000..f7ceca5db --- /dev/null +++ b/.github/workflows/black-suggest.yml @@ -0,0 +1,16 @@ +name: black Suggest +on: [pull_request] +jobs: + formatting-check: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - name: Install Dependance + run: | + pip install black + - name: Run black style check. + run: | + black . + - uses: parkerbxyz/suggest-changes@v1 + with: + comment: 'Please commit the suggested changes from black.' From fc25f2f9d3f5994a063b805dedb6c0e71c5dcb36 Mon Sep 17 00:00:00 2001 From: coco875 Date: Wed, 11 Sep 2024 21:34:07 +0200 Subject: [PATCH 2/6] Update black-suggest.yml --- .github/workflows/black-suggest.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/black-suggest.yml b/.github/workflows/black-suggest.yml index f7ceca5db..6037acdd0 100644 --- a/.github/workflows/black-suggest.yml +++ b/.github/workflows/black-suggest.yml @@ -7,7 +7,8 @@ jobs: - uses: actions/checkout@v4 - name: Install Dependance run: | - pip install black + sudo apt isntall python-pip + pip install black==23.12.1 - name: Run black style check. run: | black . From a80724523aa17fdad150565c47ca02cfba2d687c Mon Sep 17 00:00:00 2001 From: coco875 Date: Wed, 11 Sep 2024 21:37:12 +0200 Subject: [PATCH 3/6] Update black-suggest.yml --- .github/workflows/black-suggest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/black-suggest.yml b/.github/workflows/black-suggest.yml index 6037acdd0..3eff01852 100644 --- a/.github/workflows/black-suggest.yml +++ b/.github/workflows/black-suggest.yml @@ -7,7 +7,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Dependance run: | - sudo apt isntall python-pip + python -m pip install --upgrade pip pip install black==23.12.1 - name: Run black style check. run: | From 1deaf6163fcce7e3873d6a2332f527e5c73161a1 Mon Sep 17 00:00:00 2001 From: coco875 Date: Wed, 11 Sep 2024 21:38:41 +0200 Subject: [PATCH 4/6] Update black-suggest.yml --- .github/workflows/black-suggest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/black-suggest.yml b/.github/workflows/black-suggest.yml index 3eff01852..1820dd36e 100644 --- a/.github/workflows/black-suggest.yml +++ b/.github/workflows/black-suggest.yml @@ -7,7 +7,7 @@ jobs: - uses: actions/checkout@v4 - name: Install Dependance run: | - python -m pip install --upgrade pip + apt isntall python3-full pip install black==23.12.1 - name: Run black style check. run: | From 94f849e6b57b4e54b54b6ec9beeb3197bc03563f Mon Sep 17 00:00:00 2001 From: coco875 Date: Wed, 11 Sep 2024 21:40:55 +0200 Subject: [PATCH 5/6] use the python action --- .github/workflows/black-suggest.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/black-suggest.yml b/.github/workflows/black-suggest.yml index 1820dd36e..e9201b786 100644 --- a/.github/workflows/black-suggest.yml +++ b/.github/workflows/black-suggest.yml @@ -5,9 +5,11 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 - - name: Install Dependance - run: | - apt isntall python3-full + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' # caching pip dependencies + - run: pip install black==23.12.1 - name: Run black style check. run: | From ae88af9485e25e66a92a8849563bc314be226a25 Mon Sep 17 00:00:00 2001 From: Lila Date: Sun, 27 Oct 2024 09:47:18 +0000 Subject: [PATCH 6/6] First iteration --- .github/workflows/black-lint.yml | 13 ----------- .github/workflows/black-suggest.yml | 19 --------------- .github/workflows/black.yml | 36 +++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 32 deletions(-) delete mode 100644 .github/workflows/black-lint.yml delete mode 100644 .github/workflows/black-suggest.yml create mode 100644 .github/workflows/black.yml diff --git a/.github/workflows/black-lint.yml b/.github/workflows/black-lint.yml deleted file mode 100644 index e0b5e1379..000000000 --- a/.github/workflows/black-lint.yml +++ /dev/null @@ -1,13 +0,0 @@ -# https://black.readthedocs.io/en/stable/integrations/github_actions.html - -name: Black Lint - -on: [push, pull_request] - -jobs: - black-lint: - permissions: {} # Remove all permissions - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: psf/black@23.12.1 diff --git a/.github/workflows/black-suggest.yml b/.github/workflows/black-suggest.yml deleted file mode 100644 index e9201b786..000000000 --- a/.github/workflows/black-suggest.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: black Suggest -on: [pull_request] -jobs: - formatting-check: - runs-on: ubuntu-24.04 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - with: - python-version: '3.12' - cache: 'pip' # caching pip dependencies - - run: - pip install black==23.12.1 - - name: Run black style check. - run: | - black . - - uses: parkerbxyz/suggest-changes@v1 - with: - comment: 'Please commit the suggested changes from black.' diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 000000000..9a1f91a97 --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,36 @@ +name: Black lint and suggest changes + +on: [pull_request, push] + +jobs: + black-lint-and-suggest: + permissions: # needed in forks? https://github.com/parkerbxyz/suggest-changes/issues/33 + contents: read + pull-requests: write + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' # caching pip dependencies + - run: pip install black==23.12.1 + + - name: Run black + run: black . # if this fails nothing else will run, this is correct behavior + + - name: Suggest changes via comment + if: github.event_name == 'pull_request' # Only run for PRs + uses: parkerbxyz/suggest-changes@v1 + with: + comment: 'Please commit the suggested changes from black.' + + - name: Fail if changes were made + run: | + if git diff --quiet; then + echo "Black formatting applied no changes." + exit 0 + else + echo "Black formatting applied changes. Please format with black." + exit 1 + fi \ No newline at end of file