-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
116 lines (107 loc) · 2.88 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
# Cache .npm instead of node_modules because the later one will be automatically removed by `npm ci`
# https://docs.npmjs.com/cli/ci.html
# https://docs.npmjs.com/cli/cache
.npm_install: &npm_install
cache: &cache
key: ${CI_COMMIT_REF_SLUG}
paths:
- ${CI_PROJECT_DIR}/.npm/
- ${CI_PROJECT_DIR}/.cypress/
policy: pull
before_script: &before_script
- export CYPRESS_CACHE_FOLDER=${CI_PROJECT_DIR}/.cypress
- npm config set cache ${CI_PROJECT_DIR}/.npm
- npm ci --prefer-offline
stages:
- build database
- build
- test
- deploy
build database builder:
image: docker:stable
services:
- docker:dind
stage: .pre
variables:
DOCKER_BUILDKIT: 1
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $CI_REGISTRY/rocwang/bus-bus/database-builder:latest
- cd src/database
- docker build --cache-from $CI_REGISTRY/rocwang/bus-bus/database-builder:latest --build-arg BUILDKIT_INLINE_CACHE=1 -t $CI_REGISTRY/rocwang/bus-bus/database-builder:latest .
- docker push $CI_REGISTRY/rocwang/bus-bus/database-builder:latest
build database:
image: $CI_REGISTRY/rocwang/bus-bus/database-builder
stage: build database
cache:
<<: *cache
policy: pull-push
before_script: *before_script
script:
- cd src/database
- make
artifacts:
expire_in: 1 week
paths:
- src/database/gtfs.sqlite3.br
build:
image: node:12
stage: build
<<: *npm_install
script:
- npm run build
artifacts:
expire_in: 1 week
paths:
- dist
.unit test:
image: node:12
stage: build
<<: *npm_install
script:
- npm run test:unit -- --coverage
artifacts:
expire_in: 1 week
paths:
- coverage
.e2e test:
image: cypress/browsers:node12.14.0-chrome79-ff71
stage: test
<<: *npm_install
script:
- npm run test:e2e -- --headless --browser chrome
.lighthouse:
image: cypress/browsers:node12.14.0-chrome79-ff71
stage: test
<<: *npm_install
script:
- 'npx netlify deploy
--dir=dist
--message="#${CI_COMMIT_SHORT_SHA} on ${CI_COMMIT_REF_NAME}: ${CI_COMMIT_TITLE}"
| tee netlify-deploy.log'
- mkdir -p lighthouse
- npx lighthouse $(grep "Live Draft URL" netlify-deploy.log | grep -o 'https://.*\.netlify\.com')
--budget-path=./tests/budgets/home.json
--output json html
--output-path ./lighthouse/audit
--emulated-form-factor=mobile
--throttling-method=provided
--chrome-flags="--headless --no-sandbox"
- node ./tests/budgets/check-lighthouse-report.js ./lighthouse/audit.report.json
artifacts:
expire_in: 1 week
paths:
- lighthouse
when: always
deploy:
image: node:12
stage: deploy
<<: *npm_install
script:
- 'npx netlify deploy
--dir=dist
--prod
--message="#${CI_COMMIT_SHORT_SHA} on ${CI_COMMIT_REF_NAME}:
${CI_COMMIT_TITLE}"'
only:
- master