forked from DeepLcom/deepl-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
132 lines (116 loc) · 3.18 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
# Note: This GitLab CI configuration is used for internal testing, users can ignore it.
include:
- project: '${CI_PROJECT_NAMESPACE}/ci-libs-for-client-libraries'
file:
- '/${CI_PROJECT_NAME}/.gitlab-ci.yml'
# Global --------------------------
image: node:latest
cache:
key:
files:
- package.json
- package-lock.lock
paths:
- node_modules/
stages:
- check
- build
- test
- publish
before_script:
- npm install
# stage: check ----------------------
eslint:
stage: check
script:
- npm run lint
audit:
stage: check
script:
- npm audit
format:
stage: check
script:
- npm run format
# stage: build ----------------------
build:
stage: build
script:
- npm run clean
- npm run build
artifacts:
paths:
- dist
# stage: test ----------------------
test:
stage: test
extends: .test
parallel:
matrix:
- DOCKER_IMAGE: 'node:17'
- DOCKER_IMAGE: 'node:12'
USE_MOCK_SERVER: 'use mock server'
- DOCKER_IMAGE: 'node:14'
USE_MOCK_SERVER: 'use mock server'
- DOCKER_IMAGE: 'node:16'
USE_MOCK_SERVER: 'use mock server'
- DOCKER_IMAGE: 'node:17'
USE_MOCK_SERVER: 'use mock server'
image: ${DOCKER_IMAGE}
script:
- >
if [[ ! -z "${USE_MOCK_SERVER}" ]]; then
echo "Using mock server"
export DEEPL_SERVER_URL=http://deepl-mock:3000
export DEEPL_MOCK_SERVER_PORT=3000
export DEEPL_PROXY_URL=http://deepl-mock:3001
export DEEPL_MOCK_PROXY_SERVER_PORT=3001
fi
- npm run test:coverage
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage/clover.xml
junit:
- junit.xml
when: always
examples:
stage: test
extends: .test
parallel:
matrix:
- DOCKER_IMAGE: 'node:12'
- DOCKER_IMAGE: 'node:14'
- DOCKER_IMAGE: 'node:16'
- DOCKER_IMAGE: 'node:17'
image: ${DOCKER_IMAGE}
before_script: # Note: replaces global before_script
- npm install --production
script:
- export DEEPL_AUTH_KEY=mock-auth-key
- export DEEPL_SERVER_URL=http://deepl-mock:3000
- export DEEPL_MOCK_SERVER_PORT=3000
- export DEEPL_PROXY_URL=http://deepl-mock:3001
- export DEEPL_MOCK_PROXY_SERVER_PORT=3001
- cd $CI_PROJECT_DIR/examples/commonjs
- npm install
- node index.js
- cd $CI_PROJECT_DIR/examples/esmodule
- npm install
- node index.js
- cd $CI_PROJECT_DIR/examples/typescript
- npm install
- npm run build
- node index.js
# stage: publish ----------------------
publish to NPM:
stage: publish
extends: .publish
dependencies:
- build
rules:
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
script:
- npm config set //registry.npmjs.org/:_authToken ${NPM_PUBLISH_TOKEN}
- npm publish