-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
96 lines (76 loc) · 1.8 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
image: node:10
stages:
- build
- qa
- staging
##############################
# Templates
##############################
.except_master_template: &except_releases
except:
- master
- tags
.on_branches_template: &on_branches
only:
- branches
.on_releases_template: &on_releases
only:
- master
- tags
##############################
# Branches
##############################
build:
# <<: *on_branches
# <<: *except_releases
stage: build
script:
- npm install --no-audit --loglevel=error
- npm run build
test:
stage: qa
script:
- npm install --no-audit --loglevel=error
- npm run build
- npm run test
lint:
stage: qa
script:
- npm install --no-audit --loglevel=error
- npm run lint
audit:
stage: qa
script:
- npm install --no-audit --loglevel=error
- npm audit
allow_failure: true
##############################
# Functions
##############################
.build_functions: &build_functions |
# Build functions and variables
[[ "$TRACE" ]] && set -x
export PROJECT_NAME_LOWER="$(echo $CI_PROJECT_NAME | tr '[:upper:]' '[:lower:]')"
function git_version() {
set -e
# parse the current git commit hash
COMMIT=`git rev-parse HEAD`
BRANCH="${CI_COMMIT_REF_NAME}"
# check if the current commit has a matching tag
HAS_TAG=$(git describe --exact-match --abbrev=0 --tags ${COMMIT} 2> /dev/null || true)
TAG=$(git describe --tags --abbrev=1)
# use the matching tag as the version, if available
if [ ! -z "$HAS_TAG" ]; then
VERSION="${TAG}.${CI_PIPELINE_IID}"
else
if [ "$BRANCH" = "master" ]; then
BRANCH="pre"
fi
VERSION="${TAG}-${BRANCH}"
fi
echo "Git version..."
export GITVERSION=${VERSION}
echo $GITVERSION
}
before_script:
- *build_functions