-
Notifications
You must be signed in to change notification settings - Fork 0
153 lines (131 loc) · 4.71 KB
/
cy-automation-tests-complexity6.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
name: Complexity level 6 -> Run Tests
on:
schedule:
- cron: "0 8 * * *" # run on schedule, examples: https://crontab.guru/examples.html
pull_request:
workflow_dispatch:
inputs:
environment:
type: choice
description: "Environment: localhost / dev"
required: true
options:
- localhost
- dev
default: "localhost"
browser:
type: choice
description: "Browser: chrome / firefox"
required: true
options:
- chrome
- firefox
default: "chrome"
jobs:
build-packages:
name: Build packages & app
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Node.js
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }}
uses: actions/setup-node@v3
with:
node-version: ">=16.0.0"
- name: Build packages
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }}
run: yarn
- name: Build application
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }}
run: yarn build-localhost
- name: Save build folder
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v3
with:
name: build
if-no-files-found: error
path: build
run-specs:
name: Run Tests
needs: [build-packages]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Node.js
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }}
uses: actions/setup-node@v3
with:
node-version: ">=16.0.0"
- name: Download the build folders
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }}
uses: actions/download-artifact@v3
with:
name: build
path: build
- name: Install Serve
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }}
run: yarn global add serve
- name: Run application on localhost
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }}
run: serve -s ${{ github.workspace }}/build &
- name: Run Tests on LOCALHOST
if: ${{ inputs.environment == 'localhost' || github.event_name == 'pull_request' }}
uses: cypress-io/github-action@v6
with:
install: true
wait-on: "http://localhost:3000"
wait-on-timeout: 120
browser: ${{ inputs.browser }}
config-file: /${{ github.workspace }}/cypress/configs/cypress.localhost.config.js
- name: Run Tests on DEV
if: ${{ github.event_name == 'schedule' || inputs.environment != 'localhost' && github.event_name != 'pull_request' }}
uses: cypress-io/github-action@v6
with:
install: true
browser: ${{ inputs.browser }}
config-file: /${{ github.workspace }}/cypress/configs/cypress.dev.config.js
- name: Cypress screenshots
uses: actions/upload-artifact@v2
if: failure()
with:
name: cypress-screenshots
path: ${{ github.workspace }}/cypress/screenshots
- name: Cypress videos
uses: actions/upload-artifact@v2
if: always()
with:
name: cypress-videos
path: ${{ github.workspace }}/cypress/videos
report:
name: Report result
needs: [run-specs]
if: always()
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
if: always()
uses: actions/checkout@v3
- name: Install Node.js
if: always()
uses: actions/setup-node@v3
with:
node-version: ">=16.0.0"
- name: Install dependency
if: always()
run: |
yarn add isomorphic-fetch
- name: Slack (${{ needs.run-specs.result }}) notification
if: always()
run: |
export SCRIPT_PATH=${{ github.workspace }}/slack/${{ needs.run-specs.result == 'success' && 'success_message.js' || 'failed_message.js'}}
export EVENT_NAME=${{ github.event_name }}
export ENVIRONMENT=${{ inputs.environment }}
export BRANCH_NAME=${GITHUB_REF#refs/heads/}
export RUN_URL=${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
yarn node $SCRIPT_PATH "${{ secrets.SLACK_WEBHOOK }}" "$EVENT_NAME" "$BRANCH_NAME" "$RUN_URL" "$ENVIRONMENT"