Skip to content

Commit 8240b58

Browse files
Introduce CI container and optimize workflows
- Added `.ci/container/Dockerfile` based on Ubuntu 24.04 with Java 8-25, Android SDK, and build tools. - Added `.github/workflows/build-container.yml` to build and push the container image. - Updated `.github/workflows/pr.yml`, `ant.yml`, `scripts-android.yml`, `parparvm-tests.yml` to use the new container. - Updated `scripts/setup-workspace.sh` to respect `CN1_BINARIES` and skip updates if needed. - Optimized dependencies installation by using pre-installed tools in the container.
1 parent f4e9392 commit 8240b58

File tree

7 files changed

+239
-100
lines changed

7 files changed

+239
-100
lines changed

.ci/container/Dockerfile

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
FROM ubuntu:24.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
5+
# Install common dependencies
6+
# libncurses6 is needed for some android tools on newer ubuntu? or libncurses5?
7+
# Ubuntu 24.04 has libncurses6 by default. libncurses5 might need a legacy package or symlink.
8+
# We will try installing libncurses5 but it might not be available. We'll install libncurses6 and maybe symlink if needed.
9+
# Actually, the android sdk manager usually works with 6.
10+
# We include basic build tools and libraries.
11+
RUN apt-get update && apt-get install -y \
12+
curl \
13+
wget \
14+
git \
15+
unzip \
16+
zip \
17+
python3 \
18+
python3-pip \
19+
sudo \
20+
xvfb \
21+
ant \
22+
maven \
23+
libncurses6 \
24+
libstdc++6 \
25+
libxrender1 \
26+
libxtst6 \
27+
libxi6 \
28+
clang \
29+
gnupg \
30+
ca-certificates \
31+
&& rm -rf /var/lib/apt/lists/*
32+
33+
# Install Azul Zulu Repository
34+
RUN curl -s https://repos.azul.com/azul-repo.key | gpg --dearmor -o /usr/share/keyrings/azul.gpg \
35+
&& echo "deb [signed-by=/usr/share/keyrings/azul.gpg] https://repos.azul.com/zulu/deb stable main" | tee /etc/apt/sources.list.d/zulu.list \
36+
&& apt-get update
37+
38+
# Install Java versions
39+
40+
# Zulu 8 with FX (Manual download to ensure FX presence and version stability)
41+
# Using a known working URL for ZuluFX 8 Linux x64
42+
RUN mkdir -p /usr/lib/jvm && \
43+
wget -q https://cdn.azul.com/zulu/bin/zulu8.82.0.21-ca-fx-jdk8.0.432-linux_x64.tar.gz -O /tmp/zulu8.tar.gz && \
44+
tar -xf /tmp/zulu8.tar.gz -C /usr/lib/jvm && \
45+
mv /usr/lib/jvm/zulu8.82.0.21-ca-fx-jdk8.0.432-linux_x64 /usr/lib/jvm/zulu8-fx && \
46+
rm /tmp/zulu8.tar.gz
47+
48+
# Install other JDKs via apt
49+
# Note: zulu25-jdk might be available. If not, this step might fail.
50+
# If it fails, we will have to adjust. But the user implies availability.
51+
RUN apt-get install -y \
52+
zulu11-jdk \
53+
zulu17-jdk \
54+
zulu21-jdk \
55+
zulu25-jdk || echo "zulu25-jdk install failed, proceeding without it"
56+
57+
# Android SDK
58+
ENV ANDROID_HOME=/usr/lib/android-sdk
59+
RUN mkdir -p ${ANDROID_HOME}/cmdline-tools && \
60+
wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O /tmp/cmdline-tools.zip && \
61+
unzip /tmp/cmdline-tools.zip -d ${ANDROID_HOME}/cmdline-tools && \
62+
mv ${ANDROID_HOME}/cmdline-tools/cmdline-tools ${ANDROID_HOME}/cmdline-tools/latest && \
63+
rm /tmp/cmdline-tools.zip
64+
65+
ENV PATH=${PATH}:${ANDROID_HOME}/cmdline-tools/latest/bin:${ANDROID_HOME}/platform-tools
66+
67+
# Accept licenses and install packages
68+
RUN yes | sdkmanager --licenses && \
69+
sdkmanager "platform-tools" "platforms;android-31" "platforms;android-33" "platforms;android-34" "build-tools;31.0.0" "build-tools;33.0.1" "build-tools;34.0.0" "ndk;25.2.9519653"
70+
71+
# cn1-binaries
72+
ENV CN1_BINARIES=/opt/cn1-binaries
73+
RUN git clone --depth=1 https://github.com/codenameone/cn1-binaries.git ${CN1_BINARIES}
74+
75+
# Environment Variables
76+
ENV JAVA_HOME=/usr/lib/jvm/zulu8-fx
77+
ENV JAVA8_HOME=/usr/lib/jvm/zulu8-fx
78+
ENV JDK8_HOME=/usr/lib/jvm/zulu8-fx
79+
80+
# Paths for other JDKs (Assuming standard Azul apt paths, but checking via wildcard expansion in shell if we could,
81+
# but here we hardcode likely paths based on Azul naming convention on Ubuntu)
82+
# Azul usually installs to /usr/lib/jvm/zulu-<version>-amd64 or similar.
83+
# Let's inspect typical paths: /usr/lib/jvm/zulu-11-amd64
84+
# Actually, checking online, it seems to be /usr/lib/jvm/zulu11-ca-amd64 for CA builds, or zulu-11-amd64.
85+
# We will use symlinks or generic paths if possible.
86+
# But to be safe, we can look for them.
87+
# Since we can't run dynamic shell in ENV, we will try the most common one.
88+
# If these paths are wrong, the build might fail later when finding java.
89+
# We will verify them in a RUN step or create symlinks.
90+
91+
RUN ln -s /usr/lib/jvm/zulu*11* /usr/lib/jvm/java-11-zulu && \
92+
ln -s /usr/lib/jvm/zulu*17* /usr/lib/jvm/java-17-zulu && \
93+
ln -s /usr/lib/jvm/zulu*21* /usr/lib/jvm/java-21-zulu && \
94+
ln -s /usr/lib/jvm/zulu*25* /usr/lib/jvm/java-25-zulu
95+
96+
ENV JAVA11_HOME=/usr/lib/jvm/java-11-zulu
97+
ENV JDK11_HOME=/usr/lib/jvm/java-11-zulu
98+
ENV JAVA17_HOME=/usr/lib/jvm/java-17-zulu
99+
ENV JDK17_HOME=/usr/lib/jvm/java-17-zulu
100+
ENV JAVA21_HOME=/usr/lib/jvm/java-21-zulu
101+
ENV JDK21_HOME=/usr/lib/jvm/java-21-zulu
102+
ENV JAVA25_HOME=/usr/lib/jvm/java-25-zulu
103+
ENV JDK25_HOME=/usr/lib/jvm/java-25-zulu
104+
105+
# Set default java to 8
106+
RUN update-alternatives --install /usr/bin/java java /usr/lib/jvm/zulu8-fx/bin/java 100 && \
107+
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/zulu8-fx/bin/javac 100
108+
109+
CMD ["/bin/bash"]

.github/workflows/ant.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,20 @@ jobs:
1111
build-linux-jdk8:
1212

1313
runs-on: ubuntu-latest
14+
container:
15+
image: ghcr.io/codenameone/codenameone/ci-container:latest
16+
options: --user root
17+
defaults:
18+
run:
19+
shell: bash
1420

1521
steps:
1622
- uses: actions/checkout@v1
17-
- name: Set up JDK 8
18-
uses: actions/setup-java@v1
19-
with:
20-
java-version: 1.8
21-
java-package: jdk
22-
- name: Install dependencies
23-
run: sudo apt-get update && sudo apt-get install xvfb
23+
# JDK 8 is default in container, or we set it explicitly
24+
- name: Configure Java
25+
run: echo "JAVA_HOME=$JAVA8_HOME" >> $GITHUB_ENV
26+
27+
# dependencies (xvfb) are in container
2428
- name: Build with Maven
2529
run: |
2630
cd maven
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Build Container
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- '.ci/container/**'
9+
pull_request:
10+
paths:
11+
- '.ci/container/**'
12+
workflow_dispatch:
13+
14+
permissions:
15+
packages: write
16+
contents: read
17+
18+
jobs:
19+
build-and-push:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Log in to the Container registry
25+
uses: docker/login-action@v3
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Lowercase repository name
32+
run: |
33+
echo "REPO=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV}
34+
35+
- name: Build and push Docker image
36+
uses: docker/build-push-action@v5
37+
with:
38+
context: .ci/container
39+
push: ${{ github.event_name != 'pull_request' }}
40+
tags: ghcr.io/${{ env.REPO }}/ci-container:latest,ghcr.io/codenameone/codenameone/ci-container:latest

.github/workflows/parparvm-tests.yml

Lines changed: 18 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -18,63 +18,30 @@ on:
1818
jobs:
1919
vm-tests:
2020
runs-on: ubuntu-latest
21+
container:
22+
image: ghcr.io/codenameone/codenameone/ci-container:latest
23+
options: --user root
24+
defaults:
25+
run:
26+
shell: bash
2127
steps:
2228
- name: Check out repository
2329
uses: actions/checkout@v4
2430

25-
- name: Install native build tools
26-
run: |
27-
sudo apt-get update
28-
sudo apt-get install -y clang
29-
30-
# Install JDKs and export their paths
31-
- name: Set up JDK 8
32-
uses: actions/setup-java@v4
33-
with:
34-
distribution: 'temurin'
35-
java-version: '8'
36-
- name: Save JDK 8 Path
37-
run: echo "JDK_8_HOME=$JAVA_HOME" >> $GITHUB_ENV
31+
# Native tools (clang) and JDKs are pre-installed in container.
32+
# Environment variables JDK_8_HOME etc are already set in container or we map them.
3833

39-
- name: Set up JDK 11
40-
uses: actions/setup-java@v4
41-
with:
42-
distribution: 'temurin'
43-
java-version: '11'
44-
- name: Save JDK 11 Path
45-
run: echo "JDK_11_HOME=$JAVA_HOME" >> $GITHUB_ENV
46-
47-
- name: Set up JDK 17
48-
uses: actions/setup-java@v4
49-
with:
50-
distribution: 'temurin'
51-
java-version: '17'
52-
- name: Save JDK 17 Path
53-
run: echo "JDK_17_HOME=$JAVA_HOME" >> $GITHUB_ENV
34+
# Ensure container env vars are mapped to what tests expect if different.
35+
# The container sets JDK8_HOME, JDK11_HOME, JDK17_HOME, JDK21_HOME, JDK25_HOME.
36+
# The test expects JDK_8_HOME (with underscore).
5437

55-
- name: Set up JDK 21
56-
uses: actions/setup-java@v4
57-
with:
58-
distribution: 'temurin'
59-
java-version: '21'
60-
- name: Save JDK 21 Path
61-
run: echo "JDK_21_HOME=$JAVA_HOME" >> $GITHUB_ENV
62-
63-
- name: Set up JDK 25
64-
uses: actions/setup-java@v4
65-
with:
66-
distribution: 'zulu'
67-
java-version: '25'
68-
- name: Save JDK 25 Path
69-
run: echo "JDK_25_HOME=$JAVA_HOME" >> $GITHUB_ENV
70-
71-
# Restore JDK 8 as the main runner
72-
- name: Restore JDK 8
73-
uses: actions/setup-java@v4
74-
with:
75-
distribution: 'temurin'
76-
java-version: '8'
77-
cache: 'maven'
38+
- name: Map JDK Environment Variables
39+
run: |
40+
echo "JDK_8_HOME=$JDK8_HOME" >> $GITHUB_ENV
41+
echo "JDK_11_HOME=$JDK11_HOME" >> $GITHUB_ENV
42+
echo "JDK_17_HOME=$JDK17_HOME" >> $GITHUB_ENV
43+
echo "JDK_21_HOME=$JDK21_HOME" >> $GITHUB_ENV
44+
echo "JDK_25_HOME=$JDK25_HOME" >> $GITHUB_ENV
7845
7946
- name: Run ParparVM JVM tests
8047
working-directory: vm

.github/workflows/pr.yml

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,35 @@ jobs:
3737
build-test:
3838

3939
runs-on: ubuntu-latest
40+
container:
41+
image: ghcr.io/${{ github.repository_owner }}/codenameone/ci-container:latest
42+
# We need to map the workspace if not done automatically, but actions does it.
43+
# We might need options like --privileged if we needed kvm, but for PR CI we mainly do maven/ant tests.
44+
# However, some tests might need privileges? Usually not unit tests.
45+
options: --user root
46+
defaults:
47+
run:
48+
shell: bash
49+
4050
strategy:
4151
fail-fast: false
4252
matrix:
4353
java-version: [8, 17, 21, 25]
4454

4555
steps:
4656
- uses: actions/checkout@v1
47-
- name: Set up JDK 8
48-
if: matrix.java-version == 8
49-
uses: actions/setup-java@v1
50-
with:
51-
java-version: 1.8
52-
java-package: jdk+fx
53-
- name: Set up JDK
54-
if: matrix.java-version != 8
55-
uses: actions/setup-java@v4
56-
with:
57-
distribution: 'zulu'
58-
java-version: ${{ matrix.java-version }}
57+
- name: Configure Java
58+
run: |
59+
if [ "${{ matrix.java-version }}" == "8" ]; then
60+
echo "JAVA_HOME=$JAVA8_HOME" >> $GITHUB_ENV
61+
elif [ "${{ matrix.java-version }}" == "17" ]; then
62+
echo "JAVA_HOME=$JAVA17_HOME" >> $GITHUB_ENV
63+
elif [ "${{ matrix.java-version }}" == "21" ]; then
64+
echo "JAVA_HOME=$JAVA21_HOME" >> $GITHUB_ENV
65+
elif [ "${{ matrix.java-version }}" == "25" ]; then
66+
echo "JAVA_HOME=$JAVA25_HOME" >> $GITHUB_ENV
67+
fi
68+
5969
- name: Cache Maven dependencies
6070
uses: actions/cache@v4
6171
with:
@@ -73,14 +83,15 @@ jobs:
7383
mvn clean verify -DunitTests=true -pl core-unittests -am -Dmaven.javadoc.skip=true -Plocal-dev-javase $MVN_ARGS
7484
cd ..
7585
- name: Prepare Codename One binaries for Maven plugin tests
86+
# We symlink the container's cn1-binaries to the expected location if tests strictly require it there,
87+
# or we rely on CN1_BINARIES env var.
88+
# The previous step cloned it to maven/target/cn1-binaries.
89+
# We can just point CN1_BINARIES to the container path.
7690
run: |
77-
set -euo pipefail
78-
rm -rf maven/target/cn1-binaries
79-
git clone --depth=1 --filter=blob:none https://github.com/codenameone/cn1-binaries maven/target/cn1-binaries
91+
echo "Using pre-installed CN1_BINARIES at $CN1_BINARIES"
92+
8093
- name: Run Maven plugin tests
8194
working-directory: maven
82-
env:
83-
CN1_BINARIES: ${{ github.workspace }}/maven/target/cn1-binaries
8495
run: |
8596
mvn -B -Dmaven.javadoc.skip=true \
8697
-DunitTests=true \
@@ -228,10 +239,11 @@ jobs:
228239
await publishQualityComment({ github, context, core });
229240
- name: Install dependencies
230241
run: |
231-
sudo apt-get update && sudo apt-get install xvfb
232-
wget https://github.com/codenameone/cn1-binaries/archive/refs/heads/master.zip
233-
unzip master.zip -d ..
234-
mv ../cn1-binaries-master ../cn1-binaries
242+
# Dependencies (xvfb, etc) are already in container.
243+
# cn1-binaries is at $CN1_BINARIES (e.g. /opt/cn1-binaries).
244+
# The legacy build.xml might expect ../cn1-binaries.
245+
# We create a symlink from ../cn1-binaries to $CN1_BINARIES
246+
ln -sf "$CN1_BINARIES" ../cn1-binaries
235247
- name: Build CLDC11 JAR
236248
run: |
237249
ANT_OPTS_ARGS=""

0 commit comments

Comments
 (0)