Skip to content

Commit 6107f3c

Browse files
committed
Add CI for OpenJDK S2I testing for bootable JAR
1 parent 9710d66 commit 6107f3c

File tree

6 files changed

+434
-0
lines changed

6 files changed

+434
-0
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
name: Wildfly Cloud Galleon feature-pack nightly - Test OpenJDK S2I bootable JAR build with latest WildFly SNAPSHOT.
2+
on:
3+
schedule:
4+
- cron: "0 0 * * *"
5+
push:
6+
branches:
7+
- 'main'
8+
env:
9+
LANG: en_US.UTF-8
10+
S2I_URI: https://github.com/openshift/source-to-image/releases/download/v1.3.1/source-to-image-v1.3.1-a5a77147-linux-amd64.tar.gz
11+
jobs:
12+
wfci:
13+
name: OpenJDK S2I Build and Test
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest]
19+
java: ['21']
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Update hosts - linux
23+
if: matrix.os == 'ubuntu-latest'
24+
run: |
25+
cat /etc/hosts
26+
sudo bash -c "echo '127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4' > /etc/hosts"
27+
sudo bash -c "echo '::1 localhost localhost.localdomain localhost6 localhost6.localdomain6' >> /etc/hosts"
28+
sudo sysctl -w fs.file-max=2097152
29+
- uses: n1hility/cancel-previous-runs@v2
30+
with:
31+
token: ${{ secrets.GITHUB_TOKEN }}
32+
- uses: wildfly-extras/wildfly-nightly-download@v1
33+
id: wildfly-nightly
34+
- name: Setup required system packages
35+
run: |
36+
sudo apt-get update
37+
sudo apt-get install krb5-multidev libkrb5-dev
38+
- name: Setup Python 3.x
39+
uses: actions/setup-python@v2
40+
with:
41+
python-version: '3.x'
42+
- name: install s2i binary
43+
run: |
44+
echo ===== Installing s2i from ${{ env.S2I_URL }} =====
45+
mkdir /tmp/s2i/ && cd /tmp/s2i/
46+
wget ${{ env.S2I_URI }}
47+
tar xvf source-to-image*.gz
48+
sudo mv s2i /usr/bin
49+
which s2i
50+
s2i version
51+
- name: Build cloud FP and docker image
52+
run: |
53+
mvn clean install -DskipTests -Dversion.org.wildfly=${{steps.wildfly-nightly.outputs.wildfly-version}}
54+
cloudVersion=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
55+
echo "CLOUD_FP_VERSION=${cloudVersion}" >> $GITHUB_ENV
56+
mkdir -p custom-cloud-image
57+
mkdir -p custom-cloud-image/docker/repository/org/wildfly/cloud/wildfly-cloud-galleon-pack/$cloudVersion
58+
mkdir -p custom-cloud-image/docker/repository/org/wildfly/cloud/wildfly-bootable-cloud-configurator/$cloudVersion
59+
cp wildfly-cloud-galleon-pack/target/wildfly-cloud-galleon-pack-$cloudVersion.zip custom-cloud-image/docker/repository/org/wildfly/cloud/wildfly-cloud-galleon-pack/$cloudVersion
60+
cp wildfly-bootable-cloud-configurator/target/wildfly-bootable-cloud-configurator-$cloudVersion.jar custom-cloud-image/docker/repository/org/wildfly/cloud/wildfly-bootable-cloud-configurator/$cloudVersion
61+
62+
# Retrieve WildFly nightly tar.gz repo
63+
mkdir -p wf-tmp/repo;cd wf-tmp/repo
64+
wget -q https://ci.wildfly.org/guestAuth/repository/download/WF_Nightly/latest.lastSuccessful/wildfly-maven-repository.tar.gz
65+
cd ..;tar xvf repo/wildfly-maven-repository.tar.gz
66+
tar xvf wildfly-maven-repository.tar.gz
67+
rm wildfly-maven-repository.tar.gz;rm -rf repo
68+
cd ..
69+
cp -r wf-tmp/* custom-cloud-image/docker/repository/
70+
71+
docker_file=custom-cloud-image/docker/Dockerfile
72+
cat <<EOF > $docker_file
73+
FROM registry.access.redhat.com/ubi9/openjdk-${{ matrix.java }}:latest
74+
RUN mkdir -p /tmp/artifacts/m2
75+
COPY --chown=default:root repository /tmp/artifacts/m2
76+
EOF
77+
78+
docker build -t wildfly/openjdk-s2i:dev-$cloudVersion ./custom-cloud-image/docker
79+
- name: Test OpenJDK S2I to build bootable JAR
80+
run: |
81+
s2i build --env MAVEN_ARGS_APPEND="-Dwildfly.bootable.jar=true -Dversion.server=${{steps.wildfly-nightly.outputs.wildfly-version}} -Dversion.wildfly.cloud.galleon.pack=${{ env.CLOUD_FP_VERSION }}" ./s2i-tests/test-apps/helloworld wildfly/openjdk-s2i:dev-${{ env.CLOUD_FP_VERSION }} wildfly/helloworld-bootable-app
82+
cid=$(docker run --detach -p8080:8080 wildfly/helloworld-bootable-app)
83+
echo "Started container with ID $cid"
84+
max_attempts=30
85+
sleep_time=1
86+
attempt=1
87+
result=1
88+
url=127.0.0.1:8080/helloworld/HelloWorld
89+
while [ $attempt -le $max_attempts ]; do
90+
echo "Sending GET request to $url"
91+
set +e
92+
response_code=$(curl -s -w %{http_code} -o /dev/null $url)
93+
status=$?
94+
set -e
95+
if [ $status -eq 0 ]; then
96+
if [ $response_code -eq 200 ]; then
97+
result=0
98+
fi
99+
break
100+
fi
101+
attempt=$(( $attempt + 1 ))
102+
sleep $sleep_time
103+
done
104+
if [ $result -eq 0 ]; then
105+
echo "GET request succeeded"
106+
else
107+
echo "GET request failed with code $response_code"
108+
fi
109+
docker kill $cid
110+
exit $result
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
name: Wildfly Cloud Galleon feature-pack - Test OpenJDK S2I bootable JAR build on the changes introduced in the PR.
2+
on:
3+
pull_request:
4+
branches: [ main ]
5+
env:
6+
LANG: en_US.UTF-8
7+
S2I_URI: https://github.com/openshift/source-to-image/releases/download/v1.3.1/source-to-image-v1.3.1-a5a77147-linux-amd64.tar.gz
8+
jobs:
9+
wfci:
10+
name: OpenJDK S2I Build and Test
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
fail-fast: false
14+
matrix:
15+
os: [ubuntu-latest]
16+
java: ['21']
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Update hosts - linux
20+
if: matrix.os == 'ubuntu-latest'
21+
run: |
22+
cat /etc/hosts
23+
sudo bash -c "echo '127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4' > /etc/hosts"
24+
sudo bash -c "echo '::1 localhost localhost.localdomain localhost6 localhost6.localdomain6' >> /etc/hosts"
25+
sudo sysctl -w fs.file-max=2097152
26+
- uses: n1hility/cancel-previous-runs@v2
27+
with:
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
- name: Setup required system packages
30+
run: |
31+
sudo apt-get update
32+
sudo apt-get install krb5-multidev libkrb5-dev
33+
- name: Setup Python 3.x
34+
uses: actions/setup-python@v2
35+
with:
36+
python-version: '3.x'
37+
- name: install s2i binary
38+
run: |
39+
echo ===== Installing s2i from ${{ env.S2I_URL }} =====
40+
mkdir /tmp/s2i/ && cd /tmp/s2i/
41+
wget ${{ env.S2I_URI }}
42+
tar xvf source-to-image*.gz
43+
sudo mv s2i /usr/bin
44+
which s2i
45+
s2i version
46+
- name: Build cloud FP and docker image
47+
run: |
48+
mvn clean install -DskipTests
49+
cloudVersion=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
50+
echo "CLOUD_FP_VERSION=${cloudVersion}" >> $GITHUB_ENV
51+
mkdir -p custom-cloud-image
52+
mkdir -p custom-cloud-image/docker/repository/org/wildfly/cloud/wildfly-cloud-galleon-pack/$cloudVersion
53+
mkdir -p custom-cloud-image/docker/repository/org/wildfly/cloud/wildfly-bootable-cloud-configurator/$cloudVersion
54+
cp wildfly-cloud-galleon-pack/target/wildfly-cloud-galleon-pack-$cloudVersion.zip custom-cloud-image/docker/repository/org/wildfly/cloud/wildfly-cloud-galleon-pack/$cloudVersion
55+
cp wildfly-bootable-cloud-configurator/target/wildfly-bootable-cloud-configurator-$cloudVersion.jar custom-cloud-image/docker/repository/org/wildfly/cloud/wildfly-bootable-cloud-configurator/$cloudVersion
56+
docker_file=custom-cloud-image/docker/Dockerfile
57+
cat <<EOF > $docker_file
58+
FROM registry.access.redhat.com/ubi9/openjdk-${{ matrix.java }}:latest
59+
RUN mkdir -p /tmp/artifacts/m2
60+
COPY --chown=default:root repository /tmp/artifacts/m2
61+
EOF
62+
docker build -t wildfly/openjdk-s2i:dev-$cloudVersion ./custom-cloud-image/docker
63+
- name: Test OpenJDK S2I to build bootable JAR
64+
run: |
65+
s2i build --env MAVEN_ARGS_APPEND="-Dwildfly.bootable.jar=true -Dversion.wildfly.cloud.galleon.pack=${{ env.CLOUD_FP_VERSION }}" ./s2i-tests/test-apps/helloworld wildfly/openjdk-s2i:dev-${{ env.CLOUD_FP_VERSION }} wildfly/helloworld-bootable-app
66+
cid=$(docker run --detach -p8080:8080 wildfly/helloworld-bootable-app)
67+
echo "Started container with ID $cid"
68+
max_attempts=30
69+
sleep_time=1
70+
attempt=1
71+
result=1
72+
url=127.0.0.1:8080/helloworld/HelloWorld
73+
while [ $attempt -le $max_attempts ]; do
74+
echo "Sending GET request to $url"
75+
set +e
76+
response_code=$(curl -s -w %{http_code} -o /dev/null $url)
77+
status=$?
78+
set -e
79+
if [ $status -eq 0 ]; then
80+
if [ $response_code -eq 200 ]; then
81+
result=0
82+
fi
83+
break
84+
fi
85+
attempt=$(( $attempt + 1 ))
86+
sleep $sleep_time
87+
done
88+
if [ $result -eq 0 ]; then
89+
echo "GET request succeeded"
90+
else
91+
echo "GET request failed with code $response_code"
92+
fi
93+
docker kill $cid
94+
exit $result

s2i-tests/test-apps/README

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# WildFly S2I to produce a WildFly server image
2+
3+
s2i build . quay.io/wildfly/wildfly-s2i:latest helloworld-app
4+
5+
podman run -p8080:8080 helloworld-app
6+
7+
# OpenJDK S2I to produce a bootable JAR image
8+
9+
s2i build --env MAVEN_ARGS_APPEND="-Dwildfly.bootable.jar=true" . registry.access.redhat.com/ubi9/openjdk-21:latest helloworld-bootable-app
10+
11+
podman run -p8080:8080 helloworld-bootable-app
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<!--
3+
JBoss, Home of Professional Open Source
4+
Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual
5+
contributors by the @authors tag. See the copyright.txt in the
6+
distribution for a full listing of individual contributors.
7+
8+
Licensed under the Apache License, Version 2.0 (the "License");
9+
you may not use this file except in compliance with the License.
10+
You may obtain a copy of the License at
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
20+
<modelVersion>4.0.0</modelVersion>
21+
<groupId>org.wildfly.cloud.examples</groupId>
22+
<artifactId>helloworld</artifactId>
23+
<version>1.0.0-SNAPSHOT</version>
24+
<packaging>war</packaging>
25+
<name>Helloworld</name>
26+
<description>Helloworld</description>
27+
28+
<licenses>
29+
<license>
30+
<name>Apache License, Version 2.0</name>
31+
<distribution>repo</distribution>
32+
<url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
33+
</license>
34+
</licenses>
35+
36+
<properties>
37+
<!-- the Maven project should use the minimum Java SE version supported -->
38+
<maven.compiler.release>17</maven.compiler.release>
39+
<!-- the version for the Server -->
40+
<version.server>39.0.1.Final</version.server>
41+
<!-- the versions for BOMs, Packs and Plugins -->
42+
<version.bom.ee>${version.server}</version.bom.ee>
43+
<version.wildfly.cloud.galleon.pack>9.1.0.Beta1</version.wildfly.cloud.galleon.pack>
44+
<version.plugin.wildfly>6.0.0.Beta2</version.plugin.wildfly>
45+
</properties>
46+
47+
<dependencyManagement>
48+
<dependencies>
49+
<!-- importing the ee-with-tools BOM adds specs and other useful artifacts as managed dependencies -->
50+
<dependency>
51+
<groupId>org.wildfly.bom</groupId>
52+
<artifactId>wildfly-ee-with-tools</artifactId>
53+
<version>${version.bom.ee}</version>
54+
<type>pom</type>
55+
<scope>import</scope>
56+
</dependency>
57+
</dependencies>
58+
</dependencyManagement>
59+
60+
<dependencies>
61+
<!-- Import the Servlet API, we use provided scope as the API is included in the server -->
62+
<dependency>
63+
<groupId>jakarta.servlet</groupId>
64+
<artifactId>jakarta.servlet-api</artifactId>
65+
<scope>provided</scope>
66+
</dependency>
67+
</dependencies>
68+
69+
<build>
70+
<!-- Set the name of the WAR, used as the context root when the app is deployed. -->
71+
<finalName>${project.artifactId}</finalName>
72+
<pluginManagement>
73+
<plugins>
74+
<plugin>
75+
<groupId>org.wildfly.plugins</groupId>
76+
<artifactId>wildfly-maven-plugin</artifactId>
77+
<version>${version.plugin.wildfly}</version>
78+
</plugin>
79+
</plugins>
80+
</pluginManagement>
81+
</build>
82+
83+
<profiles>
84+
<profile>
85+
<id>openshift</id>
86+
<build>
87+
<plugins>
88+
<plugin>
89+
<groupId>org.wildfly.plugins</groupId>
90+
<artifactId>wildfly-maven-plugin</artifactId>
91+
<configuration>
92+
<feature-packs>
93+
<feature-pack>
94+
<location>org.wildfly:wildfly-galleon-pack:${version.server}</location>
95+
</feature-pack>
96+
<feature-pack>
97+
<location>org.wildfly.cloud:wildfly-cloud-galleon-pack:${version.wildfly.cloud.galleon.pack}</location>
98+
</feature-pack>
99+
</feature-packs>
100+
<layers>
101+
<layer>cloud-server</layer>
102+
</layers>
103+
</configuration>
104+
<executions>
105+
<execution>
106+
<goals>
107+
<goal>package</goal>
108+
</goals>
109+
</execution>
110+
</executions>
111+
</plugin>
112+
<!-- do not attach sources to openshift deployments -->
113+
<plugin>
114+
<groupId>org.apache.maven.plugins</groupId>
115+
<artifactId>maven-source-plugin</artifactId>
116+
<executions>
117+
<execution>
118+
<id>attach-sources</id>
119+
<phase>none</phase>
120+
</execution>
121+
</executions>
122+
</plugin>
123+
</plugins>
124+
</build>
125+
</profile>
126+
</profiles>
127+
128+
<repositories>
129+
<repository>
130+
<id>jboss-public-maven-repository</id>
131+
<name>JBoss Public Maven Repository</name>
132+
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
133+
</repository>
134+
</repositories>
135+
<pluginRepositories>
136+
<pluginRepository>
137+
<id>jboss-public-maven-repository</id>
138+
<name>JBoss Public Maven Repository</name>
139+
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
140+
</pluginRepository>
141+
</pluginRepositories>
142+
</project>

0 commit comments

Comments
 (0)