forked from cypress-io/cypress-documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle.yml
187 lines (172 loc) · 6.02 KB
/
circle.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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# let's try using orbs, jobs, commands
version: 2.1
env_defaults: &env_defaults
## this enables colors + fixes failing unit tests
TERM: xterm
npm_config_loglevel: warn
# even when running as non-root user
# need to set unsafe perm to be able to do `npm postinstall`
npm_config_unsafe-perm: true
defaults: &defaults
working_directory: ~/cypress-documentation
docker:
# the Docker image with Cypress dependencies
# https://github.com/cypress-io/cypress-docker-images
# Note: the image needs to have fonts with Chinese characters
- image: cypress/base:8.16.0
environment:
<<: *env_defaults
jobs:
## code checkout and NPM installs
build:
<<: *defaults
steps:
- checkout
## make sure the TERM is set to 'xterm' in node
## else colors (and tests) will fail
## See the following information
## - http://andykdocs.de/development/Docker/Fixing+the+Docker+TERM+variable+issue
## - https://unix.stackexchange.com/questions/43945/whats-the-difference-between-various-term-variables
- run:
name: Checking TERM is set
command: |
echo 'term env var is:' $TERM
node -e 'assert.equal(process.env.TERM, "xterm", "need TERM to be set for Docker to work")'
node -e 'console.log("TERM %s stdout.isTTY?", process.env.TERM, process.stdout.isTTY)'
# need to restore previously caches files, if any to speed up the build
# we want to use new cache if package or circle files change
- restore_cache:
key: v2-deps-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "circle.yml" }}
- run: npm ci
# run Cypress verify command to cache its status
- run: npm run cypress:verify
# store NPM logs in case there was a problem
- store_artifacts:
path: ~/.npm/_logs
# cache NPM modules and folder with Cypress v3+ binary
# https://on.cypress.io/continuous-integration
# this ensures that this job can start quickly next time
- save_cache:
key: v2-deps-{{ .Branch }}-{{ checksum "package.json" }}-{{ checksum "circle.yml" }}
paths:
- /root/.npm
- /root/.cache
#
# build the static content
#
- run: ls -la
- run: npm run deps
- run: npm run lint -- --max-warnings=0
- run: npm run md-lint
- run: npm test
- run: npm run build
## save entire folder + Cypress binary as the workspace for other jobs to continue
- persist_to_workspace:
root: ~/
paths:
- cypress-documentation
- .cache/Cypress
"docs-tests":
<<: *defaults
parallelism: 4
steps:
# restore application and Cypress binary before running the test command
- attach_workspace:
at: ~/
- run: ls -Rl themes/cypress/source/js
- run:
command: npm start
background: true
- run:
name: Waiting for local server to start
command: $(npm bin)/wait-on http://localhost:2222 --interval 1000 --timeout 360000
- run:
name: Running Cypress tests
command: |
if [ -n "$DOCS_RECORD_KEY" ]; then
$(npm bin)/cypress run --record --key $DOCS_RECORD_KEY --parallel --group "develop"
else
$(npm bin)/cypress run
fi
- store_artifacts:
path: cypress/videos
- store_artifacts:
path: cypress/screenshots
- store_artifacts:
path: npm-debug.log
"deploy-docs-staging":
<<: *defaults
steps:
# restore application and Cypress binary before running the test command
- attach_workspace:
at: ~/
- run: npm ls || true
# need to build the app for STAGING environment
- run: NODE_ENV=staging npm run build
- run: ls -Rl themes/cypress/source/js
- run: ls public
- run: DEBUG=ggit,deploy npm run deploy-prebuilt -- --environment staging --force
- run:
name: Print deployed version
command: cat public/build.json
- run:
name: Test deployed docs
command: |
export CYPRESS_baseUrl=https://docs-staging.cypress.io
if [ -n "$DOCS_RECORD_KEY" ]; then
$(npm bin)/cypress run --record --key $DOCS_RECORD_KEY --parallel --group "staging" --ci-build-id $CIRCLE_WORKFLOW_ID-$CIRCLE_BUILD_NUM
else
$(npm bin)/cypress run
fi
- store_artifacts:
path: cypress/videos
- store_artifacts:
path: cypress/screenshots
- store_artifacts:
path: npm-debug.log
# store NPM logs in case there was a problem
- store_artifacts:
path: ~/.npm/_logs
"deploy-docs-production":
<<: *defaults
steps:
# restore application and Cypress binary before running the test command
- attach_workspace:
at: ~/
# need to build the app for PRODUCTION environment
- run: NODE_ENV=production npm run build
# because we already built docs for production
# use script that just deploys without rebuilding the production docs
- run: npm run deploy-prebuilt -- --environment production --scrape
- run: cat public/build.json
- store_artifacts:
path: npm-debug.log
# store NPM logs in case there was a problem
- store_artifacts:
path: ~/.npm/_logs
workflows:
version: 2
build_and_test:
jobs:
- build
- docs-tests:
requires:
- build
# we can deploy development docs in parallel
# with unit testing them.
- deploy-docs-staging:
filters:
branches:
only:
# allow deploying to staging from "develop"
# and branches starting with special prefix
- develop
- /docs-.*/
requires:
- docs-tests
- deploy-docs-production:
filters:
branches:
only: master
requires:
- docs-tests