-
Notifications
You must be signed in to change notification settings - Fork 32
275 lines (257 loc) · 11.9 KB
/
ci.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
name: Alfresco Identity Service CI
on:
push:
branches:
- master
- AUTH-**
- OPSEXP-**
- feature/**
- fix/**
- release/**
workflow_dispatch:
schedule:
- cron: "0 5 * * 3"
env:
S3_ARTIFACTS_BUCKET: ${{ secrets.S3_ARTIFACTS_BUCKET }}
AUTH0_CLIENT_ID: ${{ secrets.AUTH0_CLIENT_ID }}
AUTH0_CLIENT_SECRET: ${{ secrets.AUTH0_CLIENT_SECRET }}
MAVEN_USERNAME: ${{ secrets.NEXUS_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
HELM_DOCS_VERSION: 1.11.0
AWS_REGION: eu-west-1
jobs:
pre-commit:
name: "Pre-commit"
runs-on: ubuntu-latest
steps:
- name: "Install helm-docs"
run: |
curl -fsSL https://github.com/norwoodj/helm-docs/releases/download/v$HELM_DOCS_VERSION/helm-docs_${HELM_DOCS_VERSION}_$(uname)_x86_64.tar.gz | sudo tar xz -C /usr/local/bin/ helm-docs
helm-docs --version
- uses: Alfresco/alfresco-build-tools/.github/actions/pre-commit@v7.0.0
build:
name: "Build"
runs-on: ubuntu-latest
needs: pre-commit
steps:
- uses: actions/checkout@v4
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v7.0.0
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v7.0.0
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_S3_PIPELINE_AMPS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_S3_PIPELINE_AMPS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: "Build"
id: build
run: |
source distribution/build.properties
export KEYCLOAK_VERSION=${KEYCLOAK_VERSION}
echo "KEYCLOAK_VERSION=${KEYCLOAK_VERSION}"
# build and package
cd distribution
make || { echo "Command failed with error code $?"; sleep 1; exit 1; }
# upload ZIP file to S3 bucket
aws s3 cp alfresco-keycloak-${KEYCLOAK_VERSION}.md5 s3://${S3_ARTIFACTS_BUCKET}/ci-${BUILD_NUMBER}/
aws s3 cp alfresco-keycloak-${KEYCLOAK_VERSION}.zip s3://${S3_ARTIFACTS_BUCKET}/ci-${BUILD_NUMBER}/
test_linux:
name: "Test on Linux"
runs-on: ubuntu-latest
needs: build
if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }}
steps:
- uses: actions/checkout@v4
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v7.0.0
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v7.0.0
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_S3_PIPELINE_AMPS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_S3_PIPELINE_AMPS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: "Test"
run: |
source distribution/build.properties
export KEYCLOAK_VERSION=${KEYCLOAK_VERSION}
echo "KEYCLOAK_VERSION=${KEYCLOAK_VERSION}"
aws s3 cp s3://${S3_ARTIFACTS_BUCKET}/ci-${BUILD_NUMBER}/alfresco-keycloak-${KEYCLOAK_VERSION}.zip .
./distribution/tests/endpoints.sh
test_windows:
name: "Test on Windows"
runs-on: windows-latest
needs: build
if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }}
steps:
- uses: actions/checkout@v4
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v7.0.0
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_S3_PIPELINE_AMPS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_S3_PIPELINE_AMPS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: "Get BUILD_NUMBER"
run: |
echo "BUILD_NUMBER=$env:GITHUB_RUN_NUMBER" | Out-File -FilePath $env:GITHUB_ENV -Append
echo $env:GITHUB_RUN_NUMBER
- name: "Test"
run: |
$Props = convertfrom-stringdata (get-content ./distribution/build.properties -raw)
$env:KEYCLOAK_VERSION = $Props.'KEYCLOAK_VERSION'
echo "KEYCLOAK_VERSION=$env:KEYCLOAK_VERSION"
aws s3 ls s3://$env:S3_ARTIFACTS_BUCKET/ci-$env:BUILD_NUMBER/
aws s3 cp s3://$env:S3_ARTIFACTS_BUCKET/ci-$env:BUILD_NUMBER/alfresco-keycloak-$env:KEYCLOAK_VERSION.zip .
unzip alfresco-keycloak-$env:KEYCLOAK_VERSION.zip
cd alfresco-keycloak-$env:KEYCLOAK_VERSION/bin
powershell -Command Get-ExecutionPolicy
powershell -Command 'Set-ExecutionPolicy unrestricted'
powershell -Command $env:GITHUB_WORKSPACE/distribution/tests/endpoints_ps.ps1
powershell -Command $env:GITHUB_WORKSPACE/distribution/tests/endpoints_bat.ps1
test_helm:
name: "Test Helm Chart"
runs-on: ubuntu-latest
needs: build
if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }}
steps:
- uses: actions/checkout@v4
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v7.0.0
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v7.0.0
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_S3_PIPELINE_AMPS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_S3_PIPELINE_AMPS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Login to Quay.io
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Setup cluster
uses: Alfresco/alfresco-build-tools/.github/actions/setup-kind@v7.0.0
- name: Create registries auth secret
run: |
kubectl create secret generic regcred \
--from-file=.dockerconfigjson=$HOME/.docker/config.json \
--type=kubernetes.io/dockerconfigjson
- name: "Prepare test environment"
run: |
openssl aes-256-cbc -K ${{ secrets.ENCRYPTED_E69BEC42AE64_KEY }} -iv ${{ secrets.ENCRYPTED_E69BEC42AE64_IV }} -in test/scripts/config-files/realmRsaKeys.json.enc -out test/scripts/config-files/realmRsaKeys.json -d
- name: "Set KC_BUILD_NAME"
run: |
KC_BUILD_NAME=$(echo ${BRANCH_NAME} | cut -c1-28 | tr /_ - | tr -d [:punct:] | awk '{print tolower($0)}')-${BUILD_NUMBER}
echo "KC_BUILD_NAME=$KC_BUILD_NAME" >> "$GITHUB_ENV"
echo $KC_BUILD_NAME
- name: "Test"
run: |
set +e
export HOST=localhost
export release_name_kc=kc
export openldap_release=openldap
# install openldap
helm upgrade --install $openldap_release --repo https://geek-cookbook.github.io/helm-openldap openldap --version 1.2.9 \
-f test/scripts/ldap-config.yaml \
--wait
# install Keycloak
helm dep up helm/alfresco-keycloak
helm upgrade --install $release_name_kc helm/alfresco-keycloak \
--values helm/alfresco-keycloak/ci/ci-values.yaml \
--set ingress.hostName=$HOST \
--set realm.alfresco.client.redirectUris[0]="https://${HOST}\*" \
--set realm.alfresco.client.webOrigins[0]="https://${HOST}\*" \
--set keycloakx.command[0]="/opt/keycloak/bin/kc.sh" \
--set keycloakx.command[1]="start" \
--set keycloakx.command[2]="--import-realm" \
--set keycloakx.command[3]="--http-relative-path=/auth" \
--set keycloakx.command[4]="--hostname=${HOST}" \
--set keycloakx.imagePullSecrets[0].name="regcred" \
--wait
# Set IDP Config
./test/scripts/set_idp_config.sh
postman_image=postman/newman_alpine33:3.9.2
# run Keycloak checks
docker run -a STDOUT --volume $PWD/test/postman:/etc/newman --network host $postman_image run "keycloak-test-collection.json" --insecure --global-var "keycloak_host=$HOST"
TEST_RESULT=$?
echo "TEST_RESULT=${TEST_RESULT}"
if [[ "${TEST_RESULT}" == "0" ]]; then
docker run -a STDOUT --volume $PWD/test/postman:/etc/newman --network host $postman_image run "change-keycloak-access-token-lifespan-collection.json" --insecure --global-var "keycloak_host=$HOST"
./test/helm/delete_keycloak_pods.sh
docker run -a STDOUT --volume $PWD/test/postman:/etc/newman --network host $postman_image run "check-keycloak-access-token-lifespan-change-persisted.json" --insecure --global-var "keycloak_host=$HOST"
TEST_RESULT=$?
echo "TEST_RESULT=${TEST_RESULT}"
fi
if [[ "${TEST_RESULT}" == "0" ]]; then
docker run -a STDOUT --volume $PWD/test/postman:/etc/newman --network host $postman_image run "ldap-user-provider-tests.postman_collection.json" -d "ldap-test-data.json" --insecure --global-var "keycloak_host=$HOST"
TEST_RESULT=$?
echo "TEST_RESULT=${TEST_RESULT}"
fi
if [[ "${TEST_RESULT}" == "0" ]]; then
cd test/scripts
./auth0-api.sh create $KC_BUILD_NAME https://$HOST
./configure-saml-kc.sh app_name=$KC_BUILD_NAME kc_base_url=https://$HOST
cd ../saml
export KEYCLOAK_HOSTNAME=$HOST
export KEYCLOAK_ISSUER=https://$HOST/auth/realms/alfresco
mvn -B -ntp clean test
TEST_RESULT=$?
echo "TEST_RESULT=${TEST_RESULT}"
cd ../..
fi
if [[ "${{ github.event.head_commit.message }}" != *"[keep env]"* ]]; then
cd test/scripts
./auth0-api.sh delete $KC_BUILD_NAME
fi
if [[ "${TEST_RESULT}" == "1" ]]; then
echo "Tests failed, exiting"
exit 1
fi
- name: "Show cluster status after install"
if: always()
run: |
helm ls --all-namespaces
kubectl get all --all-namespaces
kubectl describe pod
test_upgrade:
name: "Test Upgrade"
runs-on: ubuntu-latest
needs: build
if: ${{ !contains(github.event.head_commit.message, '[skip tests]') }}
steps:
- uses: actions/checkout@v4
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v7.0.0
- uses: Alfresco/alfresco-build-tools/.github/actions/setup-java-build@v7.0.0
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_S3_PIPELINE_AMPS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_S3_PIPELINE_AMPS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: "Prepare test environment"
run: |
openssl aes-256-cbc -K ${{ secrets.ENCRYPTED_E69BEC42AE64_KEY }} -iv ${{ secrets.ENCRYPTED_E69BEC42AE64_IV }} -in test/scripts/config-files/realmRsaKeys.json.enc -out test/scripts/config-files/realmRsaKeys.json -d
- name: "Set KC_BUILD_NAME"
run: |
KC_BUILD_NAME=$(echo ${BRANCH_NAME} | cut -c1-28 | tr /_ - | tr -d [:punct:] | awk '{print tolower($0)}')-${BUILD_NUMBER}
echo "KC_BUILD_NAME=$KC_BUILD_NAME" >> "$GITHUB_ENV"
echo $KC_BUILD_NAME
- name: "Test"
run: |
cd test/saml
mvn -B -ntp clean package -DskipTests
./upgrade/test-upgrade.sh
cleanup:
name: "Cleanup"
runs-on: ubuntu-latest
needs: [test_linux, test_windows, test_helm, test_upgrade]
if: always()
steps:
- uses: Alfresco/alfresco-build-tools/.github/actions/get-build-info@v7.0.0
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_S3_PIPELINE_AMPS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_S3_PIPELINE_AMPS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: "Clean up S3"
run: aws s3 rm s3://${S3_ARTIFACTS_BUCKET}/ci-${BUILD_NUMBER}/ --recursive