This is an automated email from the ASF dual-hosted git repository.
ppkarwasz pushed a commit to branch gha/v0
in repository https://gitbox.apache.org/repos/asf/logging-parent.git
The following commit(s) were added to refs/heads/gha/v0 by this push:
new c33dab4 Purge snapshots from the Maven cache in reproducibility
checks (#508)
c33dab4 is described below
commit c33dab45a7d74ac5e1922ac36c97091ea4c04c9b
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Sun Jul 26 09:58:10 2026 +0200
Purge snapshots from the Maven cache in reproducibility checks (#508)
* Purge snapshots from the Maven cache in reproducibility checks
The local Maven repository restored from the GitHub Actions cache contains
the reference artifacts resolved by `artifact:compare` in previous runs.
Since snapshots are not updated on every resolution, these stale copies
shadow the reference repository and make the comparison meaningless.
Purge all `*-SNAPSHOT` directories from the local repository before the
build, warning about each file found, and purge them again after the build
so they are not saved to the cache.
Assisted-By: Claude Fable 5 <[email protected]>
* Use NUL-delimited paths in the snapshot purge loops
Assisted-By: Claude Fable 5 <[email protected]>
---
.../workflows/verify-reproducibility-reusable.yaml | 30 ++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/verify-reproducibility-reusable.yaml
b/.github/workflows/verify-reproducibility-reusable.yaml
index 63f0298..77f3dc8 100644
--- a/.github/workflows/verify-reproducibility-reusable.yaml
+++ b/.github/workflows/verify-reproducibility-reusable.yaml
@@ -112,13 +112,13 @@ jobs:
NEXUS_URL: ${{ inputs.nexus-url }}
REFERENCE_ARTIFACT_NAME: ${{ inputs.reference-artifact-name }}
run: |
- REFERENCE_REPO=""
-
if [ -n "$NEXUS_URL" ] && [ -n "$REFERENCE_ARTIFACT_NAME" ]; then
echo '::error::Provide exactly one of `nexus-url` or
`reference-artifact-name`, not both.'
exit 1
fi
+ echo '::group::Determine reference repository'
+ REFERENCE_REPO=""
# Computes the URI of the local repository, if
`reference-artifact-name` was given.
if [ -n "$REFERENCE_ARTIFACT_NAME" ]; then
TEMP_DIR="$RUNNER_TEMP"
@@ -134,12 +134,38 @@ jobs:
echo '::error::Either `nexus-url` or `reference-artifact-name`
must be provided.'
exit 1
fi
+ echo "Using reference repository: $REFERENCE_REPO"
+ echo '::endgroup::'
+
+ echo '::group::Purge snapshots from the local Maven repository'
+ # Snapshot artifacts restored from the GitHub Actions cache shadow
the reference repository during resolution,
+ # so their presence means the cache was polluted by a previous run.
+ if [ -d ~/.m2/repository ]; then
+ find ~/.m2/repository -type d -name '*-SNAPSHOT' -prune -print0 |
while IFS= read -r -d '' dir; do
+ find "$dir" -type f -print0 | while IFS= read -r -d '' file; do
+ echo "::warning::Purging stale snapshot file: $file"
+ done
+ rm -rf "$dir"
+ done
+ fi
+ echo '::endgroup::'
+
./mvnw \
--show-version --batch-mode --errors --no-transfer-progress \
-DskipTests=true \
-Dreference.repo="${REFERENCE_REPO}" \
clean verify artifact:compare
+ # Remove all snapshots from the local Maven repository before it is
saved to the GitHub Actions cache,
+ # so that the reference artifacts resolved by `artifact:compare` do not
contaminate the cache.
+ - name: Purge snapshots from Maven cache
+ if: always()
+ shell: bash
+ run: |
+ if [ -d ~/.m2/repository ]; then
+ find ~/.m2/repository -type d -name '*-SNAPSHOT' -prune -exec rm
-rf {} +
+ fi
+
# Upload reproducibility results if the build fails.
- name: Upload reproducibility results
if: failure()