-
Notifications
You must be signed in to change notification settings - Fork 10
124 lines (118 loc) · 4.37 KB
/
test-workflow.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
name: Test Framework Suite
on:
pull_request:
branches:
- develop
concurrency:
group: 'develop'
jobs:
build-id:
runs-on: ubuntu-latest
outputs:
uuid: ${{ steps.uuid.outputs.value }}
steps:
- name: 'uuid'
id: uuid
run: echo "::set-output name=value::$GITHUB_SHA-$(date +"%s")"
jest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Yarn
run: npm install -g yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-modules-
- name: Install project dependencies (via cache)
run: yarn --prefer-offline
- name: Run Jest Tests
run: yarn jest
cypress-run:
needs: build-id
runs-on: ubuntu-latest
container:
image: cypress/browsers:node16.16.0-chrome107-ff107
options: --user 1001
strategy:
fail-fast: false
matrix:
containers: [1, 2, 3, 4, 5]
env:
REACT_APP_PD_ENV: 'github-ci'
REACT_APP_PD_SUBDOMAIN_ALLOW_LIST: '*'
REACT_APP_PD_USER_TOKEN: ${{ secrets.PD_INTEGRATION_USER_TOKEN }}
REACT_APP_PD_REQUIRED_ABILITY: ${{ secrets.PD_REQUIRED_ABILITY }}
REACT_APP_DD_APPLICATION_ID: ${{ secrets.DD_APPLICATION_ID }}
REACT_APP_DD_CLIENT_TOKEN: ${{ secrets.DD_CLIENT_TOKEN }}
REACT_APP_DD_SITE: ${{ secrets.DD_SITE }}
REACT_APP_DD_SAMPLE_RATE: ${{ secrets.DD_SAMPLE_RATE }}
REACT_APP_DD_TRACK_INTERACTIONS: ${{ secrets.DD_TRACK_INTERACTIONS }}
REACT_APP_DD_DEFAULT_PRIVACY_LEVEL: ${{ secrets.DD_DEFAULT_PRIVACY_LEVEL }}
CYPRESS_API_URL: ${{ format('{0}:1234', secrets.CYPRESS_API_URL) }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache Yarn Dependencies
uses: actions/cache@v2
id: yarn-cache
with:
path: |
~/.cache/Cypress
${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
restore-keys: ${{ runner.os }}-modules-
- name: Install project dependencies (via cache)
run: yarn --prefer-offline
- name: Run Cypress Tests
run: |
Xvfb -screen 0 1920x1080x24 :99 & export DISPLAY=:99
yarn start &
npx wait-on http://localhost:3000 && \
npx cy2 run \
--group "e2e" \
--browser chrome \
--headless \
--parallel \
--record \
--key ${CYPRESS_RECORD_KEY} \
--ci-build-id ${{ needs.build-id.outputs.uuid }} && \
pkill Xvfb
# Below steps required to pass GitHub status as we are manually running Cypress
- name: Cypress tests ✅
if: ${{ success() }}
run: |
curl --request POST \
--url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \
--header 'authorization: Bearer ${{ secrets.GH_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"context": "cypress-run",
"state": "success",
"description": "Cypress tests passed",
"target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}'
- name: Cypress tests 🚨
if: ${{ failure() }}
run: |
curl --request POST \
--url https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.sha }} \
--header 'authorization: Bearer ${{ secrets.GH_TOKEN }}' \
--header 'content-type: application/json' \
--data '{
"context": "cypress-run",
"state": "failure",
"description": "Cypress tests failed",
"target_url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}'