-
Notifications
You must be signed in to change notification settings - Fork 3
194 lines (161 loc) · 7.12 KB
/
code-quality-pipline.yaml
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
name: Code Quality
on:
pull_request:
branches:
- main
- stage
- develop
concurrency:
group: self-hosted-${{ github.head_ref || github.ref }}-${{ github.base_ref }}
cancel-in-progress: true
jobs:
app-linting:
name: 🔉 Linting the code
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out the repository code
uses: actions/checkout@v2
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'yarn'
cache-dependency-path: yarn.lock
- name: Installing yarn packages
run: yarn
- run: echo "🖥️ The workflow is now ready to start linting the ${{ github.repository }} code."
- name: Run the eslint
run: yarn ci:code:lint
unit-testing:
name: 🔉 Run Unit Tests
needs: app-linting
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out the repository code
uses: actions/checkout@v2
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'yarn'
cache-dependency-path: yarn.lock
- name: Installing yarn packages
run: yarn
- run: echo "🖥️ The workflow is now ready to start unit testing the ${{ github.repository }} code."
- name: Run the jest tests
run: yarn ci:unit:test
- name: Upload unit test coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./cypress/reports/jest-coverage/coverage-final.json
flags: unittest-${{ github.base_ref }}
env_vars: OS,Node
name: codecov-unittest-${{ github.base_ref }}
fail_ci_if_error: true
verbose: true
ui-tests:
name: 🔊 UI testing - ${{ matrix.browser }} browser
needs: [app-linting, unit-testing]
strategy:
fail-fast: false
matrix:
browser: [chrome , firefox]
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out the repository code
uses: actions/checkout@v2
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '14'
cache: 'yarn'
cache-dependency-path: yarn.lock
- name: Installing yarn packages
run: yarn
- name: Decrypt the envs and cypress env files
run: ./.github/scripts/decrypt_secrets.sh
env:
DECRYPT_SECRETS_PASSPHRASE: ${{ secrets.DECRYPT_SECRETS_PASSPHRASE }}
- name: Remove the reports
run: yarn ci:remove:reports
- name: Set the project environment to DEVELOP
if: ${{ contains( github.base_ref , 'develop' ) }}
run: yarn firebase use DEVELOP --token ${{ secrets.FIREBASE_TOKEN }}
- name: Set the project environment to STAGE
if: ${{ contains( github.base_ref , 'stage' ) }}
run: yarn firebase use STAGE --token ${{ secrets.FIREBASE_TOKEN }}
- name: Set the project environment to MAIN
if: ${{ contains( github.base_ref , 'main' ) }}
run: yarn firebase use MAIN --token ${{ secrets.FIREBASE_TOKEN }}
- name: Auto generating the firebase configuration
run: yarn firebase apps:sdkconfig web --token ${{ secrets.FIREBASE_TOKEN }} --json | tail -n +3 |head -n -1 > ./src/utasks-configuration.json
- run: echo "🖥️ The workflow is now ready to start cypress tests the ${{ github.repository }} code in the ${{matrix.browser}} browser."
- name: 🙈 UI Tests - On ${{ matrix.browser }}
id: uiTest
uses: cypress-io/github-action@v2
with:
install: false
start: yarn ci:app:start
wait-on: 'http://localhost:5050'
wait-on-timeout: 300
browser: ${{ matrix.browser }}
headless: true
config: reporter=mochawesome
parallel: false
record: true
# group: e2e-testing-${{ matrix.browser }}
tag: node-v14-${{ matrix.browser }},e2e-testing
env: TESTING_ENV=LOCAL
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.UTASKS_CYPRESS_RECORD_KEY }}
# pass GitHub token to allow accurately detecting a build vs a re-run build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# pass the project ID from the secrets through environment variable
CYPRESS_PROJECT_ID: ${{ secrets.UTASKS_CYPRESS_PROJECT_ID }}
- name: 👀 Generate the testing report
if: always()
run: yarn ci:code:test:report
- name: Publish the reports on GitHub - on success
uses: actions/upload-artifact@v2
if: ${{ contains( steps.uiTest.outcome , 'success' ) }}
with:
name: ${{ matrix.browser }}-cypress-reports-success-${{ github.sha }}
path: |
cypress/reports/mochawsome/**.html
- name: Publish the reports on GitHub - on failure
uses: actions/upload-artifact@v2
if: ${{ failure() && contains( steps.uiTest.outcome , 'failure' ) }}
with:
name: ${{ matrix.browser }}-cypress-reports-failure-${{ github.sha }}
path: |
cypress/reports/mochawsome/**.html
cypress/reports/screenshots/**
cypress/reports/videos/**
!cypress/reports/.nyc_output
!cypress/reports/coverage
!cypress/reports/downloads
- name: Upload UI coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }} # not required for public repos
files: ./cypress/reports/cy-coverage/coverage-final.json
flags: ui-tests-${{ matrix.browser }}-${{ github.base_ref }} # optional
env_vars: OS,Node
name: codecov-ui-${{ matrix.browser }}-${{ github.base_ref }} # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)