From 65c4588a6c0a1e1adb7e1f23e0e92205af15d11f Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 16 Feb 2025 20:16:32 +0100 Subject: [PATCH 01/11] Add force-push-detection --- .github/ghprcomment.yml | 25 ++++++++++++++++------ .github/workflows/force-push-detection.yml | 18 ++++++++++++++++ 2 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/force-push-detection.yml diff --git a/.github/ghprcomment.yml b/.github/ghprcomment.yml index c41d97510ac..a721e37356b 100644 --- a/.github/ghprcomment.yml +++ b/.github/ghprcomment.yml @@ -1,5 +1,5 @@ - jobName: Checkstyle - message: | + message: > Your code currently does not meet [JabRef's code guidelines](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.html). We use [Checkstyle](https://checkstyle.sourceforge.io/) to identify issues. Please carefully follow [the setup guide for the codestyle](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.html). @@ -8,7 +8,7 @@ In case of issues with the import order, double check that you [activated Auto Import](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-13-code-style.html#enable-proper-import-cleanup). You can trigger fixing imports by pressing Ctrl+Alt+O to trigger [Optimize Imports](https://www.jetbrains.com/guide/tips/optimize-imports/). - jobName: OpenRewrite - message: | + message: > Your code currently does not meet JabRef's code guidelines. We use [OpenRewrite](https://docs.openrewrite.org/) to ensure "modern" Java coding practices. The issues found can be **automatically fixed**. @@ -16,14 +16,14 @@ You can check the detailed error output by navigating to your pull request, selecting the tab "Checks", section "Tests" (on the left), subsection "OpenRewrite". - jobName: Modernizer - message: | + message: > Your code currently does not meet JabRef's code guidelines. We use [Gradle Modernizer Plugin](https://github.com/andygoossens/gradle-modernizer-plugin#gradle-modernizer-plugin) to ensure "modern" Java coding practices. Please fix the detected errors, commit, and push. You can check the detailed error output by navigating to your pull request, selecting the tab "Checks", section "Tests" (on the left), subsection "Modernizer". - jobName: Markdown - message: | + message: > You modified Markdown (`*.md`) files and did not meet JabRef's rules for consistently formatted Markdown files. To ensure consistent styling, we have [markdown-lint](https://github.com/DavidAnson/markdownlint) in place. [Markdown lint's rules](https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#rules) help to keep our Markdown files consistent within this repository and consistent with the Markdown files outside here. @@ -34,7 +34,18 @@ While the PR was in progress, a new version of JabRef has been released. You have to merge `upstream/main` and move your entry in `CHANGELOG.md` up to the section `## [Unreleased]`. - jobName: 'Unit tests' - message: | - JUnit tests are failing. In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". This brings you to the test output. + message: > + JUnit tests are failing. + In the area "Some checks were not successful", locate "Tests / Unit tests (pull_request)" and click on "Details". + This brings you to the test output. - You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section [Final build system checks](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-12-build.html#final-build-system-checks) in our setup guide. + You can then run these tests in IntelliJ to reproduce the failing tests locally. + We offer a quick test running howto in the section [Final build system checks](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-12-build.html#final-build-system-checks) in our setup guide. +- jobName: detect-force-push + message: > + Do not force-push! + Force push is off limits and very bad style when working together on a project. + ([Mainly because it is not supported well by GitHub istself.](https://github.com/orgs/community/discussions/3478)) + Commits will be lost, comments on commits will loose their context. + This makes it harder to review. + In the end, all commits will be [squashed](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/incorporating-changes-from-a-pull-request/about-pull-request-merges#squash-and-merge-your-commits) either way before being merged into the `main`` branch. diff --git a/.github/workflows/force-push-detection.yml b/.github/workflows/force-push-detection.yml new file mode 100644 index 00000000000..c5ff72f5131 --- /dev/null +++ b/.github/workflows/force-push-detection.yml @@ -0,0 +1,18 @@ +name: Force Push Detection + +on: + push + +jobs: + detect-force-push: + runs-on: ubuntu-latest + steps: + - name: Check if force push + id: force_push_check + run: | + if git rev-list --ancestry-path ${{ github.event.before }}..${{ github.event.after }} | grep -q "${{ github.event.before }}"; then + echo "✅ Regular commit" + else + echo "❌ Force push detected" + exit 1 + fi From d74187c9d662dd5ce1970c8313a8a68310108ed5 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 16 Feb 2025 20:20:25 +0100 Subject: [PATCH 02/11] Add checkout --- .github/workflows/force-push-detection.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/force-push-detection.yml b/.github/workflows/force-push-detection.yml index c5ff72f5131..610e05b79c0 100644 --- a/.github/workflows/force-push-detection.yml +++ b/.github/workflows/force-push-detection.yml @@ -7,7 +7,12 @@ jobs: detect-force-push: runs-on: ubuntu-latest steps: - - name: Check if force push + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check force push id: force_push_check run: | if git rev-list --ancestry-path ${{ github.event.before }}..${{ github.event.after }} | grep -q "${{ github.event.before }}"; then From a4427bd184e25db8c0ea13c64c794f69617b07cf Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 16 Feb 2025 20:25:12 +0100 Subject: [PATCH 03/11] Try new approach --- .github/workflows/force-push-detection.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/force-push-detection.yml b/.github/workflows/force-push-detection.yml index 610e05b79c0..a1985ffc94e 100644 --- a/.github/workflows/force-push-detection.yml +++ b/.github/workflows/force-push-detection.yml @@ -10,12 +10,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - fetch-depth: 0 + fetch-depth: 0 # Ensure full history for proper merge-base checks - name: Check force push id: force_push_check run: | - if git rev-list --ancestry-path ${{ github.event.before }}..${{ github.event.after }} | grep -q "${{ github.event.before }}"; then + MERGE_BASE=$(git merge-base ${{ github.event.before }} ${{ github.event.after }}) + if [[ "$MERGE_BASE" == "${{ github.event.before }}" ]]; then echo "✅ Regular commit" else echo "❌ Force push detected" From bb3b349920312d299e3444ec79d5f51fbf558063 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 16 Feb 2025 20:28:17 +0100 Subject: [PATCH 04/11] Fix trigger --- .github/workflows/force-push-detection.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/force-push-detection.yml b/.github/workflows/force-push-detection.yml index a1985ffc94e..ee12eb6df79 100644 --- a/.github/workflows/force-push-detection.yml +++ b/.github/workflows/force-push-detection.yml @@ -1,7 +1,9 @@ name: Force Push Detection on: - push + pull_request: + types: + - synchronize jobs: detect-force-push: @@ -10,7 +12,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - fetch-depth: 0 # Ensure full history for proper merge-base checks + fetch-depth: 0 - name: Check force push id: force_push_check From 12dab8395e5732e1e88c1d1f1dbce75e91b939fb Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 16 Feb 2025 20:36:18 +0100 Subject: [PATCH 05/11] Fix trigger --- .github/workflows/pr-comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index 090adf78352..e7b5a9baa3f 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -7,7 +7,7 @@ name: Comment on PR on: workflow_run: - workflows: ["Tests"] + workflows: ["Tests", "Force Push Detection"] types: - completed From 0aad741ba16d12b9d7cd9c46a91d0fc700fbf409 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 16 Feb 2025 20:41:49 +0100 Subject: [PATCH 06/11] Rework logic --- .github/ghprcomment.yml | 2 +- .github/workflows/force-push-detection.yml | 26 ---------------------- .github/workflows/tests.yml | 18 ++++++++++++++- 3 files changed, 18 insertions(+), 28 deletions(-) delete mode 100644 .github/workflows/force-push-detection.yml diff --git a/.github/ghprcomment.yml b/.github/ghprcomment.yml index a721e37356b..9e8f5810e9c 100644 --- a/.github/ghprcomment.yml +++ b/.github/ghprcomment.yml @@ -41,7 +41,7 @@ You can then run these tests in IntelliJ to reproduce the failing tests locally. We offer a quick test running howto in the section [Final build system checks](https://devdocs.jabref.org/getting-into-the-code/guidelines-for-setting-up-a-local-workspace/intellij-12-build.html#final-build-system-checks) in our setup guide. -- jobName: detect-force-push +- jobName: no-force-push message: > Do not force-push! Force push is off limits and very bad style when working together on a project. diff --git a/.github/workflows/force-push-detection.yml b/.github/workflows/force-push-detection.yml deleted file mode 100644 index ee12eb6df79..00000000000 --- a/.github/workflows/force-push-detection.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Force Push Detection - -on: - pull_request: - types: - - synchronize - -jobs: - detect-force-push: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Check force push - id: force_push_check - run: | - MERGE_BASE=$(git merge-base ${{ github.event.before }} ${{ github.event.after }}) - if [[ "$MERGE_BASE" == "${{ github.event.before }}" ]]; then - echo "✅ Regular commit" - else - echo "❌ Force push detected" - exit 1 - fi diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index eb06d1176ca..613e8c9dece 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -52,7 +52,6 @@ jobs: - name: Run checkstyle using gradle run: ./gradlew checkstyleMain checkstyleTest checkstyleJmh - openrewrite: name: OpenRewrite runs-on: ubuntu-latest @@ -372,6 +371,23 @@ jobs: - name: Merge Conflict finder uses: olivernybroe/action-conflict-finder@v4.0 + no-force-push: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check force push + id: force_push_check + run: | + if git cat-file -e ${{ github.event.before }} 2>/dev/null; then + echo "✅ Regular push detected." + else + echo "❌ Force push detected" + fi + other_than_main: name: Source branch is other than "main" runs-on: ubuntu-latest From 6ed0e9aae30d266e93619770215344d8919c0894 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 16 Feb 2025 20:44:23 +0100 Subject: [PATCH 07/11] Test From 96d287c138b21b91fe82a1d6e2387b48bd2a8074 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 16 Feb 2025 20:48:41 +0100 Subject: [PATCH 08/11] Fix workflow --- .github/workflows/tests.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 613e8c9dece..5d35ccdcec3 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -386,6 +386,7 @@ jobs: echo "✅ Regular push detected." else echo "❌ Force push detected" + exit 1 fi other_than_main: From d4deb2cbb6cd4ec6658f3062b4233066b725f624 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 16 Feb 2025 20:49:11 +0100 Subject: [PATCH 09/11] Test From b61c762721bd8a04690cc6aaaac5bae4a30c3205 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 16 Feb 2025 20:49:38 +0100 Subject: [PATCH 10/11] Test From 081ac79e978563aea9d478b16f95040636d28e60 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sun, 16 Feb 2025 20:54:04 +0100 Subject: [PATCH 11/11] Discard changes to .github/workflows/pr-comment.yml --- .github/workflows/pr-comment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml index e7b5a9baa3f..090adf78352 100644 --- a/.github/workflows/pr-comment.yml +++ b/.github/workflows/pr-comment.yml @@ -7,7 +7,7 @@ name: Comment on PR on: workflow_run: - workflows: ["Tests", "Force Push Detection"] + workflows: ["Tests"] types: - completed