-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
160 lines (149 loc) · 4.27 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
variables:
BUILD_DIR: dist
CHROME_IMAGE_TAG: 125.0.6422.141-1-nodejs-20.14.0
DEPENDENCY_CACHE_IMAGE: $CI_REGISTRY/particify/dev/foss/arsnova-webclient/dependency-cache-chromebrowser-nodejs
workflow:
rules:
# Create pipeline for either the MR or the branch/tag but not both
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "schedule" || $CI_PIPELINE_SOURCE == "web"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_TAG =~ /^v[0-9]+/ || $CI_COMMIT_BRANCH =~ /^[0-9]+\.[0-9]+$/ || $CI_COMMIT_BRANCH =~ /^renovate\//
default:
image: $DEPENDENCY_CACHE_IMAGE:$CHROME_IMAGE_TAG
interruptible: true
before_script:
- date
- corepack enable
- yarn install --immutable
after_script:
- date
lint:
stage: test
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
allow_failure: false
script:
- yarn eslint --config=eslint.config.ci.mjs --max-warnings=0 src projects
prettier:
stage: test
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
allow_failure: false
script:
- yarn prettier --check .
stylelint:
stage: test
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
allow_failure: false
script:
- yarn stylelint "**/*.scss"
unit_tests:
stage: test
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
allow_failure: false
variables:
CHROME_BIN: /usr/bin/google-chrome
script:
- yarn test
storybook:
stage: test
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
allow_failure: false
script:
- yarn build-storybook
artifacts:
expire_in: 2 days
paths:
- '$BUILD_DIR'
ngbuild:
stage: build
rules:
- if: $CI_PIPELINE_SOURCE != "schedule"
allow_failure: false
artifacts:
expire_in: 2 days
paths:
- '$BUILD_DIR'
script:
- sed -i "s/\$VERSION_COMMIT_HASH/$CI_COMMIT_SHA/" src/environments/environment.prod.ts
- sed -i "s/\$VERSION_COMMIT_DATE/$CI_COMMIT_TIMESTAMP/" src/environments/environment.prod.ts
- yarn build
docker_image:
stage: deploy
dependencies:
- ngbuild
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ['']
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: on_success
variables:
DOCKER_TAG: next
- when: manual
variables:
DOCKER_TAG: dev-$CI_COMMIT_REF_SLUG
variables:
DOCKER_IMAGE: $CI_REGISTRY/$CI_PROJECT_PATH
KANIKO_CONTEXT: $CI_PROJECT_DIR
KANIKO_DOCKERFILE: $CI_PROJECT_DIR/docker/Dockerfile
allow_failure: true
interruptible: false
before_script:
- date
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor
--context "$KANIKO_CONTEXT"
--dockerfile "$KANIKO_DOCKERFILE"
--destination "$DOCKER_IMAGE:$DOCKER_TAG"
--build-arg "ARSNOVA_BUILD_DIR=`echo $BUILD_DIR`"
prepare_dependency_cache:
stage: .pre
image: particifydev/chromebrowser-nodejs:$CHROME_IMAGE_TAG
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
variables:
YARN_GLOBAL_FOLDER: .yarn-global
artifacts:
expire_in: 2 hours
paths:
- .yarn-global
script:
# NOOP
- ':'
dependency_cache:
stage: build
needs:
- prepare_dependency_cache
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ['']
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
variables:
DOCKER_IMAGE: $DEPENDENCY_CACHE_IMAGE
DOCKER_TAG: $CHROME_IMAGE_TAG
KANIKO_CONTEXT: $CI_PROJECT_DIR
KANIKO_DOCKERFILE: $CI_PROJECT_DIR/docker/dependency-cache.Dockerfile
YARN_GLOBAL_FOLDER: .yarn-global
allow_failure: true
interruptible: false
before_script:
- date
script:
- mkdir -p /kaniko/.docker
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
- /kaniko/executor
--context "$KANIKO_CONTEXT"
--dockerfile "$KANIKO_DOCKERFILE"
--destination "$DOCKER_IMAGE:$DOCKER_TAG"
--build-arg "BASE_TAG=`echo $DOCKER_TAG`"
--build-arg "YARN_GLOBAL_FOLDER=`echo $YARN_GLOBAL_FOLDER`"