Skip to content

Commit 167f481

Browse files
Optimize CI by using a custom Docker container with pre-installed dependencies.
This change introduces a Docker container (`.ci/container/Dockerfile`) that pre-installs: - OpenJDK 8 (ZuluFX), 11, 17, 21, and 25 (Zulu). - Android SDK (command-line tools, platform-tools, build-tools) and NDK dependencies. - Ant, Maven, Python 3. - Codename One binaries (`cn1-binaries`). - Required libraries for headless UI testing (xvfb, libgl1-mesa-dri, libncurses6). Updates `pr.yml`, `ant.yml`, and `scripts-android.yml` to run jobs inside this container (`ghcr.io/codenameone/codenameone/ci-container:latest`), removing redundant setup steps (JDK download, tool installation) to improve build speed and reproducibility. The workflow `.github/workflows/build-container.yml` is added to build and push this container image to GHCR, ensuring the image tag is always lowercase to comply with registry requirements. Also updates `scripts/setup-workspace.sh` to respect the `CN1_BINARIES` environment variable and handle the pre-configured environment correctly. Explicit `packages: read` permissions are added to `pr.yml`, `ant.yml`, and `scripts-android.yml` to allow pulling the CI container from GHCR.
1 parent 9189a20 commit 167f481

File tree

10 files changed

+68
-352
lines changed

10 files changed

+68
-352
lines changed

.github/workflows/ant.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
paths-ignore:
88
- 'CodenameOneDesigner/**'
99

10+
permissions:
11+
contents: read
12+
packages: read
13+
1014
jobs:
1115
build-linux-jdk8:
1216

.github/workflows/pr.yml

Lines changed: 14 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -32,33 +32,17 @@ permissions:
3232
contents: write
3333
pull-requests: write
3434
issues: write
35+
packages: read
3536

3637
jobs:
37-
build-test:
38+
build-linux-jdk8-fx:
3839

3940
runs-on: ubuntu-latest
4041
container:
4142
image: ghcr.io/codenameone/codenameone/ci-container:latest
4243

