-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathsemaphore.yml
112 lines (100 loc) · 4.21 KB
/
semaphore.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
# copied from https://docs.semaphoreci.com/article/50-pipeline-yaml
# NodeJS and JavaScript docs
# https://docs.semaphoreci.com/article/82-language-javascript-and-nodejs
version: v1.0
name: Cypress example Kitchensink
agent:
# Dummy agent - the real agent is under the "task"
# but seems Semaphore requires top level one
machine:
type: e1-standard-2
blocks:
- name: Mac E2E tests
# disable Mac tests with built-in Electron
# until the following issue is resolved
# https://github.com/cypress-io/cypress-example-kitchensink/issues/269
# probably by upgrading Electron
# https://github.com/renderedtext/when#skip-block-exection
skip:
when: "true"
task:
agent:
machine:
type: a1-standard-4
prologue:
commands:
- checkout
- node --version
- npm --version
- npm ci
# verify the Cypress test binary so its check status is cached
- npm run cy:verify
- npx cypress cache path
- npx cypress cache list
# prints SEMAPHORE_* environment variables
- npm run print-env -- SEMAPHORE
jobs:
- name: Cypress E2E
commands:
# prints SEMAPHORE_* environment variables
- npm run print-env -- SEMAPHORE
- npm run e2e
- name: Linux E2E tests
task:
agent:
# Linux machine with our Docker image
machine:
type: e1-standard-2
containers:
# use Cypress-provided Docker image
# https://github.com/cypress-io/cypress-docker-images
- name: main
image: 'cypress/browsers:node12.0.0-chrome75'
# see https://docs.semaphoreci.com/article/66-environment-variables-and-secrets
secrets:
# we have created new secrets object at https://cypress-io.semaphoreci.com/secrets/new
# for this organization. In this job we can now access CYPRESS_RECORD_KEY
- name: dashboard
# common commands that should be done before each E2E test command
prologue:
commands:
- checkout
# from "How to Cache Cypress binary on Semaphore" documentation page
# https://semaphoreci.com/docs/caching-between-builds.html#caching-cypress-binary
- mkdir -p $SEMAPHORE_CACHE_DIR/Cypress
- mkdir -p ~/.cache || true
- ln -s $SEMAPHORE_CACHE_DIR/Cypress ~/.cache/Cypress
# restore previously cached files if any
# re-install dependencies if package.json or this semaphore YML file changes
- cache restore npm-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json)-$(checksum .semaphore/semaphore.yml)
- npm ci
# verify the Cypress test binary so its check status is cached
- npm run cy:verify
- cache store npm-$SEMAPHORE_GIT_BRANCH-$(checksum package-lock.json)-$(checksum .semaphore/semaphore.yml) ~/.npm
# prints SEMAPHORE_* environment variables
- npm run print-env -- SEMAPHORE
# finally, build the web application and run end-to-end tests
- npm run build
# start the web application server in the background
- npm run start:ci &
jobs:
# all "prologue" commands have finished by now
# and we can define several jobs to execute in parallel on 3 machines
# for Cypress https://on.cypress.io/parallelization we just need
# to pass same "--ci-build-id" to link these parallel jobs together
# on Semaphore V2 we can use the common SEMAPHORE_PIPELINE_ID value
- name: Cypress E2E 1
commands:
# prints SEMAPHORE_* environment variables
- npm run print-env -- SEMAPHORE
- npm run e2e:record:parallel -- --ci-build-id $SEMAPHORE_PIPELINE_ID
- name: Cypress E2E 2
commands:
# prints SEMAPHORE_* environment variables
- npm run print-env -- SEMAPHORE
- npm run e2e:record:parallel -- --ci-build-id $SEMAPHORE_PIPELINE_ID
- name: Cypress E2E 3
commands:
# prints SEMAPHORE_* environment variables
- npm run print-env -- SEMAPHORE
- npm run e2e:record:parallel -- --ci-build-id $SEMAPHORE_PIPELINE_ID