-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
executable file
·122 lines (110 loc) · 3.53 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
---
image: docker.io/library/node:18
variables:
KUBERNETES_MEMORY_REQUEST: "1Gi"
KUBERNETES_MEMORY_LIMIT: "1Gi"
# cache setting, by default only pull files
cache: &global_cache
key: "${CI_COMMIT_REF_SLUG}"
paths:
- .npm/
- node_modules/
- dist/
policy: pull
stages:
- static analysis
- build
- test
- docker build
- ci-pipeline
- mirroring
static-analysis:
tags: ['new-runner']
stage: static analysis
needs: []
cache:
# inherit all global cache settings
<<: *global_cache
script:
# install npm packages, using cache as source. Use npm install instead of ci here to make use of
# cached node_modules if it exists
- npm install --cache .npm --prefer-offline --no-audit
# check if ng client is already installed and create a symlink if needed
- test -e /usr/local/bin/ng || ln -s $PWD/node_modules/.bin/ng /usr/local/bin/ng
# check if webdriver-manager is already installed and create a symlink if needed
- test -e /usr/local/bin/webdriver-manager || ln -s $PWD/node_modules/.bin/webdriver-manager /usr/local/bin/webdriver-manager
- ng lint
# report all vulnerabilities, fail on moderate ones
- npm audit --prod --audit-level=moderate
- npm audit --prod || true
- node_modules/.bin/linthtml .
ng-build:
tags: ['new-runner']
stage: build
needs: []
cache:
# this task populates the cache, set the policy accordingly
<<: *global_cache
policy: pull-push
variables:
KUBERNETES_MEMORY_REQUEST: "3Gi"
KUBERNETES_MEMORY_LIMIT: "3Gi"
script:
# install npm packages, using cache as source. To speed things up for feature branches, use npm install to
# make use of cached node_modules
- |
if [[ ${CI_COMMIT_REF_NAME} == "main" ]]; then
npm ci --cache .npm --prefer-offline --no-audit
else
npm install --cache .npm --prefer-offline --no-audit
fi
# build application
- npm run-script build:prod
ng-test:
tags: ['new-runner']
stage: test
image: docker.io/trion/ng-cli-karma:16.2.9
needs: ['ng-build']
cache:
# inherit all global cache settings
<<: *global_cache
variables:
KUBERNETES_MEMORY_REQUEST: "2Gi"
KUBERNETES_MEMORY_LIMIT: "2Gi"
script:
# check if ng client is already installed and create a symlink if needed
- test -e /usr/local/bin/ng || ln -s $PWD/node_modules/.bin/ng /usr/local/bin/ng
# run Karma/Jasmine unit tests
- ng test --no-watch --no-progress --browsers=Chrome
build-image:
tags: ['new-runner']
stage: docker build
needs: ['ng-build']
image:
name: gcr.io/kaniko-project/executor:v1.21.1-debug
entrypoint: [""]
cache:
# inherit all global cache settings
<<: *global_cache
script:
- ln -s /run/secrets/runner-job-secrets/docker_config_ci.json /kaniko/.docker/config.json
# copy compiled application from cache to runtime image. This assumes cache accessible by all runners
- echo "Going to build and push ${PRIVATE_IMAGE}:${CI_COMMIT_REF_NAME}"
# build the runtime image from files in 'dist/pebbles-frontend'
- /kaniko/executor
--context "${CI_PROJECT_DIR}"
--dockerfile "${CI_PROJECT_DIR}/deployment/Dockerfile.runtime"
--destination "${CI_IMAGE_REPO_CI}/pebbles-frontend:${CI_COMMIT_REF_NAME}"
--build-arg PB_APP_VERSION=$(date -Is)
${CI_KANIKO_OPTIONS}
# call pipeline project for 'main' branch changes to update QA
ci-pipeline:
stage: ci-pipeline
needs: ['build-image']
trigger:
project: pebbles/cicd-pipeline
branch: main
strategy: depend
only:
refs:
- main