-
Notifications
You must be signed in to change notification settings - Fork 8
/
.gitlab-ci.yml
183 lines (173 loc) · 7.32 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
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
image: docker:latest
variables:
GIT_SUBMODULE_STRATEGY: recursive
GOOGLE_TAG: eu.gcr.io/papers-kubernetes/tezblock-frontend:$CI_COMMIT_SHA
TEST_TAG: tezblock_frontend_test_$CI_COMMIT_SHA
GOOGLE_TAG_LATEST: eu.gcr.io/papers-kubernetes/tezblock-frontend:latest
GOOGLE_TAG_DEV: eu.gcr.io/papers-dev-kubernetes/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_SHA
GOOGLE_TAG_LATEST_DEV: eu.gcr.io/papers-dev-kubernetes/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:latest
stages:
- build
- test
# - qa
- build_serve
- publish
- deploy
build:
stage: build
script:
- docker build --build-arg FONTAWESOME_NPM_AUTH_TOKEN --build-arg MAINNET_RPC_URL --build-arg ITHACANET_RPC_URL --build-arg MAINNET_CONSEIL_URL --build-arg ITHACANET_CONSEIL_URL --build-arg MAINNET_CONSEIL_API_KEY --build-arg ITHACANET_CONSEIL_API_KEY --build-arg MAINNET_INDEXER_URL --build-arg ITHACANET_INDEXER_URL --build-arg MAINNET_TARGET_URL --build-arg ITHACANET_TARGET_URL --build-arg GA_KEY --target angular-build -t $TEST_TAG .
tags:
- docker
build_serve:
stage: build_serve
script:
- docker build --build-arg FONTAWESOME_NPM_AUTH_TOKEN --build-arg MAINNET_RPC_URL --build-arg ITHACANET_RPC_URL --build-arg MAINNET_CONSEIL_URL --build-arg ITHACANET_CONSEIL_URL --build-arg MAINNET_CONSEIL_API_KEY --build-arg ITHACANET_CONSEIL_API_KEY --build-arg MAINNET_INDEXER_URL --build-arg ITHACANET_INDEXER_URL --build-arg MAINNET_TARGET_URL --build-arg ITHACANET_TARGET_URL --build-arg GA_KEY -t $GOOGLE_TAG .
only:
- master
- develop
tags:
- docker
test:
allow_failure: false
stage: test
script:
- docker run -e FONTAWESOME_NPM_AUTH_TOKEN -e MAINNET_RPC_URL -e ITHACANET_RPC_URL -e MAINNET_CONSEIL_URL -e ITHACANET_CONSEIL_URL -e MAINNET_CONSEIL_API_KEY -e ITHACANET_CONSEIL_API_KEY -e MAINNET_INDEXER_URL -e ITHACANET_INDEXER_URL -e MAINNET_TARGET_URL -e ITHACANET_TARGET_URL -e GA_KEY --name unit-$CI_COMMIT_SHA $TEST_TAG yarn test-ci
- docker run -e FONTAWESOME_NPM_AUTH_TOKEN -e MAINNET_RPC_URL -e ITHACANET_RPC_URL -e MAINNET_CONSEIL_URL -e ITHACANET_CONSEIL_URL -e MAINNET_CONSEIL_API_KEY -e ITHACANET_CONSEIL_API_KEY -e MAINNET_INDEXER_URL -e ITHACANET_INDEXER_URL -e MAINNET_TARGET_URL -e ITHACANET_TARGET_URL -e GA_KEY --name lint-$CI_COMMIT_SHA $TEST_TAG yarn lint-ci
- docker cp unit-$CI_COMMIT_SHA:/app/coverage/tezblock/lcov.info lcov.info
- docker cp lint-$CI_COMMIT_SHA:/app/lintReport.json lintReport.json
after_script:
- docker rm -f unit-$CI_COMMIT_SHA || true
- docker rm -f lint-$CI_COMMIT_SHA || true
tags:
- docker
artifacts:
paths:
- lcov.info
- lintReport.json
# qa:
# allow_failure: false
# stage: qa
# script:
# - docker create -e FONTAWESOME_NPM_AUTH_TOKEN -e MAINNET_RPC_URL -e ITHACANET_RPC_URL -e MAINNET_CONSEIL_URL -e ITHACANET_CONSEIL_URL -e MAINNET_CONSEIL_API_KEY -e ITHACANET_CONSEIL_API_KEY -e MAINNET_TARGET_URL -e ITHACANET_TARGET_URL -e GA_KEY --name qa-$CI_PIPELINE_ID $TEST_TAG yarn sonar-scanner -- -X
# -Dsonar.typescript.lcov.reportPaths=lcov.info
# -Dsonar.typescript.tslint.reportPaths=lintReport.json
# -Dsonar.test.inclusions=**/*.spec.ts
# -Dsonar.tests=src/
# -Dsonar.exclusions=**/node_modules/**,**/*.spec.ts
# -Dsonar.sources=src/
# -Dsonar.host.url=$SONAR_URL
# -Dsonar.login=$SONAR_LOGIN
# -Dsonar.gitlab.commit_sha=$CI_COMMIT_SHA
# -Dsonar.gitlab.ref_name=$CI_COMMIT_REF_NAME
# -Dsonar.gitlab.project_id=$CI_PROJECT_ID
# -Dsonar.branch.name=$CI_BUILD_REF_NAME
# - docker cp lcov.info qa-$CI_PIPELINE_ID:/app/lcov.info
# - docker cp lintReport.json qa-$CI_PIPELINE_ID:/app/lintReport.json
# - docker start -a qa-$CI_PIPELINE_ID
# after_script:
# - docker rm -f qa-$CI_PIPELINE_ID || true
# tags:
# - docker
publish-prod:
stage: publish
image: google/cloud-sdk
needs: ['build_serve']
before_script:
- echo $GCLOUD_GOOGLE_KEY > key.json
- gcloud auth activate-service-account $GCLOUD_ACCOUNT --key-file key.json
- gcloud config set project $GCLOUD_PROJECT
- gcloud config set account $GCLOUD_ACCOUNT
- gcloud config set compute/zone $GCLOUD_ZONE
- gcloud auth configure-docker
script:
- docker tag $GOOGLE_TAG $GOOGLE_TAG_LATEST
- docker push $GOOGLE_TAG
- docker push $GOOGLE_TAG_LATEST
only:
- master
tags:
- docker
publish-dev:
stage: publish
needs: ['build_serve']
image: google/cloud-sdk
before_script:
- echo $GCLOUD_GOOGLE_KEY_DEV > key.json
- gcloud auth activate-service-account $GCLOUD_ACCOUNT_DEV --key-file key.json
- gcloud config set account $GCLOUD_ACCOUNT_DEV
- gcloud config set project $GCLOUD_PROJECT_DEV
- gcloud config set compute/zone $GCLOUD_ZONE_DEV
- gcloud auth configure-docker
script:
- docker tag $GOOGLE_TAG $GOOGLE_TAG_DEV
- docker tag $GOOGLE_TAG $GOOGLE_TAG_LATEST_DEV
- docker push $GOOGLE_TAG_DEV
- docker push $GOOGLE_TAG_LATEST_DEV
only:
- develop
tags:
- docker
k8s-deploy-development:
stage: deploy
needs: ['publish-dev']
when: manual
image: google/cloud-sdk
before_script:
- echo $GCLOUD_GOOGLE_KEY_DEV > key.json
- gcloud auth activate-service-account $GCLOUD_ACCOUNT_DEV --key-file key.json
- gcloud config set account $GCLOUD_ACCOUNT_DEV
- gcloud config set project $GCLOUD_PROJECT_DEV
- gcloud config set compute/zone $GCLOUD_ZONE_DEV
- gcloud container clusters get-credentials papers-cluster-development
script:
- sed -i "s|_TO_BE_REPLACED_BY_IMAGE_TAG_|"$GOOGLE_TAG_DEV"|g" k8s/tezblock/development/frontend/deployment.yaml
- kubectl apply -f k8s/tezblock/common/namespace.yaml
- kubectl apply -f k8s/tezblock/development/ --recursive
- kubectl apply -f k8s/tezblock/common/ --recursive
only:
- develop
tags:
- docker
k8s-deploy-production:
stage: deploy
needs: ['publish-prod']
when: manual
image: google/cloud-sdk
before_script:
- echo $GCLOUD_GOOGLE_KEY > key.json
- gcloud auth activate-service-account $GCLOUD_ACCOUNT --key-file key.json
- gcloud config set project $GCLOUD_PROJECT
- gcloud config set account $GCLOUD_ACCOUNT
- gcloud config set compute/zone $GCLOUD_ZONE
- gcloud container clusters get-credentials papers-cluster-production
script:
- sed -i "s|_TO_BE_REPLACED_BY_IMAGE_TAG_|"$GOOGLE_TAG"|g" k8s/tezblock/production/frontend/deployment.yaml
- kubectl apply -f k8s/tezblock/common/namespace.yaml
- kubectl apply -f k8s/tezblock/production/ --recursive
- kubectl apply -f k8s/tezblock/common/ --recursive
only:
- master
tags:
- docker
k8s-deploy-ithacanet:
stage: deploy
needs: ['publish-prod']
when: manual
image: google/cloud-sdk
before_script:
- echo $GCLOUD_GOOGLE_KEY > key.json
- gcloud auth activate-service-account $GCLOUD_ACCOUNT --key-file key.json
- gcloud config set project $GCLOUD_PROJECT
- gcloud config set account $GCLOUD_ACCOUNT
- gcloud config set compute/zone $GCLOUD_ZONE
- gcloud container clusters get-credentials papers-cluster-production
script:
- sed -i "s|_TO_BE_REPLACED_BY_IMAGE_TAG_|"$GOOGLE_TAG"|g" k8s/tezblock/ithacanet/frontend/deployment.yaml
- kubectl apply -f k8s/tezblock/common/namespace.yaml
- kubectl apply -f k8s/tezblock/ithacanet/ --recursive
- kubectl apply -f k8s/tezblock/common/ --recursive
only:
- master
tags:
- docker