diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4e81d87e865..ca4e9861aea 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,11 +29,37 @@ jobs: name: Checkstyle runs-on: ubuntu-latest steps: - - name: Checkout source + - name: Checkout source (PR) + if: github.event_name == 'pull_request' + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + submodules: 'true' + show-progress: 'false' + - name: Checkout source (no-PR) + if: github.event_name != 'pull_request' uses: actions/checkout@v4 with: submodules: 'true' show-progress: 'false' + - name: Install prettier-plugin-java + run: npm install + - name: Check code style (using prettier-java) + if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository + uses: creyD/prettier_action@v4.3 + with: + prettier_options: --check **/*.java + prettier_plugins: "prettier-plugin-java" + clean_node_folder: false + dry: true + - name: Reformat code (using prettier-java) + if: "!(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository)" + uses: creyD/prettier_action@v4.3 + with: + prettier_options: --write **/*.java + prettier_plugins: "prettier-plugin-java" + clean_node_folder: false - name: Set up JDK uses: actions/setup-java@v3 with: @@ -49,20 +75,6 @@ jobs: checkstyle_version: '10.3' - name: Run checkstyle using gradle run: ./gradlew checkstyleMain checkstyleTest checkstyleJmh - - name: Add comment on pull request - if: ${{ failure() }} - uses: thollander/actions-comment-pull-request@v2 - with: - message: > - Your code currently does not meet JabRef's code guidelines. - We use [Checkstyle](https://checkstyle.sourceforge.io/) to identify issues. - The tool reviewdog already placed comments on GitHub to indicate the places. See the tab "Files" in you PR. - 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). - Afterwards, please run checkstyle locally and fix the issues. - - - More information on code quality in JabRef is available at . - comment_tag: checkstyle openrewrite: name: OpenRewrite runs-on: ubuntu-latest @@ -81,19 +93,6 @@ jobs: - name: Run OpenRewrite run: | ./gradlew rewriteDryRun - - name: Add comment on pull request - if: ${{ failure() }} - uses: thollander/actions-comment-pull-request@v2 - with: - 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**. - Please execute the gradle task *`rewriteRun`*, check the results, commit, and push. - - - You can check the detailed error output at the tab "Checks", section "Tests" (on the left), subsection "OpenRewrite". - comment_tag: openrewrite modernizer: name: Modernizer runs-on: ubuntu-latest @@ -114,18 +113,6 @@ jobs: # enable failing of this task if modernizer complains sed -i "s/failOnViolations = false/failOnViolations = true/" build.gradle ./gradlew modernizer - - name: Add comment on pull request - if: ${{ failure() }} - uses: thollander/actions-comment-pull-request@v2 - with: - 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 at the tab "Checks", section "Tests" (on the left), subsection "Modernizer". - comment_tag: modernizer markdown: name: Markdown runs-on: ubuntu-latest @@ -141,17 +128,6 @@ jobs: globs: | *.md docs/**/*.md - - name: Add comment on pull request - if: ${{ failure() }} - uses: thollander/actions-comment-pull-request@v2 - with: - message: > - You modified Markdown (*.md) 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. - - You can check the detailed error output at the tab "Checks", section "Tests" (on the left), subsection "Markdown". - comment_tag: markdown changelog: name: CHANGELOG.md runs-on: ubuntu-latest @@ -198,14 +174,6 @@ jobs: diff \ <(git show origin/main:CHANGELOG.md | clparse --format=json --separator=– - | jq '.releases[] | select(.version != null)') \ <(git show HEAD:CHANGELOG.md | clparse --format=json --separator=– - | jq '.releases[] | select(.version != null)') - - name: Add comment on pull request - if: ${{ failure() }} - uses: thollander/actions-comment-pull-request@v2 - with: - message: > - While the PR was in progress, JabRef released a new version. - You have to merge `upstream/main` and move your entry in `CHANGELOG.md` to section `## [Unreleased]`. - comment_tag: changelog-unreleased-only tests: name: Unit tests runs-on: ubuntu-latest diff --git a/.prettierrc.yaml b/.prettierrc.yaml new file mode 100644 index 00000000000..0a88ae54481 --- /dev/null +++ b/.prettierrc.yaml @@ -0,0 +1,4 @@ +tabWidth: 4 +printWidth: 100 +plugins: + - prettier-plugin-java diff --git a/.vscode/settings.json b/.vscode/settings.json index 2094775de07..97f15775553 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,6 @@ "java.configuration.updateBuildConfiguration": "interactive", "java.format.settings.url": "/config/VSCode Code Style.xml", "java.checkstyle.configuration": "${workspaceFolder}/config/checkstyle/checkstyle_reviewdog.xml", - "java.checkstyle.version": "10.3.4" + "java.checkstyle.version": "10.3.4", + "java.completion.importOrder": ["#"] } diff --git a/build.gradle b/build.gradle index c72f3c74bd0..8d50a6cca0f 100644 --- a/build.gradle +++ b/build.gradle @@ -22,12 +22,11 @@ plugins { id 'jacoco' id 'checkstyle' + id 'org.openrewrite.rewrite' version '6.4.0' id 'project-report' id 'idea' - - id 'org.openrewrite.rewrite' version '6.4.0' } // Enable following for debugging diff --git a/config/IntelliJ Code Style.xml b/config/IntelliJ Code Style.xml index 6a03e104d9d..3db7387111f 100644 --- a/config/IntelliJ Code Style.xml +++ b/config/IntelliJ Code Style.xml @@ -11,28 +11,20 @@ +