-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
azure-ci.yml
70 lines (61 loc) · 2.81 KB
/
azure-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
# if you want to configure triggers for Azure CI see
# https://docs.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops&tabs=yaml#tags
jobs:
# Example job that runs end-to-end tests using Cypress test runner
# https://www.cypress.io/
# Job names can contain alphanumeric characters and '_', cannot start with a number
- job: Cypress_e2e_tests
pool:
vmImage: 'ubuntu-latest'
strategy:
parallel: 4
steps:
- task: NodeTool@0
inputs:
versionSpec: '22.x'
displayName: 'Install Node.js'
# npm modules and Cypress binary should be cached
# otherwise the install will be too slow
# https://docs.microsoft.com/en-us/azure/devops/pipelines/caching/?view=azure-devops
# since the username / user home directory are not available via system variables
# (there is even an open question about it)
# https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops
# just use "/home/vsts" for now
- task: CacheBeta@1
inputs:
key: npm | $(Agent.OS) | package-lock.json
path: /home/vsts/.npm
restoreKeys: npm | $(Agent.OS) | package-lock.json
displayName: Cache npm packages
- task: CacheBeta@1
inputs:
key: cypress | $(Agent.OS) | package-lock.json
path: /home/vsts/.cache/Cypress
restoreKeys: cypress | $(Agent.OS) | package-lock.json
displayName: Cache Cypress binary
# Install Node dependencies
- script: npm ci
displayName: 'Install npm dependencies'
- script: npm run cy:verify
displayName: 'Cypress verify'
- script: npm run cy:info
displayName: 'Cypress info'
# The next command starts the server and runs Cypress end-to-end tests against it.
# The test artifacts (screenshots, test output) will be uploaded to Cypress Cloud.
# To record on Cypress Cloud we need to set CYPRESS_RECORD_KEY environment variable.
# For setting ci-build-id, BUILD_BUILDNUMBER is a good candidate
# Note that `npm run start & npx cypress run` is included below for brevity only.
# This pattern is not ideal because Cypress may run before the server reaches a true ready state.
# For better solutions see https://on.cypress.io/guides/continuous-integration.
- script: |
npx print-env AGENT
npx print-env BUILD
npx print-env SYSTEM
npm run start &
npx cypress run --record --parallel --ci-build-id $BUILD_BUILDNUMBER --group "Azure CI"
displayName: 'Run Cypress tests'
env:
# avoid warnings about terminal
TERM: xterm
# map the secret Cypress record key as environment variable for this step
CYPRESS_RECORD_KEY: $(CYPRESS_RECORD_KEY)