From 3df5beb3b02416db5b09a08428bac7cfaefc6b9b Mon Sep 17 00:00:00 2001 From: ilyushka <61294398+DRMPN@users.noreply.github.com> Date: Thu, 14 Dec 2023 22:09:10 +0300 Subject: [PATCH 1/4] Create autopep8.yml --- .github/workflows/autopep8.yml | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/autopep8.yml diff --git a/.github/workflows/autopep8.yml b/.github/workflows/autopep8.yml new file mode 100644 index 0000000000..84cff0d6b2 --- /dev/null +++ b/.github/workflows/autopep8.yml @@ -0,0 +1,60 @@ +name: Format python code with autopep8 +on: push +jobs: + autopep8: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: autopep8 + id: autopep8 + uses: peter-evans/autopep8@v2 + with: + args: --exit-code --max-line-length 120 --recursive --in-place --aggressive --aggressive . + - name: Get Pull Request Number + id: pr + run: echo "::set-output name=pull_request_number::$(gh pr view --json number -q .number || echo "")" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Find Comment + uses: peter-evans/find-comment@v2 + id: fc + with: + issue-number: ${{ steps.pr.outputs.pull_request_number }} + comment-author: "github-actions[bot]" + - name: Create comment if autopep8 made NO changes + if: ${{ steps.fc.outputs.comment-id == '' && steps.autopep8.outputs.exit-code != 2}} + uses: peter-evans/create-or-update-comment@v3 + with: + issue-number: ${{ steps.pr.outputs.pull_request_number }} + body: | + Code has no PEP8 errors! + - name: Create comment if autopep8 made changes + if: ${{ steps.fc.outputs.comment-id == '' && steps.autopep8.outputs.exit-code == 2}} + uses: peter-evans/create-or-update-comment@v3 + with: + issue-number: ${{ steps.pr.outputs.pull_request_number }} + body: | + Code in this pull request contains PEP8 errors, please write the `/fix-pep8` command in the comments below to create commit with automatic fixes. + - name: Update comment if NOT fixed + if: ${{ steps.fc.outputs.comment-id != '' && steps.autopep8.outputs.exit-code == 2}} + uses: peter-evans/create-or-update-comment@v3 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + edit-mode: replace + body: | + Code in this pull request **still** contains PEP8 errors, please write the `/fix-pep8` command in the comments below to create commit with automatic fixes. + + ##### Comment last updated at ${{ github.event.head_commit.timestamp }} + - name: Update comment if fixed + if: ${{ steps.fc.outputs.comment-id != '' && steps.autopep8.outputs.exit-code != 2}} + uses: peter-evans/create-or-update-comment@v3 + with: + comment-id: ${{ steps.fc.outputs.comment-id }} + edit-mode: replace + body: | + All PEP8 errors has been fixed, thanks :heart: + + ##### Comment last updated at ${{ github.event.head_commit.timestamp }} + - name: Fail if autopep8 made changes + if: steps.autopep8.outputs.exit-code == 2 + run: exit 1 From a9a753930fe1bd40cf25f23356f67d7ab0bfae38 Mon Sep 17 00:00:00 2001 From: ilyushka <61294398+DRMPN@users.noreply.github.com> Date: Thu, 14 Dec 2023 22:10:03 +0300 Subject: [PATCH 2/4] Create slash-command-dispatch.yml --- .github/workflows/slash-command-dispatch.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/slash-command-dispatch.yml diff --git a/.github/workflows/slash-command-dispatch.yml b/.github/workflows/slash-command-dispatch.yml new file mode 100644 index 0000000000..0f46ab9fe1 --- /dev/null +++ b/.github/workflows/slash-command-dispatch.yml @@ -0,0 +1,15 @@ +name: Slash Command Dispatch +on: + issue_comment: + types: [created] +jobs: + slashCommandDispatch: + runs-on: ubuntu-latest + steps: + - name: Slash Command Dispatch + uses: peter-evans/slash-command-dispatch@v3 + with: + token: ${{ secrets.REPO_ACCESS_TOKEN }} + reactions: true + commands: fix-pep8 + issue-type: pull-request From 46ec99b3c0f99a24e151677856861268bd623e16 Mon Sep 17 00:00:00 2001 From: ilyushka <61294398+DRMPN@users.noreply.github.com> Date: Thu, 14 Dec 2023 22:10:41 +0300 Subject: [PATCH 3/4] Create fix-pep8-command.yml --- .github/workflows/fix-pep8-command.yml | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/fix-pep8-command.yml diff --git a/.github/workflows/fix-pep8-command.yml b/.github/workflows/fix-pep8-command.yml new file mode 100644 index 0000000000..5c1c707758 --- /dev/null +++ b/.github/workflows/fix-pep8-command.yml @@ -0,0 +1,34 @@ +name: fix-pep8-command +on: + repository_dispatch: + types: [fix-pep8-command] +jobs: + fix-pep8: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.REPO_ACCESS_TOKEN }} + repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }} + ref: ${{ github.event.client_payload.pull_request.head.ref }} + - name: autopep8 + id: autopep8 + uses: peter-evans/autopep8@v2 + with: + args: --exit-code --max-line-length 120 --recursive --in-place --aggressive --aggressive . + - name: Commit autopep8 changes + id: cap8c + if: steps.autopep8.outputs.exit-code == 2 + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git commit -am "Automated autopep8 fixes" + git push + - name: Create comment + if: steps.cap8c.outcome == 'success' + uses: peter-evans/create-or-update-comment@v3 + with: + repository: ${{ github.event.client_payload.github.payload.repository.full_name }} + issue-number: ${{ github.event.client_payload.github.payload.issue.number }} + body: | + Fixed PEP8 problems! From 89161d04f409048e2e45ad9fd8f40ecda077c2b1 Mon Sep 17 00:00:00 2001 From: ilyushka <61294398+DRMPN@users.noreply.github.com> Date: Tue, 9 Jan 2024 14:02:18 +0300 Subject: [PATCH 4/4] changed to not leave comment after fix --- .github/workflows/fix-pep8-command.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/fix-pep8-command.yml b/.github/workflows/fix-pep8-command.yml index 5c1c707758..fc0a897182 100644 --- a/.github/workflows/fix-pep8-command.yml +++ b/.github/workflows/fix-pep8-command.yml @@ -24,11 +24,11 @@ jobs: git config --global user.email 'github-actions[bot]@users.noreply.github.com' git commit -am "Automated autopep8 fixes" git push - - name: Create comment - if: steps.cap8c.outcome == 'success' - uses: peter-evans/create-or-update-comment@v3 - with: - repository: ${{ github.event.client_payload.github.payload.repository.full_name }} - issue-number: ${{ github.event.client_payload.github.payload.issue.number }} - body: | - Fixed PEP8 problems! + # - name: Create comment + # if: steps.cap8c.outcome == 'success' + # uses: peter-evans/create-or-update-comment@v3 + # with: + # repository: ${{ github.event.client_payload.github.payload.repository.full_name }} + # issue-number: ${{ github.event.client_payload.github.payload.issue.number }} + # body: | + # Fixed PEP8 problems!