-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy path.gitlab-ci.yml
169 lines (159 loc) · 5.23 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
include:
- local: .rpc-version.yml
- project: perun/common
file: /templates/.gitlab-ci-template.yml
default:
cache:
key:
files:
- package-lock.json
paths:
- .npm
- node_modules
- .cache/Cypress
unprotect: true
image: $CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX/bitnami/node:20-debian-11
variables:
# release from production branch instead of main
RELEASE_FROM_PRODUCTION: 1
CI: 1
CYPRESS_baseUrl: http://localhost:4200
CYPRESS_CACHE_FOLDER: "${CI_PROJECT_DIR}/.cache/Cypress" # needed also for semantic release
CYPRESS_CRASH_REPORTS: 0
CYPRESS_COMMERCIAL_RECOMMENDATIONS: 0
CYPRESS_PORT: 8082
XDG_CACHE_HOME: "/tmp/xdgcachehome/"
# renovate: datasource=gitlab-packages depName=perun/perun-idm/perun:release versioning=semver registryUrl=https://gitlab.ics.muni.cz
FF_NETWORK_PER_BUILD: "true"
.npm:
before_script:
- mkdir -p $CYPRESS_CACHE_FOLDER
- npm ci --prefer-offline
npm_ci:
artifacts:
when: always
paths:
- apps/admin-gui
expire_in: 30 days
test_build:
extends: .npm
needs: [npm_ci]
stage: build
script:
- cp e2e/instanceConfig.json apps/admin-gui/src/assets/config/instanceConfig.json
- npm run build -- --prod --progress=false
artifacts:
when: always
paths:
- dist/apps/admin-gui
- apps/admin-gui
expire_in: 30 days
eslint:
needs: [npm_ci]
extends: .npm
stage: test
script:
- npm run lint
.e2e_docker_build:
stage: build
needs: []
image: registry.gitlab.ics.muni.cz:443/perun/ci/pipeline-components/kaniko:latest
tags:
- k8s-root
before_script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"},\"$CI_DEPENDENCY_PROXY_SERVER\":{\"auth\":\"$(printf "%s:%s" ${CI_DEPENDENCY_PROXY_USER} "${CI_DEPENDENCY_PROXY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
script:
- >-
if crane manifest $CI_REGISTRY_IMAGE/$IMAGE:$RPC_VERSION-k8s; then echo "$IMAGE:$RPC_VERSION-k8s already exists, skipping build"; exit 0; fi
- >-
/kaniko/executor
--context "$CI_PROJECT_DIR/e2e/docker-$IMAGE"
--dockerfile "$CI_PROJECT_DIR/e2e/docker-$IMAGE/Dockerfile"
--build-arg RPC_VERSION="$RPC_VERSION"
--build-arg CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX="$CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX"
--destination "$CI_REGISTRY_IMAGE/$IMAGE:$RPC_VERSION-k8s"
rules:
# run on main branch
- if: &if_main_branch '$CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH && $CI_PIPELINE_SOURCE != "schedule"'
# run in merge requests
- if: &if_merge_request '$CI_MERGE_REQUEST_EVENT_TYPE != "merge_train" && $CI_MERGE_REQUEST_DIFF_BASE_SHA'
changes:
paths: &admin_gui_e2e_files
- apps/admin-gui/**/*
- apps/admin-gui-e2e/**/*
- e2e/**/*
- libs/**/*
- .gitlab-ci.yml
- color-migration.js
- nx.json
- package-lock.json
- package.json
e2e_docker_build_postgres:
extends: .e2e_docker_build
variables:
IMAGE: postgresql
e2e_docker_build_rpc:
extends: .e2e_docker_build
variables:
IMAGE: rpc
script:
- >-
/kaniko/executor
--context "$CI_PROJECT_DIR/e2e/docker-$IMAGE"
--dockerfile "$CI_PROJECT_DIR/e2e/docker-$IMAGE/Dockerfile"
--build-arg CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX="$CI_DEPENDENCY_PROXY_DIRECT_GROUP_IMAGE_PREFIX"
--destination "$CI_REGISTRY_IMAGE/$IMAGE:k8s"
# inspired by https://medium.com/devops-with-valentine/run-your-cypress-e2e-tests-in-gitlab-ci-complete-guide-909990962001
e2e_tests:
extends: .npm
stage: test
needs:
- test_build
- e2e_docker_build_postgres
- e2e_docker_build_rpc
image: registry.gitlab.ics.muni.cz:443/perun/ci/pipeline-components/cypress:latest
tags:
- k8s-3s-hpc
script:
- mkdir $XDG_CACHE_HOME
- npx wait-on http-get://localhost:8080/non/rpc/
- npm run start-dev-admin-gui -- --prod --watch=false --live-reload=false &
- npx wait-on $CYPRESS_baseUrl
- cd apps/admin-gui-e2e
- cp tsconfig.cypress.json tsconfig.json
- npx cypress run --reporter junit --headless --browser chrome
artifacts:
when: always
paths:
- dist/cypress/apps/admin-gui-e2e/videos
- dist/cypress/apps/admin-gui-e2e/screenshots
expire_in: 30 days
reports:
junit:
- apps/admin-gui-e2e/test-results.xml
services:
- name: $CI_REGISTRY_IMAGE/postgresql:$RPC_VERSION-k8s
alias: db
variables:
POSTGRESQL_USERNAME: perun
POSTGRESQL_PASSWORD: test
POSTGRESQL_DATABASE: perun
HEALTHCHECK_TCP_PORT: "5432"
- name: $CI_REGISTRY_IMAGE/rpc:k8s
alias: perun-rpc
variables:
HEALTHCHECK_TCP_PORT: "8009"
- name: registry.gitlab.ics.muni.cz:443/perun/ci/pipeline-components/perun-apache:latest
variables:
HEALTHCHECK_TCP_PORT: "8080"
rules:
# run on main branch automatically
- if: *if_main_branch
# run in merge requests manually
- if: *if_merge_request
when: manual
changes:
paths: *admin_gui_e2e_files
# 2024-08-02: temporary workaround until runner issue is fixed; revert asap
allow_failure: true