Skip to content

Commit 8f679d4

Browse files
committed
build(cli): fix reproducible build failures and add nightly workflow
- Hardcode Unix line endings (&#xA;) and use `<fixcrlf>` in the maven-antrun-plugin to prevent OS-specific line separators in dependencies.properties. - Set `<addMavenDescriptor>false</addMavenDescriptor>` in the maven-jar-plugin to prevent OS-specific pom.properties generation. - Add an explicit execution block for maven-jar-plugin before the maven-assembly-plugin to resolve race conditions, ensuring the fresh JAR is built before it gets zipped. - Create .github/workflows/reproducibility.yml to run artifact:compare nightly (excluding the tests module) with a visual Markdown summary.
1 parent 23e2dad commit 8f679d4

File tree

2 files changed

+92
-14
lines changed

2 files changed

+92
-14
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Reproducible Build Check
2+
3+
on:
4+
schedule:
5+
- cron: '0 0 * * *'
6+
workflow_dispatch:
7+
8+
jobs:
9+
check:
10+
name: Verify Deterministic Build
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v5
16+
with:
17+
ref: main
18+
19+
- name: Set up JDK 21
20+
uses: actions/setup-java@v5
21+
with:
22+
java-version: 21
23+
distribution: 'temurin'
24+
cache: maven
25+
26+
- name: 📦 Install
27+
run: mvn clean install -pl "!tests" -DskipTests -B --no-transfer-progress
28+
29+
- name: 🔍 Verify Reproducibility
30+
run: mvn clean verify artifact:compare -pl "!tests" -DskipTests -B --no-transfer-progress
31+
32+
- name: 📊 Generate Visual Report
33+
if: always()
34+
run: |
35+
echo "## 🔍 Reproducible Build Report" >> $GITHUB_STEP_SUMMARY
36+
37+
# Find the generated comparison file (Maven Artifact Plugin creates a .buildcompare file)
38+
COMPARE_FILE=$(find . -type f -name "*.buildcompare" | head -n 1)
39+
40+
if [ -f "$COMPARE_FILE" ]; then
41+
# Extract the values
42+
OK=$(grep '^ok=' "$COMPARE_FILE" | cut -d'=' -f2)
43+
KO=$(grep '^ko=' "$COMPARE_FILE" | cut -d'=' -f2)
44+
IGNORED=$(grep '^ignored=' "$COMPARE_FILE" | cut -d'=' -f2)
45+
46+
# Draw a Markdown Table
47+
echo "| Result | Count |" >> $GITHUB_STEP_SUMMARY
48+
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
49+
echo "| ✅ **OK** | **$OK** |" >> $GITHUB_STEP_SUMMARY
50+
echo "| ❌ **Failed (KO)** | **$KO** |" >> $GITHUB_STEP_SUMMARY
51+
echo "| ⚠️ **Ignored** | **$IGNORED** |" >> $GITHUB_STEP_SUMMARY
52+
echo "" >> $GITHUB_STEP_SUMMARY
53+
54+
# Provide specific feedback
55+
if [ "$KO" -gt 0 ]; then
56+
echo "### 🚨 Reproducibility Drift Detected!" >> $GITHUB_STEP_SUMMARY
57+
echo "The following files differ from the reference build:" >> $GITHUB_STEP_SUMMARY
58+
echo "\`\`\`text" >> $GITHUB_STEP_SUMMARY
59+
# Extract the koFiles string, remove quotes, and print each file on a new line
60+
grep '^koFiles=' "$COMPARE_FILE" | cut -d'=' -f2 | tr -d '"' | tr ' ' '\n' >> $GITHUB_STEP_SUMMARY
61+
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
62+
else
63+
echo "### 🎉 100% Reproducible!" >> $GITHUB_STEP_SUMMARY
64+
echo "The build is perfectly deterministic." >> $GITHUB_STEP_SUMMARY
65+
fi
66+
else
67+
echo "⚠️ **Could not find the \`.buildcompare\` file.** The Maven plugin might have failed before generating the report." >> $GITHUB_STEP_SUMMARY
68+
fi

modules/jooby-cli/pom.xml

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@
128128
<sortfilter/>
129129
</filterchain>
130130
</loadfile>
131-
<echo message="# dependencies:${line.separator}${filtered.dependencies}" file="${cli.dependencies}" />
131+
<echo message="# dependencies:&#xA;${filtered.dependencies}" file="${cli.dependencies}" />
132+
<fixcrlf srcdir="${project.build.outputDirectory}" includes="dependencies.properties" eol="lf" />
132133
</target>
133134
</configuration>
134135
</execution>
@@ -165,6 +166,28 @@
165166
</execution>
166167
</executions>
167168
</plugin>
169+
<plugin>
170+
<groupId>org.apache.maven.plugins</groupId>
171+
<artifactId>maven-jar-plugin</artifactId>
172+
<version>${maven-jar-plugin.version}</version>
173+
<executions>
174+
<execution>
175+
<id>default-jar</id>
176+
<phase>package</phase>
177+
<goals>
178+
<goal>jar</goal>
179+
</goals>
180+
</execution>
181+
</executions>
182+
<configuration>
183+
<archive>
184+
<manifestEntries>
185+
<Automatic-Module-Name>${Module-Name}</Automatic-Module-Name>
186+
</manifestEntries>
187+
<addMavenDescriptor>false</addMavenDescriptor>
188+
</archive>
189+
</configuration>
190+
</plugin>
168191
<plugin>
169192
<groupId>org.apache.maven.plugins</groupId>
170193
<artifactId>maven-assembly-plugin</artifactId>
@@ -186,19 +209,6 @@
186209
</execution>
187210
</executions>
188211
</plugin>
189-
190-
<plugin>
191-
<groupId>org.apache.maven.plugins</groupId>
192-
<artifactId>maven-jar-plugin</artifactId>
193-
<version>${maven-jar-plugin.version}</version>
194-
<configuration>
195-
<archive>
196-
<manifestEntries>
197-
<Automatic-Module-Name>${Module-Name}</Automatic-Module-Name>
198-
</manifestEntries>
199-
</archive>
200-
</configuration>
201-
</plugin>
202212
</plugins>
203213
</build>
204214
</project>

0 commit comments

Comments
 (0)