openrewrite / openrewrite/rewrite-github-actions
Do not use `gradle/actions/setup-gradle` with `arguments`; replace with two steps
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1
- Forks
- 9
- Avg merge
- 5h 27m
- Merged PRs (30d)
- 12
Description
What problem are you trying to solve?
Using the action to execute Gradle via the arguments parameter is deprecated
The core functionality of the setup-gradle (and gradle-build-action) actions is to configure your Gradle environment for GitHub Actions. Once the action has run, any subsequent Gradle executions will benefit from caching, reporting and other features of the action.Using the arguments parameter to execute Gradle directly is not necessary to benefit from this action. This input is deprecated, and will be removed in the v4 major release of the action.
To convert your workflows, replace any steps using the arguments parameter with 2 steps: one to setup-gradle and another that runs your Gradle build.
What precondition(s) should be checked before applying this recipe?
Uses gradle/actions/setup-gradle
Describe the situation before applying the recipe
steps:
- name: Assemble the project
uses: gradle/actions/setup-gradle@v3
with:
arguments: 'assemble'
- name: Run the tests
uses: gradle/actions/setup-gradle@v3
with:
arguments: 'test'
- name: Run build in a subdirectory
uses: gradle/actions/setup-gradle@v3
with:
build-root-directory: another-build
arguments: 'build'
Describe the situation after applying the recipe
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Assemble the project
run: ./gradlew assemble
- name: Run the tests
run: ./gradlew test
- name: Run build in a subdirectory
working-directory: another-build
run: ./gradlew build
Any additional context
Using the action in this way gives you more control over how Gradle is executed, while still giving you all of the benefits of the setup-gradle action.
The arguments parameter is scheduled to be removed in setup-gradle@v4.
Note: if you are using the gradle-build-action, see here for more details on how to migrate.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the recipe that handles gradle/actions/setup-gradle steps using the arguments parameter and review the recipe unit tests. Use the before-and-after YAML examples as the expected transformation, including build-root-directory and working-directory handling. Done means deprecated arguments-based executions become a setup step followed by run steps for the Gradle commands.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions
- Domain
- ci-cd
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100