Skip to content

HDDS-17790. Create setup-java-with-cache action - #12023

Merged
adoroszlai merged 5 commits into
apache:masterfrom
adoroszlai:HDDS-17790
Nov 12, 2026
Merged

adoroszlai merged 5 commits into
apache:masterfrom
adoroszlai:HDDS-17790

Conversation

@adoroszlai

@adoroszlai adoroszlai commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Create a reusable action for setting up Java and restoring the Maven cache that contains Ozone's dependencies (but not Ozone). These two should almost always be performed together. Any workflow that needs Java without this cache (e.g. build-ratis) can keep using actions/setup-java.

The action encapsulates:

  • the type of cache used (actions/cache currently)
  • cache key composition (maven-repo-${{ hashFiles(...) }})

Use the new action in existing workflows, keeping current behavior:

  • populate-cache restores only if "exact key" matches
  • other workflows may fallback to other existing caches

Add .mvn/extensions.xml to the cache key, since it uses versioned Maven artifacts, cache may need to be updated if it changes.

Update asf-allowlist-check and zizmor workflows to also apply checks to .github/actions.

https://issues.apache.org/jira/browse/HDDS-17790

How was this patch tested?

CI check (before populate-cache):

populate-cache:

flaky-test-check after populate-cache:

repeat-acceptance after populate-cache:

populate-cache re-run:

zizmor: https://github.com/adoroszlai/ozone/actions/runs/43039579095/job/130587459621#step:3:34
asf-allowlist-check: https://github.com/adoroszlai/ozone/actions/runs/43039579538/job/130587461473#step:3:110

Full CI:
https://github.com/adoroszlai/ozone/actions/runs/43039579591
https://github.com/adoroszlai/ozone/actions/runs/43231253203

@adoroszlai adoroszlai added the CI label Nov 11, 2026
@adoroszlai adoroszlai self-assigned this Nov 11, 2026

@chihsuan chihsuan left a comment

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.

Thanks for the patch! @adoroszlai Nice consolidation. I left a few notes inline.

run: |
rm -frv ~/.m2/repository

- name: Restore cache with exact key

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.

Just a thought, what do you think about a single restore step here? Leaving restore-keys empty keeps it exact-only, and cache-matched-key shows whether anything was restored. That could replace the -d checks and the Any hit? step. For example:

- name: Restore cache
  id: restore
  uses: actions/cache/restore@v6
  with:
    path: |
      ~/.m2/repository/*/*/*
      !~/.m2/repository/org/apache/ozone
    key: ${{ steps.cache-key.outputs.value }}
    restore-keys: ${{ inputs.only-exact-hit != 'true' && 'maven-repo-' || '' }}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I intend to start using apache/infrastructure-actions/stash:

  • does not have restore-keys
  • exact stash should precede "generic" cache lookup (which would be kept for some time for stability)

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.

Thanks for the explanation! In this case, would it make sense to drop the if: on Any hit? step? Otherwise restored stays empty on an exact hit.

${{ runner.os }}-pnpm-

- name: Cache for Maven dependencies
if: ${{ inputs.needs-maven-cache }}

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.

nit: needs-maven-cache looks unused now that this step checks java-version. Could we remove the input and its uses in basic and dependency too?

id: cache-key
shell: bash
run: |
echo "value=maven-repo-${{ hashFiles('**/pom.xml', '.mvn/extensions.xml') }}" >> "$GITHUB_OUTPUT"

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.

Since the key now includes .mvn/extensions.xml, should populate-cache also trigger on it and on this action?

@adoroszlai

Copy link
Copy Markdown
Contributor Author

Thanks @chihsuan for the review, patch is updated.

- '!hadoop-ozone/dist/src/main/license/jar-report.txt'
# ignore .github except this workflow and the ones used transitively
- '.github/**'
- '!.github/actions/setup-java-with-cache/**'

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.

Just noticed one more thing, should we add this to run_all_tests_if_environment_files_changed too, so a change to only this action runs the full CI?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point. I think it's enough to trigger build to exercise the check, no need to run all tests. If you agree, I will push a commit to make this change. (BTW selective checks are currently unused on master, since there are no PR runs. We should start using it for push runs in forks.)

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.

Agreed, build sounds enough. Thanks!

@adoroszlai
adoroszlai requested a review from chihsuan November 12, 2026 14:09
@adoroszlai

Copy link
Copy Markdown
Contributor Author
$ gh pr checks https://github.com/apache/ozone/pull/12023
All checks were successful
0 cancelled, 0 failing, 5 successful, 0 skipped, and 0 pending checks

   NAME                                                    DESCRIPTION  ELAPSED   URL                                                                      
✓  ASF Allowlist Check/asf-allowlist-check (pull_request)               54s       https://github.com/apache/ozone/actions/runs/43231261311/job/131226861422
✓  pull request/build-branch (fork) (pull_request)                      1h14m35s  https://github.com/apache/ozone/runs/131236519240
✓  Fork CI ping/ping (pull_request)                                     4s        https://github.com/apache/ozone/actions/runs/43246109558/job/131279063546
✓  pull request/title (pull_request)                                    12s       https://github.com/apache/ozone/actions/runs/43246109798/job/131279127115
✓  zizmor/zizmor (pull_request)                                         15s       https://github.com/apache/ozone/actions/runs/43231261424/job/131226858156

@chihsuan chihsuan left a comment

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.

Thanks @adoroszlai LGTM

@adoroszlai
adoroszlai merged commit c359bf7 into apache:master Nov 12, 2026
7 checks passed
@adoroszlai

Copy link
Copy Markdown
Contributor Author

Thanks @chihsuan for the review!

@adoroszlai
adoroszlai deleted the HDDS-17790 branch November 12, 2026 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants