Skip to content

Change OpenRewrite task to use rewriteDryRun#15664

Merged
koppor merged 3 commits into
mainfrom
InAnYan-patch-2
May 3, 2026
Merged

Change OpenRewrite task to use rewriteDryRun#15664
koppor merged 3 commits into
mainfrom
InAnYan-patch-2

Conversation

@InAnYan

@InAnYan InAnYan commented May 3, 2026

Copy link
Copy Markdown
Member

Related issues and pull requests

Closes https://github.com/JabRef/jabref-issue-melting-pot/issues/1289

PR Description

Fixes the OpenRewrite check. The problem was that when there are changes, the check is succeded. But if we change the task to the dry run, on changes it will fail (the same also happens locally, so I think on CI/CD it will also work like that).

Steps to test

I don't know how to test the CI/CD changes. But you can locally run rewriteRun and rewriteDryRun.

Checklist

  • I own the copyright of the code submitted and I license it under the MIT license
  • I manually tested my changes in running JabRef (always required)
  • [/] I added JUnit tests for changes (if applicable)
  • [/] I added screenshots in the PR description (if change is visible to the user)
  • [/] I added a screenshot in the PR description showing a library with a single entry with me as author and as title the issue number
  • [/] I described the change in CHANGELOG.md in a way that can be understood by the average user (if change is visible to the user)
  • I checked the user documentation for up to dateness and submitted a pull request to our user documentation repository

@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

Review Summary by Qodo

Fix OpenRewrite CI check to use dry-run mode

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Change OpenRewrite Gradle task from rewriteRun to rewriteDryRun
• Fixes CI/CD check to properly fail when code style changes are detected
• Aligns CI behavior with local development workflow
Diagram
flowchart LR
  A["rewriteRun<br/>succeeds on changes"] -->|changed to| B["rewriteDryRun<br/>fails on changes"]
  B -->|proper CI behavior| C["Detects code style issues"]
Loading

Grey Divider

File Changes

1. .github/workflows/tests-code.yml 🐞 Bug fix +1/-1

Switch OpenRewrite to dry-run mode in CI

• Changed OpenRewrite Gradle task from rewriteRun to rewriteDryRun in the CI workflow
• Ensures the check fails when code style violations are detected instead of succeeding
• Aligns CI/CD behavior with local development testing

.github/workflows/tests-code.yml


Grey Divider

Qodo Logo

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented May 3, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider


Remediation recommended

1. Brittle patch output path🐞 Bug ☼ Reliability
Description
With :rewriteDryRun now expected to fail when rewrites are pending, the Output diff step will
execute more often but uses a hard-coded absolute path (/home/runner/work/jabref/jabref/...) that
can be wrong when the checkout directory differs, producing an unhelpful "file not found" error
instead of the rewrite patch output.
Code

.github/workflows/tests-code.yml[R85-88]

+          gradle --no-configuration-cache :rewriteDryRun
   - name: Output diff
     if: failure()
     run: |
Evidence
The workflow prints the patch via a hard-coded runner path. The same workflow file also demonstrates
that checkout paths can vary (it uses actions/checkout with path: 'jabref' in another job), so
relying on a fixed /home/runner/work/jabref/jabref location is fragile and can break the
diagnostics step right when rewriteDryRun fails on detected changes.

.github/workflows/tests-code.yml[72-90]
.github/workflows/tests-code.yml[106-129]
build.gradle.kts[20-36]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The OpenRewrite failure diagnostics uses a hard-coded absolute path (`/home/runner/work/jabref/jabref/...`) to print `rewrite.patch`. Now that `:rewriteDryRun` is intended to fail when it finds results, this step will run more often and can fail with `No such file or directory` when the checkout directory differs.
### Issue Context
This repository’s Gradle config sets `failOnDryRunResults = true`, so `:rewriteDryRun` is expected to fail on detected rewrite results and trigger the `if: failure()` step.
### Fix Focus Areas
- .github/workflows/tests-code.yml[72-90]
### Suggested change
Use `${{ github.workspace }}` (or a relative path) and optionally guard with `test -f`:

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

@InAnYan

InAnYan commented May 3, 2026

Copy link
Copy Markdown
Member Author

Aha! The changed workflow is triggered here, and you can see it's working now

Comment thread .github/workflows/tests-code.yml Outdated
run: |
gradle --no-configuration-cache :rewriteRun
gradle --no-configuration-cache :rewriteDryRun
- name: Output diff

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the idea is nice; the core idea of the change was that the CHANGES were output!!

Thus, the "real" requirement would be to check if there is any code diff. If yes, then do it.

Maybe, it is as simple as check for /home/runner/work/jabref/jabref/build/reports/rewrite/rewrite.patch being present?

I think, additionally, we should do :rewriteDryRun to ensure that the check fails?

@InAnYan InAnYan May 3, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want the action to produce a commit with openrewrite changes?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we want to have a list/the gradle output of the task saying openRewrite failed with....

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For fixing using the CI we have https://github.com/JabRef/jabref/blob/main/.github/workflows/run-openrewrite.yml

