Skip to content

Commit 2f1b70a

Browse files
committed
mega-melt: add in a section for changed components
Empty by default, but configurable to mix in PRs and such.
1 parent 35c5318 commit 2f1b70a

File tree

1 file changed

+123
-1
lines changed

1 file changed

+123
-1
lines changed

tests/run.sh

Lines changed: 123 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,131 @@ chmod +x "$meltingPotScript" &&
114114
test "$(grep -F "[ERROR]" "$meltingPotLog" | grep -v "using default branch")" &&
115115
die 'Melting pot generation failed!'
116116

117+
buildScript="$meltingPotDir/build.sh"
118+
119+
echo
120+
echo 'Hacking in any changed components...'
121+
122+
# Mix in changed components. Syntax is:
123+
#
124+
# groupId|artifactId|path-to-remote|remote-ref
125+
#
126+
# Example:
127+
#
128+
# components='
129+
# org.janelia.saalfeldlab|n5-imglib2|git@github.com:saalfeldlab/n5-imglib2|pull/54/head
130+
# sc.fiji|SPIM_Registration|git@github.com:fiji/SPIM_Registration|pull/142/head
131+
# sc.fiji|labkit-ui|git@github.com:juglab/labkit-ui|pull/115/head
132+
# sc.fiji|labkit-pixel-classification|git@github.com:juglab/labkit-pixel-classification|pull/12/head
133+
# sc.fiji|z_spacing|git@github.com:saalfeldlab/z-spacing|pull/28/head
134+
# net.imagej|imagej-common|git@github.com:imagej/imagej-common|pull/112/head
135+
# sc.fiji|TrackMate|git@github.com:trackmate-sc/TrackMate|pull/289/head
136+
# sc.fiji|TrackMate-Skeleton|git@github.com:trackmate-sc/TrackMate-Skeleton|pull/2/head
137+
# sc.fiji|bigwarp_fiji|git@github.com:saalfeldlab/bigwarp|pull/170/head
138+
# net.imagej|imagej-ops|git@github.com:imagej/imagej-ops|pull/654/head
139+
# '
140+
#
141+
# One entry per line inside the components variable declaration.
142+
# No leading or trailing whitespace anywhere.
143+
#
144+
# Each component will:
145+
# 1. Be updated to that ref (cloning as needed);
146+
# 2. Have its version adjusted to 999 in its pom.xml and gav marker;
147+
# 3. Be `mvn install`ed to the local repo cache at that version;
148+
# 4. Have its version adjusted to 999 in melting pot's build.sh;
149+
# 5. Be added to the list of components to build in melt.sh (if not already present).
150+
components='
151+
'
152+
failFile="$meltingPotDir/fail"
153+
rm -f "$failFile"
154+
echo "$components" | while read component
155+
do
156+
test "$component" || continue
157+
158+
g=${component%%|*}; r=${component#*|}
159+
a=${r%%|*}; r=${r#*|}
160+
remote=${r%%|*}; ref=${r#*|}
161+
test "$g" -a "$a" -a "$remote" -a "$ref" || {
162+
touch "$failFile"
163+
die "Invalid component line: $component"
164+
}
165+
d="$meltingPotDir/$g/$a"
166+
printf "[$g:$a] "
167+
168+
# Update component working copy to desired ref (cloning as needed).
169+
mkdir -p "$d" &&
170+
echo "Log of actions for custom version of $g:$a" > "$d/surgery.log" &&
171+
echo >> "$d/surgery.log" &&
172+
test -f "$d/.git" || git init "$d" >> "$d/surgery.log" || {
173+
touch "$failFile"
174+
die "Failed to access or initialize repository in directory $d"
175+
}
176+
printf .
177+
cd "$d" &&
178+
git remote add mega-melt "$remote" >> surgery.log &&
179+
printf . &&
180+
git fetch mega-melt --depth 1 "$ref":mega-melt >> surgery.log 2>&1 &&
181+
printf . &&
182+
git switch mega-melt >> surgery.log 2>&1 || {
183+
touch "$failFile"
184+
die "$g:$a: failed to fetch ref '$ref' from remote $remote"
185+
}
186+
printf .
187+
188+
# Adjust component version to 999.
189+
mvn versions:set -DnewVersion=999 >> surgery.log || {
190+
touch "$failFile"
191+
die "$g:$a: failed to adjust pom.xml version"
192+
}
193+
printf .
194+
if [ -f gav ]
195+
then
196+
mv gav gav.prehacks
197+
sed -E "s;:[^:]*$;:999;" gav.prehacks > gav || {
198+
touch "$failFile"
199+
die "$g:$a: failed to adjust gav version"
200+
}
201+
fi
202+
printf .
203+
204+
# Install changed component into the local repo cache.
205+
mvn -Denforcer.skip -Dmaven.test.skip install >> surgery.log || {
206+
touch "$failFile"
207+
die "$g:$a: failed to build and install component"
208+
}
209+
printf .
210+
211+
# Adjust component version to 999 in melting pot's build.sh.
212+
cd "$meltingPotDir"
213+
test -f "$buildScript.prehacks" || cp "$buildScript" "$buildScript.prehacks" || {
214+
touch "$failFile"
215+
die "$g:$a: failed to back up $buildScript"
216+
}
217+
printf .
218+
mv -f "$buildScript" "$buildScript.tmp" &&
219+
sed -E "s;(-D($g\\.)?$a\\.version)=[^ ]*;\1=999;g" "$buildScript.tmp" > "$buildScript" || {
220+
touch "$failFile"
221+
die "$g:$a: failed to adjust component version in $buildScript"
222+
}
223+
printf .
224+
225+
# Add component to the build list in melt.sh (if not already present).
226+
grep -q "\b$g/$a\b" "$meltScript" || {
227+
test -f "$meltScript.prehacks" || cp "$meltScript" "$meltScript.prehacks"
228+
mv -f "$meltScript" "$meltScript.tmp" &&
229+
perl -0777 -pe 's;\n+do\n;\n '"$g/$a"' \\$&;igs' "$meltScript.tmp" > "$meltScript"
230+
} || {
231+
touch "$failFile"
232+
die "$g:$a: failed to add component to the build list in $meltScript"
233+
}
234+
printf ".\n"
235+
done
236+
rm -f "$buildScript.tmp" "$meltScript.tmp"
237+
test ! -f "$failFile" ||
238+
die "Failed to hack in changed components!"
239+
117240
sectionStart 'Adjusting the melting pot: build.sh script'
118241

119-
buildScript="$meltingPotDir/build.sh"
120242
cp "$buildScript" "$buildScript.original" &&
121243

122244
# HACK: Remove known-duplicate short version properties, keeping

0 commit comments

Comments
 (0)