Repository navigation
HDDS-17790. Create setup-java-with-cache action - #12023
Conversation
chihsuan
left a comment
There was a problem hiding this comment.
Thanks for the patch! @adoroszlai Nice consolidation. I left a few notes inline.
| run: | | ||
| rm -frv ~/.m2/repository | ||
|
|
||
| - name: Restore cache with exact key |
There was a problem hiding this comment.
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-' || '' }}There was a problem hiding this comment.
I intend to start using apache/infrastructure-actions/stash:
- does not have
restore-keys - exact
stashshould precede "generic"cachelookup (which would be kept for some time for stability)
There was a problem hiding this comment.
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 }} |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
Since the key now includes .mvn/extensions.xml, should populate-cache also trigger on it and on this action?
|
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/**' |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.)
There was a problem hiding this comment.
Agreed, build sounds enough. Thanks!
|
|
Thanks @chihsuan for the review! |
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 usingactions/setup-java.The action encapsulates:
actions/cachecurrently)maven-repo-${{ hashFiles(...) }})Use the new action in existing workflows, keeping current behavior:
populate-cacherestores only if "exact key" matchesAdd
.mvn/extensions.xmlto the cache key, since it uses versioned Maven artifacts, cache may need to be updated if it changes.Update
asf-allowlist-checkandzizmorworkflows to also apply checks to.github/actions.https://issues.apache.org/jira/browse/HDDS-17790
How was this patch tested?
CIcheck (beforepopulate-cache):populate-cache:flaky-test-checkafterpopulate-cache:repeat-acceptanceafterpopulate-cache:populate-cachere-run:Fetch dependenciesandSave cache for Maven dependencieszizmor: https://github.com/adoroszlai/ozone/actions/runs/43039579095/job/130587459621#step:3:34asf-allowlist-check: https://github.com/adoroszlai/ozone/actions/runs/43039579538/job/130587461473#step:3:110Full CI:
https://github.com/adoroszlai/ozone/actions/runs/43039579591https://github.com/adoroszlai/ozone/actions/runs/43231253203