-
Notifications
You must be signed in to change notification settings - Fork 75
296 lines (271 loc) · 11 KB
/
build-test.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
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
name: Janssen Build & Test
on:
push:
branches:
- main
paths:
- "jans-**"
- "agama"
schedule:
- cron: '0 8 * * *'
pull_request:
branches:
- main
paths:
- "jans-**"
- "agama"
workflow_dispatch:
inputs:
project:
type: choice
options:
- "jans-bom"
- "jans-orm"
- "jans-core"
- "jans-lock/lock-server"
- "agama"
- "jans-auth-server"
- "jans-link"
- "jans-fido2"
- "jans-scim"
- "jans-keycloak-link"
- "jans-config-api"
- "jans-keycloak-integration"
- "jans-casa"
- "jans-bom jans-orm jans-core jans-lock/lock-server agama jans-auth-server jans-link jans-fido2 jans-scim jans-keycloak-link jans-config-api jans-keycloak-integration jans-casa"
description: 'Service'
required: true
default: "jans-bom jans-orm jans-core jans-lock/lock-server agama jans-auth-server jans-link jans-fido2 jans-scim jans-keycloak-link jans-config-api jans-keycloak-integration jans-casa"
concurrency:
group: run-once
cancel-in-progress: false
jobs:
cleanup:
if: github.event_name == 'push' && github.event.ref == 'refs/heads/main'
runs-on: ubuntu-20.04
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
egress-policy: audit
- name: Get version ID for 0.0.0-nightly
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
id: get_version_id
run: |
services=$(gh api -H "Accept: application/vnd.github+json" \
/orgs/JanssenProject/packages?package_type=maven \
| jq -r '.[].name')
for service in "${services}"; do
version_id=$(gh api -H "Accept: application/vnd.github+json" \
/orgs/JanssenProject/packages/maven/io.jans.${service}/versions \
| jq -r '.[] | select(.name == "0.0.0-nightly") | .id')
echo "version_id=$version_id" >> $GITHUB_ENV
gh api --method DELETE \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/orgs/JanssenProject/packages/maven/io.jans."${service}"/versions/"${version_id}"
done
prep-matrix:
needs: cleanup
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
egress-policy: audit
- id: set-matrix
run: |
projects="${{ github.event.inputs.project }}"
if [ -z "$projects" ]; then
projects="jans-bom jans-orm jans-core jans-lock/lock-server agama jans-auth-server jans-link jans-fido2 jans-scim jans-keycloak-link jans-config-api jans-keycloak-integration jans-casa"
fi
pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
DIRECTORIES_CHANGED=$(gh pr view $pull_number --json files --jq '.files.[].path' | cut -d/ -f1 | sort -u | grep "jans-" || echo "$projects")
changed_projects=""
for dir in $DIRECTORIES_CHANGED; do
for project in $projects; do
if [[ "$dir" == "$project" ]]; then
changed_projects="$changed_projects $project"
fi
done
done
echo "Changed projects: $changed_projects"
matrix="{\"include\":["
for project in $changed_projects; do
matrix="$matrix{\"service\":\"$project\",\"maven_skip_tests\":true},"
done
matrix="${matrix%,}]}"
echo $matrix
echo "matrix=$matrix" >> $GITHUB_OUTPUT
build-with-disabled-tests:
runs-on: ubuntu-20.04
needs: prep-matrix
permissions:
contents: read
packages: write
env:
VERSION_NAME: main
MAVEN_SKIP_TESTS: true
PROFILE_NAME: "default"
strategy:
max-parallel: 1
matrix: ${{ fromJson(needs.prep-matrix.outputs.matrix) }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Set up Java 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
- name: Set up Maven
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
cache: 'maven'
- name: Build ${{ matrix.service }}
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
mvn -f ${{ matrix.service }}/pom.xml -Dcfg=${{ env.PROFILE_NAME }} -Dmaven.test.skip=${{ matrix.maven_skip_tests }} clean install -Drevision=${{ github.head_ref }}-nightly
else
mvn -f ${{ matrix.service }}/pom.xml -Dcfg=${{ env.PROFILE_NAME }} -Dmaven.test.skip=${{ matrix.maven_skip_tests }} clean install
fi
- name: Publish to GitHub Packages
run: mvn -B deploy -Dmaven.test.skip=${{ matrix.maven_skip_tests }} -Dcfg=${{ env.PROFILE_NAME }}
working-directory: ${{ matrix.service }}
env:
GITHUB_TOKEN: ${{ secrets.MOAUTO_WORKFLOW_TOKEN }}
- name: Archive results
if: always()
uses: actions/upload-artifact@v4
with:
name: build-results
path: ${{ matrix.service }}/target
- name: Send notification on failure
if: failure()
run: echo "Build failed"
run-tests:
if: github.event_name == 'push' || github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && github.event.inputs.project == 'jans-bom, jans-orm, jans-core, jans-lock/lock-server, agama, jans-auth-server, jans-link, jans-fido2, jans-scim, jans-keycloak-link, jans-config-api, jans-keycloak-integration, jans-casa')
permissions: write-all
needs: cleanup
runs-on: ubuntu-20.04
env:
MAVEN_SKIP_TESTS: false
CONTAINER_NAME_SPANNER: ubuntu20-spanner
CONTAINER_NAME_CB: ubuntu20-couchbase
CONTAINER_NAME_LDAP: ubuntu20-ldap
CONTAINER_NAME_MYSQL: ubuntu20-mysql
CONTAINER_NAME_POSTGRESQL: ubuntu20-postgresql
DEVELOPMENT_BUILD: true
SKIP_FINDBUGS: true
DEPENDENCY_CHECK: true
VERSION_NAME: main
PROFILE_NAME: default
strategy:
max-parallel: 5
matrix:
persistence:
- "MYSQL"
- "PGSQL"
fail-fast: false
steps:
- name: Harden Runner
uses: step-security/harden-runner@a4aa98b93cab29d9b1101a6143fb8bce00e2eac4 # v2.7.1
with:
egress-policy: audit
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.branch }}
- name: Set up Java 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
- name: Set up Maven
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
cache: 'maven'
- name: Set up Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: 1.18
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
with:
gpg_private_key: ${{ secrets.MOAUTO_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.MOAUTO_GPG_PRIVATE_KEY_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Configure Git
run: |
git config --global user.name "mo-auto"
git config --global user.email "[email protected]"
git config --global user.signingkey "${{ steps.import_gpg.outputs.keyid }}"
echo "${{ secrets.MOAUTO_WORKFLOW_TOKEN }}" | gh auth login --with-token
- name: Run Jans Monolith
env:
JANS_FQDN: demoexample.jans.io
EXT_IP: $(ifconfig eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')
JANS_BUILD_COMMIT: main
run: |
export ip=$(ifconfig eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')
sudo chmod a+x automation/startjanssenmonolithdemo.sh
sudo RUN_TESTS=true bash ./automation/startjanssenmonolithdemo.sh "demoexample.jans.io" "${{ matrix.persistence }}" "$ip" "${{ github.sha }}"
echo "generating rdbms docs for ${{ matrix.persistence-backends }}..."
git clone https://mo-auto:${{ secrets.MOAUTO_WORKFLOW_TOKEN }}@github.com/JanssenProject/jans.git
cd jans
git config pull.rebase true
git checkout -b cn-jans-update-${{ matrix.persistence-backends }}-auto-generated-docs || echo "Branch exists"
git pull origin cn-jans-update-${{ matrix.persistence-backends }}-auto-generated-docs || echo "Nothing to pull"
sudo bash ./automation/docs/generate-rdbms-docs.sh "$persistence" || echo "generating rdbms docs failed for ${{ matrix.persistence-backends }}!!!"
git add . || echo "generating rdbms docs failed !!!"
git commit -a -S -m "docs: auto-generated ${{ matrix.persistence-backends }} docs" || echo "Nothing to commit"
git push --set-upstream origin cn-jans-update-${{ matrix.persistence-backends }}-auto-generated-docs || echo "generating rdbms docs failed !!!"
MESSAGE="fix(docs): autogenerate ${{ matrix.persistence-backends }} RDBMS docs"
gh pr create --body "Auto generated RDBMS docs" --title "${MESSAGE}" || echo "PR exists"
cd ..
echo "generating rdbms docs for ${{ matrix.persistence-backends }} done"
export JANS_URL=https://demoexample.jans.io
export JANS_CLIENT_ID=9876baac-de39-4c23-8a78-674b59df8c09
export JANS_CLIENT_SECRET=1t5Fin3#security
export JANS_INSECURE_CLIENT=true
export TF_ACC=1
cd terraform-provider-jans
go install github.com/jstemmer/go-junit-report/v2@latest
go test -v 2>&1 ./... | go-junit-report > /tmp/reports/${{ matrix.persistence-backends }}report.xml
cd ..
- name: List Reports
run: |
ls /tmp/reports/
- name: Upload Test Results
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.persistence }}-test-results
path: /tmp/reports
- name: Publish Test Report ${{ matrix.persistence }}
uses: starburstdata/action-testng-report@v1
with:
report_paths: /tmp/reports/${{ matrix.persistence }}*.xml
github_token: ${{ github.token }}
fail_if_empty: false
# - name: Publish Test Report Surefire
# uses: scacap/action-surefire-report@v1
# if: success() || failure()
# with:
# github_token: ${{ github.token }}
# report_paths: /tmp/reports/**.xml