Skip to content

Commit

Permalink
Switch to Using Gradle Wrapper Exclusively (#3803)
Browse files Browse the repository at this point in the history
## What was the problem?

The workflow used `gradle/actions/setup-gradle@v3` to manage the Gradle
version, which was redundant since the project already uses the Gradle
Wrapper (`./gradlew`). This redundancy created the potential for version
conflicts if `setup-gradle` and the Gradle Wrapper specified different
versions.

Additionally, setting the Ubuntu version in the workflow worked
temporarily but failed after Ubuntu 20.04.6 upgraded to Gradle 8.11
([GitHub Actions
update](actions/runner-images#10999)) 😅. It's
also impossible to pin to the correct minor version in GH workflows
(20.04.05).

---

## How does this fix it?

- Removed `gradle/actions/setup-gradle@v3` to ensure the Gradle Wrapper
exclusively manages the Gradle version.
- The Gradle version specified in `gradle-wrapper.properties` (8.10.2)
is always used, ensuring consistency and avoiding version mismatches.
- Simplified workflow by eliminating unnecessary cache settings
(`cache-read-only`, `gradle-home-cache-cleanup`).
- Added a step to clear Gradle caches (`rm -rf ~/.gradle || true`) to
prevent residual or mismatched Gradle versions from interfering with the
build process.

This approach aligns the workflow with best practices by relying on the
Gradle Wrapper for version management and ensures the workflow remains
functional despite changes to the Ubuntu image.

---

## How to test this PR

1. Verify that the workflow executes successfully in CI pipelines.
2. Confirm that Gradle 8.10.2 (as defined in
`gradle-wrapper.properties`) is used during all builds.

Note: running `abd-vro-internal`, this change seems to work!

https://github.com/department-of-veterans-affairs/abd-vro-internal/actions/runs/12022537477/job/33514927530#step:13:2

![image](https://github.com/user-attachments/assets/78d83c1e-2ac4-4b9d-8978-20e6b1a14a62)

![image](https://github.com/user-attachments/assets/e3d48842-be7e-4431-a48e-38eedd3bbc54)
  • Loading branch information
gabezurita authored Nov 26, 2024
2 parents fb4f060 + cde044b commit aad6a8c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
13 changes: 3 additions & 10 deletions .github/actions/setup-vro/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,9 @@ runs:
# cache the Gradle User Home"
# cache: 'gradle'

# https://github.com/gradle/actions/blob/v3.5.0/setup-gradle/action.yml
- name: "Setup Gradle"
uses: gradle/actions/setup-gradle@v3
with:
# Only write to the cache for builds on the 'main' and 'develop' branches. (Default is 'main' only.)
# Builds on other branches will only read existing entries from the cache.
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/qa' && github.ref != 'refs/heads/develop' }}
# To avoid a growing cache over time, attempt to delete any files in the Gradle User Home
# that were not used by Gradle during the workflow, prior to saving the cache.
gradle-home-cache-cleanup: true
- name: "Clear Gradle Cache"
shell: bash
run: rm -rf ~/.gradle || true

- uses: ./.github/actions/install-java-tools

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/secrel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
outputs:
run-secrel: ${{ steps.check-run-conds.outputs.run_secrel }}
publish-images: ${{ steps.check-run-conds.outputs.publish_images }}
runs-on: ubuntu-20.04 # NOTE: As VRO is being shut down, this version is pinned to get around a .gradle issue with removeUnusedEntriesOlderThan.
runs-on: ubuntu-latest
steps:
- name: "Decide downstream actions"
id: check-run-conds
Expand Down Expand Up @@ -106,7 +106,7 @@ jobs:
outputs:
vro-images: ${{ steps.publish-images.outputs.images_list }}
slack-response-ts: ${{ fromJson(steps.notify-slack.outputs.slack-result).response.message.ts }}
runs-on: ubuntu-20.04 # NOTE: As VRO is being shut down, this version is pinned to get around a .gradle issue with removeUnusedEntriesOlderThan.
runs-on: ubuntu-latest
steps:
- name: "Determine image tag"
id: image-props
Expand Down

0 comments on commit aad6a8c

Please sign in to comment.