Skip to content

Commit 367ffb8

Browse files
committed
Add type-specific builds and CI infrastructure
This commit adds infrastructure for type-specific builds across all orchestration scripts and extends the GitHub Actions CI pipeline to build and test both legacy and m4 variants in parallel. Key changes: Orchestration script enhancements: - Add optional <type> parameter to all orchestration scripts - Support execution in type-specific subdirectories (e.g., example_xyz/m4/) - Use lowercase variable name 'type' (shell convention for local vars) - Special handling in all.sh for type dirs without all.sh script - Maintain backward compatibility (no type = default behavior) - Enhanced error handling and progress tracking Central documentation: - Add "Type-Specific Builds" section to README.adoc - Document usage: ./allcompile.sh m4, ./allverify.sh m4 --only - List currently implemented type: m4 (Maven 4 migrations) - Mention future possibilities: m3, gradle-alt - Explain artifact isolation and directory structure GitHub Actions workflow: - Add dedicated shellcheck job (ubuntu-latest only) * Validate orchestration scripts (all*.sh) * Validate m4 example scripts (*/m4/*.sh) - Restructure into 3-job pipeline: shellcheck → build-legacy + build-m4 → docs - Both build jobs depend on shellcheck completion - Maven 4 build configuration: * Use s4u/setup-maven-action@v4 for combined Maven 4 + JDK 17 setup * JDK 17 as default JAVA_HOME (required for Maven 4 runtime) * JDK 11 available for compatibility (JAVA11_HOME) - Type-specific artifact uploads: run-results-{legacy|m4}-{os} - Docs job depends on both builds and downloads both artifact sets Modified files: - .github/workflows/build.yml: 3-job parallel pipeline (+169/-24 lines) - README.adoc: Type-specific builds documentation - jigsaw-examples/all*.sh: Type parameter support (5 scripts) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Introduced in the course of support-and-care/maven-support-and-care#137
1 parent 05f029d commit 367ffb8

File tree

7 files changed

+369
-69
lines changed

7 files changed

+369
-69
lines changed

.github/workflows/build.yml

Lines changed: 177 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,36 @@ on:
66
workflow_dispatch:
77

88
jobs:
9-
build:
10-
name: Build on ${{ matrix.os }}
9+
shellcheck:
10+
name: Shellcheck
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Install shellcheck
18+
run: |
19+
sudo apt-get update
20+
sudo apt-get install -y shellcheck
21+
22+
- name: Run shellcheck on orchestration scripts
23+
shell: bash
24+
run: cd jigsaw-examples && shellcheck -ax all*.sh
25+
26+
- name: Run shellcheck on m4 scripts
27+
shell: bash
28+
run: |
29+
cd jigsaw-examples
30+
for m4_dir in */m4; do
31+
echo "=== Checking ${m4_dir} ==="
32+
(cd "${m4_dir}" && shellcheck -ax *.sh)
33+
done
34+
35+
build-legacy:
36+
name: Build (legacy) on ${{ matrix.os }}
1137
runs-on: ${{ matrix.os }}
38+
needs: shellcheck
1239

1340
strategy:
1441
fail-fast: false
@@ -22,24 +49,6 @@ jobs:
2249
- name: Checkout repository
2350
uses: actions/checkout@v4
2451

25-
- name: Install shellcheck (Ubuntu)
26-
if: runner.os == 'Linux'
27-
run: |
28-
sudo apt-get update
29-
sudo apt-get install -y shellcheck
30-
31-
- name: Install shellcheck (macOS)
32-
if: runner.os == 'macOS'
33-
run: brew install shellcheck
34-
35-
- name: Install shellcheck (Windows)
36-
if: runner.os == 'Windows'
37-
run: choco install shellcheck --no-progress
38-
39-
- name: Run shellcheck on shell scripts
40-
shell: bash
41-
run: cd jigsaw-examples && shellcheck -ax all*.sh
42-
4352
- name: Set up JDK 8 (non macOS)
4453
id: setup-jdk8
4554
uses: actions/setup-java@v5
@@ -169,14 +178,150 @@ jobs:
169178
if: always()
170179
uses: actions/upload-artifact@v4
171180
with:
172-
name: run-results-${{ matrix.os }}
181+
name: run-results-legacy-${{ matrix.os }}
173182
path: jigsaw-examples/*/run-result
174183
if-no-files-found: ignore
175184

185+
build-m4:
186+
name: Build (m4) on ${{ matrix.os }}
187+
runs-on: ${{ matrix.os }}
188+
needs: shellcheck
189+
190+
strategy:
191+
fail-fast: false
192+
matrix:
193+
os: [ubuntu-latest, macos-latest, windows-latest]
194+
195+
steps:
196+
- name: Disable CRLF conversion
197+
run: git config --global core.autocrlf false
198+
199+
- name: Checkout repository
200+
uses: actions/checkout@v4
201+
202+
- name: Set up JDK 11
203+
id: setup-jdk11
204+
uses: actions/setup-java@v5
205+
with:
206+
distribution: 'temurin'
207+
java-version: '11.0.28'
208+
209+
- name: Set up Maven 4 with JDK 17
210+
id: setup-maven4
211+
uses: s4u/setup-maven-action@v1.19.0
212+
with:
213+
java-version: '17'
214+
java-distribution: 'temurin'
215+
maven-version: '4.0.0-rc-4'
216+
217+
- name: Create .envrc with Java and Maven paths
218+
shell: bash
219+
env:
220+
JAVA11_PATH: ${{ steps.setup-jdk11.outputs.path }}
221+
JAVA17_PATH: ${{ steps.setup-maven4.outputs.java-home }}
222+
MAVEN4_PATH: ${{ steps.setup-maven4.outputs.maven-home }}
223+
run: |
224+
# Convert Windows paths to Unix paths if on Windows
225+
if [[ "$RUNNER_OS" == "Windows" ]]; then
226+
JAVA11_PATH="$(cygpath -u "$JAVA11_PATH")"
227+
JAVA17_PATH="$(cygpath -u "$JAVA17_PATH")"
228+
MAVEN4_PATH="$(cygpath -u "$MAVEN4_PATH")"
229+
fi
230+
231+
cat > .envrc << EOF
232+
# Environment configuration for Java 9 Jigsaw Examples (Maven 4 builds)
233+
# Auto-generated by GitHub Actions
234+
235+
# Path to JDK 17 (default for Maven 4 builds)
236+
export JAVA17_HOME=$JAVA17_PATH
237+
238+
# Path to JDK 17 is the default JAVA_HOME for Maven 4
239+
export JAVA_HOME=$JAVA17_PATH
240+
241+
# Path to JDK 11 (for compatibility with examples that need it)
242+
export JAVA11_HOME=$JAVA11_PATH
243+
244+
# Path to Maven 4 (required for m4 builds)
245+
export M4_HOME=$MAVEN4_PATH
246+
247+
# Add Java to PATH
248+
export PATH="\$JAVA_HOME/bin:\$PATH"
249+
EOF
250+
251+
echo "=== Created .envrc file ==="
252+
cat .envrc
253+
254+
- name: Verify Java and Maven setup
255+
shell: bash
256+
run: |
257+
set -eu
258+
259+
source .envrc
260+
261+
echo "=== Verifying JDK 17 (default) ==="
262+
PATH="$JAVA_HOME/bin:$PATH"
263+
java -version
264+
echo "✓ JDK 17 is available at: $JAVA_HOME"
265+
echo "✓ JDK 17 is also at: $JAVA17_HOME"
266+
267+
echo ""
268+
echo "=== Verifying JDK 11 (compatibility) ==="
269+
PATH="$JAVA11_HOME/bin:$PATH"
270+
java -version
271+
echo "✓ JDK 11 is available at: $JAVA11_HOME"
272+
273+
echo ""
274+
echo "=== Verifying Maven 4 ==="
275+
mvn --version
276+
echo "✓ Maven 4 is available at: $M4_HOME"
277+
278+
- name: Compile all m4 Samples
279+
shell: bash
280+
run: |
281+
source .envrc
282+
cd jigsaw-examples
283+
./allcompile.sh m4
284+
285+
- name: Run all m4 Samples
286+
shell: bash
287+
run: |
288+
source .envrc
289+
cd jigsaw-examples
290+
./allrun.sh m4
291+
292+
- name: Verify all m4 Samples
293+
shell: bash
294+
run: |
295+
source .envrc
296+
cd jigsaw-examples
297+
./allverify.sh m4 --only
298+
299+
- name: Collect failure information
300+
if: failure()
301+
shell: bash
302+
run: |
303+
echo "Environment:"
304+
env | sort
305+
echo "=== Listing contents of RUNNER_TOOL_CACHE ==="
306+
if test "$(uname)" == "Windows_NT"; then
307+
ls -l "$RUNNER_TOOL_CACHE" "$RUNNER_TOOL_CACHE\\*" "$RUNNER_TOOL_CACHE\\Java*\\*"
308+
else
309+
ls -l "$RUNNER_TOOL_CACHE" "$RUNNER_TOOL_CACHE/*" "$RUNNER_TOOL_CACHE/Java*/*"
310+
fi
311+
echo
312+
313+
- name: Upload run results
314+
if: always()
315+
uses: actions/upload-artifact@v4
316+
with:
317+
name: run-results-m4-${{ matrix.os }}
318+
path: jigsaw-examples/*/m4/run-result
319+
if-no-files-found: ignore
320+
176321
docs:
177322
name: Generate and Deploy Documentation
178323
runs-on: ubuntu-latest
179-
needs: build
324+
needs: [build-legacy, build-m4]
180325
if: "!cancelled()"
181326

182327
permissions:
@@ -195,11 +340,19 @@ jobs:
195340
distribution: 'temurin'
196341
java-version: '17'
197342

198-
- name: Download Linux run results for documentation
343+
- name: Download Linux legacy run results for documentation
344+
uses: actions/download-artifact@v4
345+
with:
346+
name: run-results-legacy-ubuntu-latest
347+
path: jigsaw-examples
348+
continue-on-error: true
349+
350+
- name: Download Linux m4 run results for documentation
199351
uses: actions/download-artifact@v4
200352
with:
201-
name: run-results-ubuntu-latest
353+
name: run-results-m4-ubuntu-latest
202354
path: jigsaw-examples
355+
continue-on-error: true
203356

204357
- name: Generate documentation
205358
run: ./mvnw verify

README.adoc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,41 @@ If you run all stuff on *nix, use a colon : .
119119
* *Either* call one of the scripts on the top level, i.e., one of `allclean.sh`, `allcompile.sh`, `allcreatevis.sh` and `allrun.sh` (or `all.sh` for all in one step).
120120
* *Alternatively*, cd to one of the examples and call one of the scripts there (again `all.sh` for all in one step).
121121

122+
==== Type-Specific Builds
123+
124+
Many examples support multiple build approaches in separate subdirectories (e.g., `m4/` for Maven 4 migrations).
125+
All orchestration scripts accept an optional `<type>` parameter to execute builds in these subdirectories:
126+
127+
[source,bash]
128+
----
129+
# Standard behavior - runs examples in example_xyz/
130+
cd jigsaw-examples
131+
./allcompile.sh
132+
./allverify.sh
133+
134+
# Type-specific behavior - runs examples in example_xyz/m4/
135+
./allcompile.sh m4
136+
./allverify.sh m4
137+
./allrun.sh m4
138+
./all.sh m4
139+
140+
# Verify with flags
141+
./allverify.sh m4 --only # Skip rebuild, only verify
142+
----
143+
144+
*Available types:*
145+
146+
* `m4` - Maven 4 migrations using Module Source Hierarchy
147+
* `m3` - (Future) Maven 3 alternative approaches
148+
* `gradle-alt` - (Future) Gradle build alternatives
149+
150+
*How it works:*
151+
152+
* Without a type parameter: Scripts execute in `example_xyz/` (original build)
153+
* With a type parameter: Scripts execute in `example_xyz/<type>/` (type-specific build)
154+
* Examples without the specified type directory are automatically skipped
155+
* Output shows which variant is being executed (e.g., "Compiling example_hiddenmain/m4")
156+
122157
[[golden-master-testing]]
123158
=== Golden Master Testing
124159

jigsaw-examples/all.sh

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,49 @@
11
#!/usr/bin/env bash
2+
3+
set -eu -o pipefail
4+
5+
# Parse optional <type> parameter (e.g., "m4", "m3")
6+
type="${1:-}"
7+
28
all() {
39
MODDIR=${dir%*/}
4-
pushd "${MODDIR}" > /dev/null 2>&1 || exit
5-
if [ -f ./all.sh ]
6-
then
10+
if [ -n "${type}" ]; then
11+
# Type-specific: example_xyz/m4/
12+
ALL_DIR="${MODDIR}/${type}"
13+
else
14+
# Default: example_xyz/
15+
ALL_DIR="${MODDIR}"
16+
fi
17+
18+
if [ ! -d "${ALL_DIR}" ]; then
19+
return
20+
fi
21+
22+
pushd "${ALL_DIR}" > /dev/null 2>&1 || exit
23+
if [ -f ./all.sh ]
24+
then
725
echo "###################################################################################################################################"
8-
echo "All in ${MODDIR}"
26+
echo "All in ${MODDIR}${type:+/$type}"
927
./all.sh
28+
elif [ -n "${type}" ]; then
29+
# For type-specific directories without all.sh, run individual scripts
30+
echo "###################################################################################################################################"
31+
echo "All in ${MODDIR}/${type} (clean, compile, run)"
32+
if [ -f ./clean.sh ]; then
33+
./clean.sh
34+
fi
35+
if [ -f ./compile.sh ]; then
36+
./compile.sh
37+
fi
38+
if [ -f ./run.sh ]; then
39+
./run.sh
40+
fi
1041
fi
1142
popd >/dev/null 2>&1 || exit
1243
echo " "
1344
}
1445

