Repository navigation
Expand file tree
/
Copy pathcircle.yml
More file actions
94 lines (86 loc) · 3.2 KB
/
Copy pathcircle.yml
File metadata and controls
94 lines (86 loc) · 3.2 KB
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
version: 2.1
orbs:
# https://github.com/cypress-io/circleci-orb
cypress: cypress-io/cypress@3
executor: cypress/default
parameters:
GREP_TAGS:
# tag can be an individual tag like
# @sanity, @adding, @complete, @editing, @item, @persistence
# @routing, @regression
# or a combination of tags like "@adding @item" (OR)
# "@editing+@item" (AND)
# see https://github.com/bahmutov/cy-grep
type: string
default: ''
RECORDED_RUN_TAG:
description: Optional tag to put on the recorded Cypress Dashboard run
type: string
default: ''
MACHINES:
description: The number of parallel machines to use
type: integer
default: 1
workflows:
nightly:
triggers:
- schedule:
cron: '0 0 * * *'
filters:
branches:
only:
- master
jobs:
- cypress/run:
name: Run all tests
# disable the test names, need to support
# TypeScript cypress.config.ts file
# https://github.com/bahmutov/find-cypress-specs/issues/47
start-command: 'npm start'
cypress-command: 'npx cypress run --record --tags @nightly --group "All tests"'
tagged:
when: << pipeline.parameters.GREP_TAGS >>
jobs:
- cypress/run:
# because the tags might have commas, standard Cypress CLI
# can choke parsing --env grepTags=... arguments
# thus pass possible tags using an environment variable
pre-steps:
- run:
name: Set any grepTags
command: echo 'export CYPRESS_grepTags="<< pipeline.parameters.GREP_TAGS >>"' >> $BASH_ENV
name: Run tagged tests
start-command: 'npm start'
cypress-command: 'npx cypress run --record --tags "<< pipeline.parameters.GREP_TAGS >>,<< pipeline.parameters.RECORDED_RUN_TAG >>" --group "Tagged tests"'
build:
unless: << pipeline.parameters.GREP_TAGS >>
jobs:
- cypress/run:
name: Run changed tests
start-command: 'npm start'
cypress-command: |
# stop if on master branch - all tests should run there
if [ "$CIRCLE_BRANCH" = "master" ]; then
echo "Default branch, will run all tests"
exit 0
fi
# be careful about counting the lines
specsLines=$(git diff --name-only --diff-filter=AMR origin/master | { grep cypress/integration || true; })
n=$(echo $specsLines | sed '/^\s*$/d' | wc -l | tr -d ' ')
specs=$(echo $specsLines | sed '/^\s*$/d' | tr '\n' ',')
echo ""
echo "Changed and added ${n} Cypress specs"
echo ${specs}
echo ""
if [ ${n} -lt 1 ]; then
echo "No Cypress specs changed, exiting..."
exit 0
fi
# we have to form the Cypress run command ourselves
npx cypress run --spec ${specs} --record --group "1. changed specs"
- cypress/run:
name: Run sanity tests
requires:
- Run changed tests
start-command: npm start
cypress-command: 'npx cypress run --parallel --record --env grepTags=@sanity --group "2. all sanity specs"'