Skip to content

Commit ae6469a

Browse files
committed
[#1929] Enable reproducible archives
1 parent 4a7c515 commit ae6469a

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

ci/compare-build-results.sh

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env bash
2+
3+
# This is a simple script to check if builds are reproducible. The steps are:
4+
# 1. Build ORM with `./gradlew --no-daemon clean publishToMavenLocal --no-build-cache -Dmaven.repo.local=some-path/out/build1`
5+
# 2. Build ORM with `./gradlew --no-daemon clean publishToMavenLocal --no-build-cache -Dmaven.repo.local=some-path/out/build2` second time pointing to a different local maven repository to publish
6+
# 3. Compare the build results with sh ./ci/compare-build-results.sh some-path/out/build1 some-path/out/build2
7+
# 4. The generated .buildcompare file will also contain the diffscope commands to see/compare the problematic build artifacts
8+
9+
outputDir1=$1
10+
outputDir2=$2
11+
outputDir1=${outputDir1%/}
12+
outputDir2=${outputDir2%/}
13+
14+
ok=()
15+
okFiles=()
16+
ko=()
17+
koFiles=()
18+
19+
for f in `find ${outputDir1} -type f | grep -v "javadoc.jar$" | grep -v "maven-metadata-local.xml$" | sort`
20+
do
21+
flocal=${f#$outputDir1}
22+
# echo "comparing ${flocal}"
23+
sha1=`shasum -a 512 $f | cut -f 1 -d ' '`
24+
sha2=`shasum -a 512 $outputDir2$flocal | cut -f 1 -d ' '`
25+
# echo "$sha1"
26+
# echo "$sha2"
27+
if [ "$sha1" = "$sha2" ]; then
28+
ok+=($flocal)
29+
okFiles+=(${flocal##*/})
30+
else
31+
ko+=($flocal)
32+
koFiles+=(${flocal##*/})
33+
fi
34+
done
35+
36+
# generate .buildcompare
37+
buildcompare=".buildcompare"
38+
echo "ok=${#ok[@]}" >> ${buildcompare}
39+
echo "ko=${#ko[@]}" >> ${buildcompare}
40+
echo "okFiles=\"${okFiles[@]}\"" >> ${buildcompare}
41+
echo "koFiles=\"${koFiles[@]}\"" >> ${buildcompare}
42+
echo "" >> ${buildcompare}
43+
echo "# see what caused the mismatch in the checksum by executing the following diffscope commands" >> ${buildcompare}
44+
for f in ${ko[@]}
45+
do
46+
echo "# diffoscope $outputDir1$f $outputDir2$f" >> ${buildcompare}
47+
done
48+
49+
if [ ${#ko[@]} -eq 0 ]; then
50+
exit 0
51+
else
52+
exit 1
53+
fi

hibernate-reactive-core/build.gradle

+9
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ dependencies {
8080
testImplementation "org.testcontainers:oracle-xe:${testcontainersVersion}"
8181
}
8282

83+
// Reproducible Builds
84+
85+
// https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives
86+
// Configure archive tasks to produce reproducible archives:
87+
tasks.withType(AbstractArchiveTask).configureEach {
88+
preserveFileTimestamps = false
89+
reproducibleFileOrder = true
90+
}
91+
8392
// Print a summary of the results of the tests (number of failures, successes and skipped)
8493
def loggingSummary(db, result, desc) {
8594
if ( !desc.parent ) { // will match the outermost suite

0 commit comments

Comments
 (0)