But we still want to have a manual trigger - and not automatic fixing... We can discuss on JabCon when we have more experience with all the AI tool usage within JabRef.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, it would seem strange for an action that has made changes successfully (not taking “there were parsing errors” into account) to fail. This is why I believe there is a dry run, along with an option (somewhere in the build.gradle) to fail the build during the dry run if there are changes to be made

koppor and others added 2 commits May 3, 2026 19:33
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@qodo-free-for-open-source-projects

Copy link
Copy Markdown
Contributor

CI Feedback 🧐

A test triggered by this PR failed. Here is an AI-generated analysis of the failure:

Action: Dependency Scopes

Failed stage: Run checkAllModuleInfo using gradle [❌]

Failed test name: ""

Failure summary:

The GitHub Action failed because the Gradle build exited with code 1 after task
:jabgui:checkModuleDirectivesScope failed.
The
org.gradlex.javamodule.dependencies.JavaModuleDependenciesPlugin reported an invalid module
requirement in jabgui/src/main/java/module-info.java:
- The build asks to remove (or change to
runtimeOnly) the directive requires org.kordamp.ikonli.material;

Relevant error logs:
1:  ##[group]Runner Image Provisioner
2:  Hosted Compute Agent
...

640:  SpringerNatureAPIKey: ***
641:  GRADLE_OPTS: -Xmx4g
642:  JAVA_OPTS: -Xmx4g
643:  JAVA_HOME: /opt/hostedtoolcache/Java_Corretto_jdk/25.0.3-9.1/x64
644:  JAVA_HOME_25_X64: /opt/hostedtoolcache/Java_Corretto_jdk/25.0.3-9.1/x64
645:  GRADLE_ACTION_ID: gradle/actions/setup-gradle
646:  GRADLE_USER_HOME: /home/runner/.gradle
647:  GRADLE_BUILD_ACTION_SETUP_COMPLETED: true
648:  GRADLE_BUILD_ACTION_CACHE_RESTORED: true
649:  DEVELOCITY_INJECTION_INIT_SCRIPT_NAME: gradle-actions.inject-develocity.init.gradle
650:  DEVELOCITY_INJECTION_CUSTOM_VALUE: gradle-actions
651:  GITHUB_DEPENDENCY_GRAPH_ENABLED: false
652:  ##[endgroup]
653:  Welcome to Gradle 9.5.0!
654:  Here are the highlights of this release:
655:  - Task provenance in reports and failure messages
656:  - Type-safe accessors for precompiled Kotlin Settings plugins
657:  For more details see https://docs.gradle.org/9.5.0/release-notes.html
658:  Starting a Gradle Daemon (subsequent builds will be faster)
659:  Parallel Configuration Cache is an incubating feature.
660:  Calculating task graph as no cached configuration is available for tasks: checkAllModuleInfo
661:  > Task :build-logic:checkKotlinGradlePluginConfigurationErrors SKIPPED
662:  > Task :build-logic:generateExternalPluginSpecBuilders
...

1366:  > Task :jabls:computeAdvice
1367:  > Task :jabls:filterAdvice
1368:  > Task :jabls:checkModuleDirectivesScope
1369:  > Task :jabls:checkModuleInfo SKIPPED
1370:  > Task :jabls:checkTestModuleInfo SKIPPED
1371:  > Task :jabls:checkAllModuleInfo
1372:  > Task :jabls-cli:artifactsReportMain
1373:  > Task :jabgui:computeActualUsageTest
1374:  > Task :jabgui:computeActualUsageMain
1375:  > Task :jabgui:computeAdvice
1376:  Note: /home/runner/work/jabref/jabref/jabls-cli/src/main/java/org/jabref/languageserver/cli/ServerCli.java uses or overrides a deprecated API.
1377:  > Task :jabgui:filterAdvice
1378:  Note: Recompile with -Xlint:deprecation for details.
1379:  > Task :jabls-cli:compileJava
1380:  > Task :jabls-cli:explodeByteCodeSourceMain
1381:  > Task :jabgui:checkModuleDirectivesScope FAILED
1382:  > Task :jabls-cli:synthesizeProjectViewMain
...

