Skip to content

Commit 91b190b

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 91b190b

File tree

2 files changed

+90
-14
lines changed

2 files changed

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