-
Notifications
You must be signed in to change notification settings - Fork 29
151 lines (151 loc) · 5.84 KB
/
test-wildfly-s2i.yml
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
name: WildFly CEKit OpenShift Modules - Build/Run WildFly s2i image if the changes introduced in the PR impact it.
on:
pull_request:
branches: [ main ]
env:
LANG: en_US.UTF-8
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
jobs:
wfci:
name: WildFly-s2i Build and Test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- id: files
uses: jitterbit/get-changed-files@v1
- run: |
for changed_file in ${{ steps.files.outputs.all }}; do
if [[ "${changed_file}" =~ ^\.github/workflows/test-wildfly-s2i.yml ]] || [[ "${changed_file}" =~ ^jboss/container/wildfly/s2i/2.0/.* ]] || [[ "${changed_file}" =~ ^jboss/container/wildfly/run/.* ]]; then
echo "Change detected in ${changed_file}, will test image."
echo "IMPACT_IMAGE=true" >> "$GITHUB_ENV"
exit 0
fi
done
echo "No change detected that would impact the image, skipping the job"
- name: Update hosts - linux
if: matrix.os == 'ubuntu-latest' && env.IMPACT_IMAGE == 'true'
run: |
cat /etc/hosts
sudo bash -c "echo '127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4' > /etc/hosts"
sudo bash -c "echo '::1 localhost localhost.localdomain localhost6 localhost6.localdomain6' >> /etc/hosts"
sudo sysctl -w fs.file-max=2097152
- uses: actions/checkout@v2
if: env.IMPACT_IMAGE == 'true'
with:
path: wildfly-cekit-modules
- uses: actions/checkout@v2
if: env.IMPACT_IMAGE == 'true'
with:
repository: wildfly/wildfly-s2i
path: wildfly-s2i
- uses: n1hility/cancel-previous-runs@v2
if: env.IMPACT_IMAGE == 'true'
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Verify latest ubi8-minimal is present
if: env.IMPACT_IMAGE == 'true'
run: |
docker pull registry.access.redhat.com/ubi8/ubi-minimal
docker image ls | grep ubi8
- name: Setup required system packages
if: env.IMPACT_IMAGE == 'true'
run: |
sudo apt-get update
sudo apt-get install krb5-multidev libkrb5-dev
- name: Setup Python 3.x
if: env.IMPACT_IMAGE == 'true'
uses: actions/setup-python@v2
with:
python-version: '3.11.5'
- name: Setup virtualenv and install cekit and required packages
if: env.IMPACT_IMAGE == 'true'
run: |
python --version
sudo pip install virtualenv
mkdir ~/cekit
python3 -m venv ~/cekit
. ~/cekit/bin/activate
pip install cekit docker docker-squash odcs behave lxml packaging
- name: install s2i binary
if: env.IMPACT_IMAGE == 'true'
run: |
echo ===== Installing s2i from ${{ env.S2I_URL }} =====
mkdir /tmp/s2i/ && cd /tmp/s2i/
wget ${{ env.S2I_URI }}
tar xvf source-to-image*.gz
sudo mv s2i /usr/bin
which s2i
s2i version
- name: Build
if: env.IMPACT_IMAGE == 'true'
run: |
. ~/cekit/bin/activate
overrides="{\"modules\": {\"repositories\": [{\"name\":\"wildfly-cekit-modules\",\"path\":\"../../wildfly-cekit-modules\"}]}}"
pushd wildfly-builder-image
cekit build --overrides=jdk21-overrides.yaml --overrides "$overrides" docker
popd
pushd wildfly-runtime-image
cekit build --overrides=jdk21-overrides.yaml --overrides "$overrides" docker
popd
docker image ls
working-directory: wildfly-s2i
- name: Behave Tests
if: env.IMPACT_IMAGE == 'true'
run: |
. ~/cekit/bin/activate
mkdir -p all-tests
mv wildfly-builder-image/tests/features/*.feature all-tests
for feature in all-tests/*.feature; do
cp $feature wildfly-builder-image/tests/features/
pushd wildfly-builder-image
echo "Testing feature file $(basename ${feature})"
cekit test --overrides=jdk21-overrides.yaml behave > test-logs-$fileName.txt 2>&1
docker system prune -f
popd
rm wildfly-builder-image/tests/features/*.feature
done
working-directory: wildfly-s2i
- name: Additional Tests
if: env.IMPACT_IMAGE == 'true'
run: |
export IMAGE_VERSION=$(yq e ".version" wildfly-runtime-image/jdk21-overrides.yaml)
export NAMESPACE=wildfly
export IMAGE_NAME=${NAMESPACE}/wildfly-s2i
export RUNTIME_IMAGE_NAME=${NAMESPACE}/wildfly-runtime
. ~/cekit/bin/activate
./test/run
working-directory: wildfly-s2i
- name: Advertise Failing Behave Scenarios
if: failure()
run: |
pushd wildfly-builder-image
logFile=$(find . -type f -iname "test-logs-*.txt")
if [ -f "${logFile}" ]; then
# Remove tar noise
grep -v "tar.go:" ${logFile} > tmpFile && mv tmpFile ${logFile}
# Display failing scenario
grep -A10000 "Failing scenarios" ${logFile}
else
echo "No failure in behave tests"
fi
popd
- name: List containers
if: failure()
run: |
echo === RUNNING CONTAINERS ===
docker container ls
echo === RUNNING PROCESSES ===
top -b -n1
echo === DISK USAGE ===
df -h
- name: Upload Test Reports on Failure
uses: actions/upload-artifact@v3
if: failure()
with:
name: wildfly-s2i-test-logs
path: |
wildfly-builder-image/test-logs-*.txt
/tmp/*.wfs2i.log