1776:  (see http://t.uber.com/nullaway )
1777:  /home/runner/work/jabref/jabref/jablib/src/test/java/org/jabref/logic/layout/format/RTFCharsTest.java:23: warning: [NullAway] assigning @Nullable expression to @NonNull field
1778:  formatter = null;
1779:  ^
1780:  (see http://t.uber.com/nullaway )
1781:  /home/runner/work/jabref/jabref/jablib/src/test/java/org/jabref/logic/layout/format/OrdinalTest.java:17: warning: [NullAway] passing @Nullable parameter 'null' where @NonNull is required
1782:  assertNull(new Ordinal().format(null));
1783:  ^
1784:  (see http://t.uber.com/nullaway )
1785:  Note: Some input files use or override a deprecated API.
1786:  Note: Recompile with -Xlint:deprecation for details.
1787:  Note: Some input files use unchecked or unsafe operations.
1788:  Note: Recompile with -Xlint:unchecked for details.
1789:  100 warnings
1790:  gradle/actions: Writing build results to /home/runner/work/_temp/.gradle-actions/build-results/__run-1777832747823.json
1791:  FAILURE: Build failed with an exception.
1792:  [Incubating] Problems report is available at: file:///home/runner/work/jabref/jabref/build/reports/problems/problems-report.html
1793:  217 actionable tasks: 181 executed, 36 from cache
1794:  * What went wrong:
1795:  Configuration cache entry stored.
1796:  Execution failed for task ':jabgui:checkModuleDirectivesScope' (registered by plugin class 'org.gradlex.javamodule.dependencies.JavaModuleDependenciesPlugin').
1797:  > /home/runner/work/jabref/jabref/jabgui/src/main/java/module-info.java
1798:  Please remove the following requires directives (or change to runtimeOnly):
1799:  requires org.kordamp.ikonli.material;
1800:  * Try:
1801:  > Run with --stacktrace option to get the stack trace.
1802:  > Run with --info or --debug option to get more log output.
1803:  > Run with --scan to get full insights from a Build Scan (powered by Develocity).
1804:  > Get more help at https://help.gradle.org.
1805:  BUILD FAILED in 4m 16s
1806:  ##[error]Process completed with exit code 1.
1807:  Post job cleanup.

@koppor koppor merged commit 5bfff9d into main May 3, 2026
53 of 55 checks passed
@koppor koppor deleted the InAnYan-patch-2 branch May 3, 2026 18:34
@Siedlerchr

Copy link
Copy Markdown
Member

Siedlerchr added a commit to FynnianB/jabref that referenced this pull request May 4, 2026
…rity

* upstream/main: (204 commits)
  New Crowdin updates (JabRef#15669)
  Fix OpenRewrite (JabRef#15670)
  Udpate heylogs (and fix CHANGELOG.md) (JabRef#15671)
  Improve security and prevent shell injection for push2applications (JabRef#15628)
  Fix depdency analysis (JabRef#15668)
  Always use CI-local "gradle", instead of gradlew (JabRef#15667)
  Change OpenRewrite task to use rewriteDryRun (JabRef#15664)
  Add small documentation to parameter (JabRef#15666)
  Fix markbaseChanged for "imported entries" (JabRef#15610)
  Add forgotten --fresh
  chore(deps): update dependency com.github.ben-manes.caffeine:caffeine to v3.2.4 (JabRef#15662)
  chore(deps): update jackson monorepo to v3.1.3 (JabRef#15659)
  chore(deps): update dependency org.glassfish.hk2:hk2-utils to v4.0.1 (JabRef#15657)
  chore(deps): update dependency org.glassfish.hk2:hk2-locator to v4.0.1 (JabRef#15656)
  fix gemsfx missing icon resolving (JabRef#15655)
  chore(deps): update dependency org.glassfish.hk2:hk2-api to v4.0.1 (JabRef#15654)
  chore(deps): update dependency org.postgresql:postgresql to v42.7.11 (JabRef#15634)
  Chore(deps): Bump tools.jackson:jackson-bom in /versions (JabRef#15653)
  Chore(deps): Bump dev.langchain4j:langchain4j-bom in /versions (JabRef#15652)
  Chore(deps): Bump com.dlsc.gemsfx:gemsfx in /versions (JabRef#15651)
  ...
Siedlerchr added a commit that referenced this pull request May 5, 2026
* upstream/main: (775 commits)
  Chore(deps): Bump com.konghq:unirest-modules-gson in /versions (#15682)
  Chore(deps): Bump org.glassfish.jaxb:jaxb-runtime in /versions (#15681)
  Update dependency com.konghq:unirest-modules-gson to v4.9.0 (#15679)
  Integrate with SearchRxiv  (#15373)
  Fix requirements (#15600)
  refactor: less objects during writing (#15677)
  Fix: suppress WARN for empty or blank column name in MainTableColumnModel#parse() (#15576)
  New Crowdin updates (#15676)
  Chore(deps): Bump com.github.ben-manes.caffeine:caffeine in /versions (#15673)
  Fix Nullwarnings - C (Mark bst package as nonnull by default) (#15663)
  Chore(deps): Bump com.github.javaparser:javaparser-symbol-solver-core (#15674)
  Chore(deps): Bump com.github.javaparser:javaparser-core in /versions (#15672)
  New Crowdin updates (#15669)
  Fix OpenRewrite (#15670)
  Udpate heylogs (and fix CHANGELOG.md) (#15671)
  Improve security and prevent shell injection for push2applications (#15628)
  Fix depdency analysis (#15668)
  Always use CI-local "gradle", instead of gradlew (#15667)
  Change OpenRewrite task to use rewriteDryRun (#15664)
  Add small documentation to parameter (#15666)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants