-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
106 lines (92 loc) · 2.77 KB
/
.gitlab-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
include:
- project: "sinch/sinch-projects/voice/gitlab-pipelines"
ref: main
file: "/jobs/_jobs.yml"
default:
tags: [rtc]
stages:
- lint & test
- build
- integration-tests
cache:
paths:
- node_modules/
# Templates
.node:
before_script:
- npm install
- apk add bash curl jq
image: public.ecr.aws/docker/library/node:20-alpine
interruptible: true
.integration-test:
extends: .vcluster
interruptible: true
variables:
TEST_DOMAIN: sample-oauth-server.k8s-cicd.tools.internal.sinch.com
IMAGE: "098456509636.dkr.ecr.eu-central-1.amazonaws.com/sample-oauth-server-for-fcm-v1:${CI_COMMIT_SHORT_SHA}"
script:
- envsubst < integration-tests/deployment.yaml > deployment_temp.yaml
- mv deployment_temp.yaml integration-tests/deployment.yaml
- kubectl create namespace vcluster
- kubectl apply -f integration-tests
- kubectl wait --for=condition=available --timeout=120s -n vcluster deployment app
- |
ATTEMPT_COUNTER=0
MAX_ATTEMPTS=10
WAIT=5
until kubectl get secret tls-internal-wildcard --namespace vcluster; do
if [ ${ATTEMPT_COUNTER} -eq ${MAX_ATTEMPTS} ]; then
echo "Max attempts reached"
exit 1
fi
printf '.'
ATTEMPT_COUNTER=$(($ATTEMPT_COUNTER+1))
sleep ${WAIT}
done
sleep 60 # waiting for the domain to be registered in Route53
ip=$(dig +short ${TEST_DOMAIN})
if [ -z "$ip" ]; then
echo "The domain not found. The job must be interrupted. Please retry the job in a few minutes."
exit 1
fi
# Concrete jobs
lint:
stage: lint & test
extends: .node
script:
- npm run lint
audit:
stage: lint & test
extends: .node
script:
- npm audit --audit-level=critical
api:test:
stage: lint & test
extends: .node
script:
- npm run test
placeholders:test:
stage: lint & test
extends: .node
script:
- bash -x verify-termination-on-placeholders.sh
docker:image:build:
stage: build
extends: .kaniko
variables:
IMAGE: "sample-oauth-server-for-fcm-v1"
REPOSITORY: "098456509636.dkr.ecr.eu-central-1.amazonaws.com"
AWS_ECR_URL: "098456509636.dkr.ecr.eu-central-1.amazonaws.com"
AWS_DEFAULT_REGION: eu-central-1
script:
- echo $CONFIG_JSON_BASE_64 | base64 -d > placeholders/config.json
- echo $SERVICE_ACCOUNT_JSON_BASE64 | base64 -d > placeholders/service-account.json
- !reference [.kaniko, script]
integration:test:
stage: integration-tests
extends: .integration-test
script:
- !reference [.integration-test, script]
- echo $CONFIG_JSON_BASE_64 | base64 -d > placeholders/config.json
- echo $SERVICE_ACCOUNT_JSON_BASE64 | base64 -d > placeholders/service-account.json
- ./test-endpoints.sh https://sample-oauth-server.k8s-cicd.tools.internal.sinch.com