-
Notifications
You must be signed in to change notification settings - Fork 0
230 lines (203 loc) · 9.18 KB
/
Copy pathtest-spring-nmvn.yml
File metadata and controls
230 lines (203 loc) · 9.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# Build the nmvn image per Spring Boot version and variant (crema/non-crema) and smoke-test
# it: every supported example project under examples/spring/<version>/ must build with the
# freshly built binary (./test-nmvn-examples.sh, goals: clean package -DskipTests=true).
# Projects a variant cannot support carry a .nmvn-unsupported-variants marker and are skipped
# by the smoke test for that variant.
#
# Scope (deliberately smaller than release-spring-nmvn.yml, which this mirrors step-for-step):
# - same platform matrix as the release workflow, crossed with the Boot versions and
# variants (crema/non-crema) — one image build per platform x Boot version x variant
# job, all in parallel
#
# Known flake: the native-image builder can die with "NativeImageForkJoinWorkerThread not
# available in this platform" — a GraalVM builder race, not caused by any change under test.
# Re-run the job.
#
name: Test Spring Native Maven
on:
workflow_dispatch:
pull_request:
branches:
- develop
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions: {}
env:
# https://github.com/graalvm/graalvm-ce-builds/releases/tag/graal-25.2.4
GRAAL_TAG: graal-25.2.4
jobs:
build-and-test:
strategy:
fail-fast: false
matrix:
boot: ["4.1.0", "4.0.7"]
variant: ["crema", "non-crema"]
os:
- ubuntu-latest-16-cores
- ubuntu-latest-32-cores-arm64
- macos-arm64-cipool
- windows-latest-16-cores
# Attach platform/graal_file to each os (merged into every boot x os x variant combination).
include:
- os: ubuntu-latest-16-cores
platform: linux-x86_64
graal_file: graalvm-community-jdk-25i2-25.0.4_linux-x64_bin.tar.gz
- os: ubuntu-latest-32-cores-arm64
platform: linux-aarch64
graal_file: graalvm-community-jdk-25i2-25.0.4_linux-aarch64_bin.tar.gz
- os: macos-arm64-cipool
platform: macos-aarch64
graal_file: graalvm-community-jdk-25i2-25.0.4_macos-aarch64_bin.tar.gz
- os: windows-latest-16-cores
platform: windows-x86_64
graal_file: graalvm-community-jdk-25i2-25.0.4_windows-x64_bin.zip
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download and install GraalVM 25.2
run: |
set -euo pipefail
GRAAL_URL="https://github.com/graalvm/graalvm-ce-builds/releases/download/${GRAAL_TAG}/${{ matrix.graal_file }}"
INSTALL_ROOT="${RUNNER_TEMP:-/tmp}/graalvm-25.2"
ARCHIVE="${RUNNER_TEMP:-/tmp}/${{ matrix.graal_file }}"
echo ">>> Downloading ${GRAAL_URL}"
rm -rf "${INSTALL_ROOT}"
mkdir -p "${INSTALL_ROOT}"
curl -fsSL "${GRAAL_URL}" -o "${ARCHIVE}"
case "${{ matrix.graal_file }}" in
*.zip)
if command -v unzip >/dev/null 2>&1; then
unzip -q "${ARCHIVE}" -d "${INSTALL_ROOT}"
else
pwsh -NoProfile -Command "Expand-Archive -Path '${ARCHIVE}' -DestinationPath '${INSTALL_ROOT}' -Force"
fi
;;
*)
tar -xzf "${ARCHIVE}" -C "${INSTALL_ROOT}"
;;
esac
# Locate JAVA_HOME (macOS: Contents/Home; Linux/Windows: unpacked root).
JAVA_HOME_CANDIDATE=""
for d in "${INSTALL_ROOT}"/*/Contents/Home "${INSTALL_ROOT}"/*/*/Contents/Home; do
if [ -f "${d}/bin/native-image" ] || [ -f "${d}/bin/native-image.cmd" ] || [ -f "${d}/bin/native-image.exe" ]; then
JAVA_HOME_CANDIDATE="$d"
break
fi
done
if [ -z "${JAVA_HOME_CANDIDATE}" ]; then
for d in "${INSTALL_ROOT}"/*; do
if [ -d "$d" ] && { [ -f "${d}/bin/native-image" ] || [ -f "${d}/bin/native-image.cmd" ] || [ -f "${d}/bin/native-image.exe" ]; }; then
JAVA_HOME_CANDIDATE="$d"
break
fi
done
fi
if [ -z "${JAVA_HOME_CANDIDATE}" ]; then
echo "::error::Could not find native-image under ${INSTALL_ROOT}"
find "${INSTALL_ROOT}" -maxdepth 5 -type f \( -name 'native-image' -o -name 'native-image.cmd' -o -name 'native-image.exe' \) 2>/dev/null | head -20 || true
exit 1
fi
# Git Bash on Windows: store Unix-style JAVA_HOME for later bash steps.
if command -v cygpath >/dev/null 2>&1; then
JAVA_HOME_CANDIDATE="$(cygpath -u "${JAVA_HOME_CANDIDATE}")"
fi
# Subsequent steps inherit these (GITHUB_ENV / GITHUB_PATH).
echo "JAVA_HOME=${JAVA_HOME_CANDIDATE}" >> "$GITHUB_ENV"
echo "${JAVA_HOME_CANDIDATE}/bin" >> "$GITHUB_PATH"
echo ">>> JAVA_HOME=${JAVA_HOME_CANDIDATE}"
- name: Strip SNAPSHOT from versions
run: LC_ALL=C find . -name 'pom.xml' -exec sed -i'' -e 's/-SNAPSHOT//g' {} +
- name: Build Maven distribution
run: |
# Git Bash on Windows: hand Maven a Windows-style path (C:/...), not /c/....
REPO_ROOT="$PWD"
if command -v cygpath >/dev/null 2>&1; then
REPO_ROOT="$(cygpath -m "$REPO_ROOT")"
fi
chmod +x ./mvnw
./mvnw clean install -B -DskipTests -Drat.skip=true -Dcheckstyle.skip=true -DdistributionTargetDir="$REPO_ROOT/apache-maven/target/apache-maven-4.1.0-SNAPSHOT"
- name: Run Native Maven Distribution in JVM mode
run: |
REPO_ROOT="$PWD"
if command -v cygpath >/dev/null 2>&1; then
REPO_ROOT="$(cygpath -m "$REPO_ROOT")"
fi
chmod +x ./mvnw
./mvnw -f native/launcher exec:exec -Dexec.appArgs="-f $REPO_ROOT/examples/java-maven-sample-project/ clean package"
- name: Build ${{ matrix.variant }} image for Boot ${{ matrix.boot }}
run: |
set -euo pipefail
chmod +x catalog/resolve_boot_catalog.py ./mvnw
rm -rf build
./catalog/resolve_boot_catalog.py \
--boot-version "${{ matrix.boot }}" \
--language java
# Variant → Maven profiles; the image build is the launcher's native profile
# (build-scripts/ are no longer involved).
PROFILES="native"
[ "${{ matrix.variant }}" = "crema" ] && PROFILES="native,crema"
# ABSOLUTE paths only: Maven resolves relative Path mojo parameters against the MODULE
# basedir (native/launcher), not the invocation dir. Dist dir by glob: this workflow
# strips -SNAPSHOT from the poms, so the profile's ${project.version}-derived default
# would miss; Windows java needs a C:/ style path (cygpath -m).
REPO_ROOT="$PWD"
if command -v cygpath >/dev/null 2>&1; then
REPO_ROOT="$(cygpath -m "$REPO_ROOT")"
fi
MAVEN_DIST=""
for d in apache-maven/target/apache-maven-*; do
[ -d "$d/lib" ] && MAVEN_DIST="$REPO_ROOT/$d" && break
done
NAME="nmvn-spring-${{ matrix.boot }}"
./mvnw -P"$PROFILES" package -pl native/launcher -am -B -DskipTests \
-Dnmvn.pluginsFile="$REPO_ROOT/build/catalogs/${NAME}.plugins" \
-Dnmvn.imageName="${NAME}" \
-Dnmvn.mavenHome="$MAVEN_DIST"
# The image lands in the module's target dir; later steps expect build/.
if [ -f "native/launcher/target/${NAME}.exe" ]; then
mv "native/launcher/target/${NAME}.exe" build/
else
mv "native/launcher/target/${NAME}" build/
fi
BIN="build/nmvn-spring-${{ matrix.boot }}"
if [ -f "${BIN}.exe" ]; then
BIN="${BIN}.exe"
fi
if [ ! -f "${BIN}" ]; then
echo "::error::Expected binary ${BIN} after build for Boot ${{ matrix.boot }}"
ls -la build/ || true
exit 1
fi
# Hand the resolved name (with .exe on Windows) to the smoke-test step.
echo "NMVN_BIN=${BIN}" >> "$GITHUB_ENV"
- name: Smoke-test examples/spring against the image
run: |
set -euo pipefail
chmod +x test-nmvn-examples.sh
./test-nmvn-examples.sh \
--spring "${{ matrix.boot }}" \
--nmvn-binary "${NMVN_BIN}" \
--variant "${{ matrix.variant }}" \
--keep-going
# E2E: examples/jvm-fallback-project binds non-baked plugins (enforcer, antrun) into a
# real `clean package`; those goals must run via the in-process HotSpot JVM, produce
# their on-disk effects, and propagate failures. See test-nmvn-jvm-fallback.sh.
- name: Exercise the JVM fallback (e2e build with non-baked plugins)
if: ${{ matrix.variant == 'non-crema' }}
run: |
set -euo pipefail
chmod +x test-nmvn-jvm-fallback.sh
./test-nmvn-jvm-fallback.sh \
--nmvn-binary "${NMVN_BIN}" \
--maven-home "$PWD/apache-maven/target/apache-maven-4.1.0-SNAPSHOT" \
--variant "${{ matrix.variant }}"
- name: Clean workspace outputs
if: always()
run: rm -rf build