forked from INRIA/spoon
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Check reproducible state in CI (INRIA#4653)
- Loading branch information
1 parent
0852aa3
commit 941bc4a
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/usr/bin/env bash | ||
|
||
# If anything fails we are done for | ||
set -e | ||
|
||
build() { | ||
mvn clean package -DskipDepClean -DskipTests -Dmaven.javadoc.skip > /dev/null | ||
} | ||
|
||
compare_files() { | ||
sudo docker run --rm -t -w $(pwd) -v $(pwd):$(pwd):ro \ | ||
registry.salsa.debian.org/reproducible-builds/diffoscope "$1" "$2" | ||
} | ||
|
||
|
||
# Build for the first time | ||
build | ||
|
||
# Save artifacts | ||
mkdir -p saved_artifacts | ||
cp target/spoon-core-*.jar saved_artifacts | ||
|
||
# Build again, will overwrite target jars | ||
build | ||
|
||
# Do not fail the script before both jars were compared and the results printed | ||
set +e | ||
|
||
# Comparison will drill down as deep as possible and print results | ||
compare_files target/spoon-core-*[^dependencies].jar saved_artifacts/spoon-core-*[^dependencies].jar | ||
CORE_EXIT="$?" | ||
|
||
compare_files target/spoon-core-*dependencies.jar saved_artifacts/spoon-core-*dependencies.jar | ||
DEPS_EXIT="$?" | ||
|
||
if [[ "$CORE_EXIT" == 0 && "$DEPS_EXIT" == 0 ]]; then | ||
echo -e "\033[1;32mThe jars were reproducible!\033[0m" | ||
exit 0 | ||
fi | ||
|
||
# Print a pretty error message | ||
|
||
echo -e "\n\033[1;31mThe jars were not reproducible\033[0m" | ||
|
||
if [[ "$DEPS_EXIT" != 0 ]]; then | ||
echo -e " \033[31mspoon-core-VERSION-with-dependencies.jar was not reproducible!\033[0m" | ||
fi | ||
if [[ "$CORE_EXIT" != 0 ]]; then | ||
echo -e " \033[31mspoon-core-VERSION.jar was not reproducible!\033[0m" | ||
fi | ||
|
||
|
||
exit 1 |