15-
for dir in example_*/;
46+
for dir in example_*/;
1647
do
1748
all
1849
done

jigsaw-examples/allclean.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
11
#!/usr/bin/env bash
2+
3+
set -eu -o pipefail
4+
5+
# Parse optional <type> parameter (e.g., "m4", "m3")
6+
type="${1:-}"
7+
28
clean() {
39
MODDIR=${dir%*/}
4-
pushd "${MODDIR}" > /dev/null 2>&1 || exit
5-
if [ -f ./clean.sh ]
6-
then
10+
if [ -n "${type}" ]; then
11+
# Type-specific: example_xyz/m4/
12+
CLEAN_DIR="${MODDIR}/${type}"
13+
else
14+
# Default: example_xyz/
15+
CLEAN_DIR="${MODDIR}"
16+
fi
17+
18+
if [ ! -d "${CLEAN_DIR}" ]; then
19+
return
20+
fi
21+
22+
pushd "${CLEAN_DIR}" > /dev/null 2>&1 || exit
23+
if [ -f ./clean.sh ]
24+
then
725
echo "###################################################################################################################################"
8-
echo "Cleaning ${MODDIR}"
26+
echo "Cleaning ${MODDIR}${type:+/$type}"
927
./clean.sh
1028
echo " "
1129
fi

0 commit comments

Comments
 (0)