43-
strategy:
44-
fail-fast: false
45-
matrix:
46-
java-version: [8, 17, 21, 25]
47-
4844
steps:
4945
- uses: actions/checkout@v1
50-
- name: Set up JDK 8
51-
if: matrix.java-version == 8
52-
uses: actions/setup-java@v1
53-
with:
54-
java-version: 1.8
55-
java-package: jdk+fx
56-
- name: Set up JDK
57-
if: matrix.java-version != 8
58-
uses: actions/setup-java@v4
59-
with:
60-
distribution: 'zulu'
61-
java-version: ${{ matrix.java-version }}
6246
- name: Cache Maven dependencies
6347
uses: actions/cache@v4
6448
with:
@@ -68,12 +52,8 @@ jobs:
6852
${{ runner.os }}-m2
6953
- name: Run Unit Tests
7054
run: |
71-
MVN_ARGS=""
72-
if [ "${{ matrix.java-version }}" != "8" ]; then
73-
MVN_ARGS="-Dspotbugs.skip=true"
74-
fi
7555
cd maven
76-
mvn clean verify -DunitTests=true -pl core-unittests -am -Dmaven.javadoc.skip=true -Plocal-dev-javase $MVN_ARGS
56+
mvn clean verify -DunitTests=true -pl core-unittests -am -Dmaven.javadoc.skip=true -Plocal-dev-javase
7757
cd ..
7858
- name: Run Maven plugin tests
7959
working-directory: maven
@@ -86,7 +66,7 @@ jobs:
8666
-Dcn1.binaries="${CN1_BINARIES}" \
8767
-pl codenameone-maven-plugin -am -Plocal-dev-javase test
8868
- name: Generate static analysis HTML summaries
89-
if: ${{ always() && matrix.java-version == 8 }}
69+
if: ${{ always() }}
9070
env:
9171
QUALITY_REPORT_TARGET_DIRS: maven/core-unittests/target
9272
QUALITY_REPORT_SERVER_URL: ${{ github.server_url }}
@@ -95,7 +75,7 @@ jobs:
9575
QUALITY_REPORT_GENERATE_HTML_ONLY: "1"
9676
run: python3 .github/scripts/generate-quality-report.py
9777
- name: Collect quality artifacts
98-
if: ${{ always() && matrix.java-version == 8 }}
78+
if: ${{ always() }}
9979
run: |
10080
set -euo pipefail
10181
mkdir -p quality-artifacts/static-analysis
@@ -123,14 +103,14 @@ jobs:
123103
echo "No quality artifacts were generated." > quality-artifacts/README.txt
124104
fi
125105
- name: Upload quality artifacts
126-
if: ${{ always() && matrix.java-version == 8 }}
106+
if: ${{ always() }}
127107
id: upload-quality-artifacts
128108
uses: actions/upload-artifact@v4
129109
with:
130110
name: quality-artifacts
131111
path: quality-artifacts
132112
- name: Publish quality report previews
133-
if: ${{ always() && matrix.java-version == 8 && github.server_url == 'https://github.com' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
113+
if: ${{ always() && github.server_url == 'https://github.com' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }}
134114
id: publish-quality-previews
135115
env:
136116
GITHUB_TOKEN: ${{ github.token }}
@@ -196,7 +176,7 @@ jobs:
196176
echo "jacoco_url=${preview_base}/coverage/index.html" >> "$GITHUB_OUTPUT"
197177
fi
198178
- name: Generate quality report summary
199-
if: ${{ always() && matrix.java-version == 8 }}
179+
if: ${{ always() }}
200180
env:
201181
QUALITY_REPORT_TARGET_DIRS: maven/core-unittests/target
202182
QUALITY_REPORT_SERVER_URL: ${{ github.server_url }}
@@ -212,13 +192,13 @@ jobs:
212192
JACOCO_HTML_URL: ${{ steps.publish-quality-previews.outputs.jacoco_url }}
213193
run: python3 .github/scripts/generate-quality-report.py
214194
- name: Upload quality report summary
215-
if: ${{ always() && matrix.java-version == 8 }}
195+
if: ${{ always() }}
216196
uses: actions/upload-artifact@v4
217197
with:
218198
name: quality-report
219199
path: quality-report.md
220200
- name: Publish quality report comment
221-
if: ${{ github.event_name == 'pull_request' && matrix.java-version == 8 }}
201+
if: ${{ github.event_name == 'pull_request' }}
222202
uses: actions/github-script@v7
223203
with:
224204
script: |
@@ -229,28 +209,13 @@ jobs:
229209
ln -sf $CN1_BINARIES ../cn1-binaries
230210
- name: Build with Ant
231211
run: xvfb-run ant test-javase
232-
233212
- name: Build CLDC11 JAR
234-
run: |
235-
ANT_OPTS_ARGS=""
236-
if [ "${{ matrix.java-version }}" != "8" ]; then
237-
ANT_OPTS_ARGS="-Djavac.source=1.8 -Djavac.target=1.8"
238-
fi
239-
ant $ANT_OPTS_ARGS -noinput -buildfile Ports/CLDC11/build.xml jar
240-
- name: Build with Ant
241-
run: |
242-
ANT_OPTS_ARGS=""
243-
if [ "${{ matrix.java-version }}" != "8" ]; then
244-
ANT_OPTS_ARGS="-Djavac.source=1.8 -Djavac.target=1.8"
245-
fi
246-
xvfb-run ant $ANT_OPTS_ARGS test-javase
213+
run: ant -noinput -buildfile Ports/CLDC11/build.xml jar
247214

248215
- name: Build Release
249-
if: matrix.java-version == 8
250216
run: ant -noinput -buildfile CodenameOne/build.xml weeklyLibUpdate
251217

252218
- name: Build JavaDocs
253-
if: matrix.java-version == 8
254219
run: |
255220
cd CodenameOne
256221
mkdir -p build
@@ -265,18 +230,12 @@ jobs:
265230
cd ..
266231
267232
- name: Build iOS Port
268-
run: |
269-
ANT_OPTS_ARGS=""
270-
if [ "${{ matrix.java-version }}" != "8" ]; then
271-
ANT_OPTS_ARGS="-Djavac.source=1.8 -Djavac.target=1.8"
272-
fi
273-
ant $ANT_OPTS_ARGS -noinput -buildfile Ports/iOSPort/build.xml jar
233+
run: ant -noinput -buildfile Ports/iOSPort/build.xml jar
274234

275235
- name: Build iOS VM API
276236
run: mvn -f vm/JavaAPI/pom.xml package
277237

278238
- name: Upload a Build Artifact
279-
if: matrix.java-version == 8
280239
uses: actions/upload-artifact@v4
281240
with:
282241
name: JavaAPI.jar
@@ -286,41 +245,27 @@ jobs:
286245
run: mvn -f vm/ByteCodeTranslator/pom.xml package
287246

288247
- name: Build CLDC 11 VM
289-
run: |
290-
ANT_OPTS_ARGS=""
291-
if [ "${{ matrix.java-version }}" != "8" ]; then
292-
ANT_OPTS_ARGS="-Djavac.source=1.8 -Djavac.target=1.8"
293-
fi
294-
ant $ANT_OPTS_ARGS -noinput -buildfile Ports/CLDC11/build.xml jar
248+
run: ant -noinput -buildfile Ports/CLDC11/build.xml jar
295249

296250
- name: Upload a Build Artifact
297-
if: matrix.java-version == 8
298251
uses: actions/upload-artifact@v4
299252
with:
300253
name: ByteCodeTranslator.jar
301254
path: vm/ByteCodeTranslator/target/ByteCodeTranslator-1.0-SNAPSHOT.jar
302255

303256
- name: Upload a Build Artifact
304-
if: matrix.java-version == 8
305257
uses: actions/upload-artifact@v4
306258
with:
307259
name: CLDC11.jar
308260
path: Ports/CLDC11/dist/CLDC11.jar
309261

310262
- name: Build Android Port
311-
run: |
312-
ANT_OPTS_ARGS=""
313-
if [ "${{ matrix.java-version }}" != "8" ]; then
314-
ANT_OPTS_ARGS="-Djavac.source=1.8 -Djavac.target=1.8"
315-
fi
316-
ant $ANT_OPTS_ARGS -noinput -buildfile Ports/Android/build.xml jar
263+
run: ant -noinput -buildfile Ports/Android/build.xml jar
317264

318265
- name: Packaging Everything
319-
if: matrix.java-version == 8
320266
run: zip -j result.zip CodenameOne/javadocs.zip CodenameOne/dist/CodenameOne.jar CodenameOne/updatedLibs.zip Ports/JavaSE/dist/JavaSE.jar build/CodenameOneDist/CodenameOne/demos/CodenameOne_SRC.zip
321267

322268
- name: Copying Files to Server
323-
if: matrix.java-version == 8
324269
uses: marcodallasanta/[email protected]
325270
with:
326271
host: ${{ secrets.WP_HOST }}
@@ -329,7 +274,6 @@ jobs:
329274
local: result.zip
330275

331276
- name: Upload a Build Artifact
332-
if: matrix.java-version == 8
333277
uses: actions/upload-artifact@v4
334278
with:
335279
name: JavaSE.jar

.github/workflows/scripts-android.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ jobs:
8989
contents: read
9090
pull-requests: write
9191
issues: write
92+
packages: read
9293
runs-on: ubuntu-latest
9394
container:
9495
image: ghcr.io/codenameone/codenameone/ci-container:latest
@@ -100,7 +101,7 @@ jobs:
100101
- uses: actions/checkout@v4
101102
- name: Set JDK_HOME
102103
if: matrix.id != 'default'
103-
run: echo "JDK_HOME=/usr/lib/jvm/zulu-${{ matrix.java_version }}-amd64" >> $GITHUB_ENV
104+
run: echo "JDK_HOME=/usr/lib/jvm/zulu${{ matrix.java_version }}-ca-amd64" >> $GITHUB_ENV
104105
- name: Set JDK_HOME (Default)
105106
if: matrix.id == 'default'
106107
run: echo "JDK_HOME=${JDK8_HOME}" >> $GITHUB_ENV

maven/core/pom.xml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,13 @@
4444
<artifactId>maven-compiler-plugin</artifactId>
4545

4646
<configuration>
47-
<source>${maven.compiler.source}</source>
48-
<target>${maven.compiler.target}</target>
47+
<source>1.5</source>
48+
<target>1.5</target>
4949
</configuration>
5050
</plugin>
5151
</plugins>
5252

5353
</build>
54-
<profiles>
55-
<profile>
56-
<id>modern-jdk</id>
57-
<activation>
58-
<jdk>[9,)</jdk>
59-
</activation>
60-
<properties>
61-
<maven.compiler.source>1.8</maven.compiler.source>
62-
<maven.compiler.target>1.8</maven.compiler.target>
63-
</properties>
64-
</profile>
65-
</profiles>
6654

6755

6856
</project>

maven/parparvm/pom.xml

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
<src.dir>../../vm/ByteCodeTranslator/src</src.dir>
4444

4545
<codename1.javaapi.src.dir>../../vm/JavaAPI/src</codename1.javaapi.src.dir>
46-
<javaapi.compiler.source>1.5</javaapi.compiler.source>
47-
<javaapi.compiler.target>1.5</javaapi.compiler.target>
4846

4947
</properties>
5048

@@ -87,6 +85,15 @@
8785
<plugin>
8886
<groupId>org.apache.maven.plugins</groupId>
8987
<artifactId>maven-antrun-plugin</artifactId>
88+
<dependencies>
89+
<dependency>
90+
<groupId>com.sun</groupId>
91+
<artifactId>tools</artifactId>
92+
<version>1.5.0</version>
93+
<scope>system</scope>
94+
<systemPath>${java.home}/../lib/tools.jar</systemPath>
95+
</dependency>
96+
</dependencies>
9097
<executions>
9198
<execution>
9299
<id>compile-java-api</id>
@@ -98,8 +105,8 @@
98105
<target>
99106
<mkdir dir="${project.build.directory}/api-classes"/>
100107
<javac srcdir="${codename1.javaapi.src.dir}"
101-
source="${javaapi.compiler.source}"
102-
target="${javaapi.compiler.target}"
108+
source="1.5"
109+
target="1.5"
103110
destdir="${project.build.directory}/api-classes"
104111
failonerror="true"
105112
/>
@@ -153,40 +160,5 @@
153160
</plugins>
154161
</build>
155162

156-
<profiles>
157-
<profile>
158-
<id>legacy-jdk-tools</id>
159-
<activation>
160-
<jdk>(,9)</jdk>
161-
</activation>
162-
<build>
163-
<plugins>
164-
<plugin>
165-
<groupId>org.apache.maven.plugins</groupId>
166-
<artifactId>maven-antrun-plugin</artifactId>
167-
<dependencies>
168-
<dependency>
169-
<groupId>com.sun</groupId>
170-
<artifactId>tools</artifactId>
171-
<version>1.5.0</version>
172-
<scope>system</scope>
173-
<systemPath>${java.home}/../lib/tools.jar</systemPath>
174-
</dependency>
175-
</dependencies>
176-
</plugin>
177-
</plugins>
178-
</build>
179-
</profile>
180-
<profile>
181-
<id>modern-jdk</id>
182-
<activation>
183-
<jdk>[9,)</jdk>
184-
</activation>
185-
<properties>
186-
<javaapi.compiler.source>1.8</javaapi.compiler.source>
187-
<javaapi.compiler.target>1.8</javaapi.compiler.target>
188-
</properties>
189-
</profile>
190-
</profiles>
191163

192164
</project>

vm/ByteCodeTranslator/nbproject/project.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ dist.jar=${dist.dir}/ByteCodeTranslator.jar
2929
dist.javadoc.dir=${dist.dir}/javadoc
3030
endorsed.classpath=
3131
excludes=
32-
file.reference.asm-9.8.jar=../../../cn1-binaries/vm/asm-9.8.jar
33-
file.reference.asm-commons-9.8.jar=../../../cn1-binaries/vm/asm-commons-9.8.jar
34-
file.reference.asm-tree-9.8.jar=../../../cn1-binaries/vm/asm-tree-9.8.jar
32+
file.reference.asm-5.0.3.jar=../../../cn1-binaries/vm/asm-9.8.jar
33+
file.reference.asm-commons-5.0.3.jar=../../../cn1-binaries/vm/asm-commons-9.8.jar
34+
file.reference.asm-tree-5.0.3.jar=../../../cn1-binaries/vm/asm-tree-9.8.jar
3535
includes=**
3636
jar.compress=false
3737
javac.classpath=\

0 commit comments

Comments
 (0)