From e02999f8b282acefc5188c375b44ff20f37550f1 Mon Sep 17 00:00:00 2001 From: Joshua Hairston Date: Wed, 2 Oct 2024 22:19:57 -0400 Subject: [PATCH 1/8] added branch, title, and body to the pull request action --- .github/workflows/blackformatter.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/blackformatter.yml b/.github/workflows/blackformatter.yml index c4d91e7..64b422b 100644 --- a/.github/workflows/blackformatter.yml +++ b/.github/workflows/blackformatter.yml @@ -25,11 +25,14 @@ jobs: - name: Run Black run: black . - + - name: Push changes back to the pull request branch uses: gr2m/create-or-update-pull-request-action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: + title: "Formatting" + body: "Formatted python files with black" + branch: "main" author: "github-actions[bot] " commit-message: "Formatted with Black per repo requirements" - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 7d27b687974517ff28811d85fa43cb0727874df4 Mon Sep 17 00:00:00 2001 From: Joshua Hairston Date: Wed, 2 Oct 2024 22:34:26 -0400 Subject: [PATCH 2/8] added spaces to the admin.py of submissions to test the formatter --- teleband/submissions/admin.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/teleband/submissions/admin.py b/teleband/submissions/admin.py index 228c2b9..61d415a 100644 --- a/teleband/submissions/admin.py +++ b/teleband/submissions/admin.py @@ -18,6 +18,31 @@ class SubmissionAdmin(VersionAdmin): @admin.register(SubmissionAttachment) class SubmissionAttachmentAdmin(VersionAdmin): list_display = ("id", "submission", "file") + + + + + + + + + + + + + + + + + + + + + + + + + raw_id_fields = ("submission",) # list_filter = ("submission",) From 8b5d1952c4c807531c19d7c785bbdf6f5b55d0d2 Mon Sep 17 00:00:00 2001 From: Joshua Hairston Date: Wed, 2 Oct 2024 23:04:37 -0400 Subject: [PATCH 3/8] added pull_request_target instead of pull_request --- .github/workflows/blackformatter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/blackformatter.yml b/.github/workflows/blackformatter.yml index 64b422b..3fddc95 100644 --- a/.github/workflows/blackformatter.yml +++ b/.github/workflows/blackformatter.yml @@ -1,7 +1,7 @@ name: Check Python Code Formatting on: - pull_request: + pull_request_target: branches: - main From a6e58a0d17d4346997542ddedc59389740600e33 Mon Sep 17 00:00:00 2001 From: Joshua Hairston Date: Thu, 3 Oct 2024 00:12:15 -0400 Subject: [PATCH 4/8] using a new action --- .github/workflows/blackformatter.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/blackformatter.yml b/.github/workflows/blackformatter.yml index 3fddc95..72e7415 100644 --- a/.github/workflows/blackformatter.yml +++ b/.github/workflows/blackformatter.yml @@ -1,7 +1,7 @@ name: Check Python Code Formatting on: - pull_request_target: + pull_request: branches: - main @@ -9,11 +9,13 @@ jobs: format-check: runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: - name: Checkout code uses: actions/checkout@v4 - with: - persist-credentials: false - name: Set up Python uses: actions/setup-python@v5 @@ -27,12 +29,10 @@ jobs: run: black . - name: Push changes back to the pull request branch - uses: gr2m/create-or-update-pull-request-action@v1 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: peter-evans/create-pull-request@v7 with: - title: "Formatting" - body: "Formatted python files with black" - branch: "main" - author: "github-actions[bot] " - commit-message: "Formatted with Black per repo requirements" + committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> + author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> + branch: main + title: Formatting Code + body: Formatting code with black From a671e52b8ca4a38b70cc35d3c39db0c5d1ee8feb Mon Sep 17 00:00:00 2001 From: Joshua Hairston Date: Mon, 7 Oct 2024 06:56:58 -0400 Subject: [PATCH 5/8] added base to yml file as pull_request needs it --- .github/workflows/blackformatter.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/blackformatter.yml b/.github/workflows/blackformatter.yml index 72e7415..cde82d8 100644 --- a/.github/workflows/blackformatter.yml +++ b/.github/workflows/blackformatter.yml @@ -28,9 +28,17 @@ jobs: - name: Run Black run: black . + - name: Commit changes if formatting is needed + run: | + git config --local user.name "github-actions[bot]" + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git add . + git diff --cached --exit-code || git commit -m "Auto-format code with Black" + - name: Push changes back to the pull request branch uses: peter-evans/create-pull-request@v7 with: + base: ${{github.head_ref}} committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> branch: main From 8797dbde6d1e068fcddad60795fbe77facf98d05 Mon Sep 17 00:00:00 2001 From: Joshua Hairston Date: Mon, 7 Oct 2024 07:06:35 -0400 Subject: [PATCH 6/8] another test --- .github/workflows/blackformatter.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/blackformatter.yml b/.github/workflows/blackformatter.yml index cde82d8..538a299 100644 --- a/.github/workflows/blackformatter.yml +++ b/.github/workflows/blackformatter.yml @@ -41,6 +41,5 @@ jobs: base: ${{github.head_ref}} committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> - branch: main title: Formatting Code body: Formatting code with black From 80bf925338b1c3c25499eee10e44184384e413dd Mon Sep 17 00:00:00 2001 From: Joshua Hairston Date: Mon, 7 Oct 2024 07:18:07 -0400 Subject: [PATCH 7/8] added more --- .github/workflows/blackformatter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/blackformatter.yml b/.github/workflows/blackformatter.yml index 538a299..c24fb26 100644 --- a/.github/workflows/blackformatter.yml +++ b/.github/workflows/blackformatter.yml @@ -38,7 +38,7 @@ jobs: - name: Push changes back to the pull request branch uses: peter-evans/create-pull-request@v7 with: - base: ${{github.head_ref}} + base: ${{ github.head_ref }} committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> title: Formatting Code From 5cc92e6c54331a647cddd9a0eeed360354de5e01 Mon Sep 17 00:00:00 2001 From: Joshua Hairston Date: Thu, 10 Oct 2024 12:35:36 -0400 Subject: [PATCH 8/8] added formatting errors --- teleband/assignments/admin.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/teleband/assignments/admin.py b/teleband/assignments/admin.py index 7e93122..b5a1cc3 100644 --- a/teleband/assignments/admin.py +++ b/teleband/assignments/admin.py @@ -87,6 +87,22 @@ class AssignmentInline(admin.TabularInline): @admin.register(AssignmentGroup) class AssignmentGroupAdmin(VersionAdmin): + + + + + + + + + + + + + + + + list_display = ( "id", "type",