forked from cypress-io/cypress-documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
circle.yml
158 lines (145 loc) · 4.83 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
version: 2
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
parallelism: 1
working_directory: ~/cypress-documentation
docker:
# the Docker image with Cypress dependencies
- image: cypress/base:8
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 a separate cache for each package.json
- restore_cache:
key: v1-{{ .Branch }}-deps
- run: npm install
- run: npm prune
# see if package-lock.json file has changed
# if yes, this means it is out of date
- run: git status
# save each node_modules folder per package
- save_cache:
key: v1-{{ .Branch }}-deps-{{ checksum "package.json" }}
paths:
- node_modules
## save entire folder as artifact for other jobs to continue
## hmm, do not see a good way to cache it, since all code
## might change
- save_cache:
key: cypress-documentation-{{ .Branch }}-{{ .Revision }}
paths:
- /root/cypress-documentation
"docs-tests":
<<: *defaults
steps:
- restore_cache:
key: cypress-documentation-{{ .Branch }}-{{ .Revision }}
- run: ls -la
- run: npm run deps
- run: npm run lint
- run: npm test
- run: npm run build
- 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 90000
- run:
name: Running Cypress tests
command: |
if [ -n "$DOCS_RECORD_KEY" ]; then
$(npm bin)/cypress run --record --key $DOCS_RECORD_KEY
else
$(npm bin)/cypress run
fi
- store_artifacts:
path: cypress/videos
- store_artifacts:
path: cypress/screenshots
"deploy-docs-staging":
<<: *defaults
steps:
- restore_cache:
key: cypress-documentation-{{ .Branch }}-{{ .Revision }}
- run: npm ls || true
- 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
else
$(npm bin)/cypress run
fi
- store_artifacts:
path: cypress/videos
- store_artifacts:
path: cypress/screenshots
"deploy-docs-production":
<<: *defaults
steps:
- restore_cache:
key: cypress-documentation-{{ .Branch }}-{{ .Revision }}
- 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
workflows:
version: 2
build_and_test:
jobs:
- build
- docs-tests:
requires:
- build
# we can deploy development docs in parallel with
# unit testining them.
- deploy-docs-staging:
filters:
branches:
only:
# allow deploying to staging from "develop"
# and branches starting with special prefix
- develop
- /docs-.*/
- get-branch
requires:
- docs-tests
- deploy-docs-production:
filters:
branches:
only: master
requires:
- docs-tests