-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
160 lines (151 loc) · 3.08 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# This is an internal setup used by Good Praxis.
# If this is not run on Good Praxis servers, you need to change it.
stages:
- build
- test
- review
- deploy
variables:
npm_config_cache: "$CI_PROJECT_DIR/.npm"
CYPRESS_CACHE_FOLDER: "$CI_PROJECT_DIR/cache/Cypress"
DOCKER_DRIVER: overlay2
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
paths:
- .npm
- cache/Cypress
build:static:
stage: build
image: cypress/base:18.14.1
before_script:
- npm ci --cache .npm --prefer-offline
script:
- npx danger ci
- npx gatsby clean
- npx gatsby build --prefix-paths
artifacts:
paths:
- public/
except:
- schedules
only:
- merge_requests
- master
- tags
test:
stage: test
needs: []
image: cypress/base:18.14.1
script:
- npm ci --cache .npm --prefer-offline
- npx cypress cache path
- npx cypress cache list
- npm run lint
- npm test
coverage: /All\sfiles.*?\s+(\d+.\d+)/
artifacts:
expire_in: 1 week
paths:
- cypress/screenshots
- cypress/videos
reports:
junit: merged-junit.xml
cache:
policy: pull
except:
- schedules
only:
refs:
- merge_requests
- tags
changes:
- src/**/*
- cypress/**/*
uptime:
stage: test
cache: {}
needs: []
only:
- schedules
script:
- curl -sL -w "%{http_code}" -I "www.goodpraxis.coop" -o /dev/null | grep 200
- curl -sL -w "%{http_code}" -I "goodpraxis.link" -o /dev/null | grep 200
tags:
- nginx
- review-apps
- goodpraxis
review:
stage: review
cache: {}
needs: ["build:static"]
script:
- rsync -av --delete public /srv/nginx/pages/$CI_PROJECT_PATH_SLUG-$CI_BUILD_REF_SLUG
dependencies:
- build:static
environment:
name: review/$CI_BUILD_REF_NAME
url: https://$CI_PROJECT_PATH_SLUG-$CI_BUILD_REF_SLUG.$APPS_DOMAIN
on_stop: stop_review
only:
- merge_requests
tags:
- nginx
- review-apps
- goodpraxis
stop_review:
stage: review
cache: {}
script:
- rm -rf public /srv/nginx/pages/$CI_PROJECT_PATH_SLUG-$CI_BUILD_REF_SLUG
variables:
GIT_STRATEGY: none
when: manual
environment:
name: review/$CI_BUILD_REF_NAME
action: stop
only:
- merge_requests
tags:
- nginx
- review-apps
- goodpraxis
deploy:staging:
stage: deploy
cache: {}
script:
- rsync -av --delete public /srv/nginx/pages/$CI_PROJECT_PATH_SLUG-staging
dependencies:
- build:static
environment:
name: staging
url: https://$CI_PROJECT_PATH_SLUG-staging.$APPS_DOMAIN
only:
refs:
- master
except:
- schedules
tags:
- nginx
- review-apps
- goodpraxis
deploy:live:
stage: deploy
cache: {}
needs: ["build:static"]
script:
- rsync -avz --delete -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress public/ root@$LIVE_DOMAIN:/var/www/html
dependencies:
- build:static
environment:
name: live
url: https://$LIVE_DOMAIN
only:
refs:
- master
- alt-master
tags:
- nginx
- review-apps
- goodpraxis
when: manual