Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions .github/workflows/verify-reproducibility-reusable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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()
Expand Down