-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path.gitlab-ci.yml
executable file
·119 lines (105 loc) · 2.38 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
.executor-docker: &executor-docker
tags:
- docker
.node-image: &node-image
image: node:12.21.0-alpine@sha256:de39b4c1af2c10c4f38c9b52f51cd152daa84f868d4af701be79a7a2ba2d8fc2
.install-git: &install-git
before_script:
- apk update && apk upgrade && apk add --no-cache git
.dependency-npm: &dependency-npm
dependencies:
- npm
.dependency-unit: &dependency-unit
dependencies:
- npm
- unit
.only-branches: &only-branches
except:
- main
- tags
- triggers
.not-branches: ¬-branches
only:
- main
- tags
stages:
- build
- compliance-tests
- security-tests
- unit-tests
- quality-tests
npm:
stage: build
<<: *executor-docker
<<: *node-image
script:
- HASH="$( md5sum package.json )"
- CACHE=/tmp/${CI_PROJECT_NAME}_${HASH}.tgz
- if [ -f "$CACHE" ]; then
tar -xzf "$CACHE";
else
rm -f /tmp/${CI_PROJECT_NAME}_*.tgz &&
npm install &&
tar -czf "$CACHE" node_modules;
fi
artifacts:
name: "${CI_PROJECT_NAME}_${CI_JOB_ID}_${CI_COMMIT_SHA}"
expire_in: 30 mins
paths:
- node_modules
commitlint-branch:
stage: compliance-tests
<<: *executor-docker
<<: *node-image
<<: *install-git
<<: *dependency-npm
script:
- git fetch origin main --quiet
- git checkout main --quiet
- git reset --hard origin/main --quiet
- git checkout - --quiet
- npm run compliance:commits
<<: *only-branches
eslint:
stage: compliance-tests
<<: *executor-docker
<<: *node-image
<<: *dependency-npm
script:
- npm run compliance:lint
outdated:
stage: security-tests
<<: *executor-docker
<<: *node-image
<<: *dependency-npm
script:
- npm outdated
allow_failure: true
audit:
stage: security-tests
<<: *executor-docker
<<: *node-image
script:
- npm run security:audit
unit:
stage: unit-tests
<<: *executor-docker
<<: *node-image
<<: *dependency-npm
script:
- npm run tests:unit
artifacts:
expire_in: 30 mins
paths:
- .coverage/unit/lcov.info
coverage: /^Lines\s*:\s(\d+(?:.\d+)?%)/
sonar-scanner:
stage: quality-tests
tags:
- transparent
image: $CI_REGISTRY/engineering-practice/sonar-scanner:latest
<<: *dependency-unit
script:
- sed -i.bak -e "s|^SF:\(.*/[[:digit:]]\{1,\}/.*/\)|SF:$( pwd )/|g" .coverage/unit/lcov.info
- sonar-scanner -Dsonar.projectBaseDir=$CI_PROJECT_DIR
<<: *not-branches