-
Notifications
You must be signed in to change notification settings - Fork 52
158 lines (129 loc) · 4.92 KB
/
dailyTests.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
154
155
156
157
158
name: Protofy CI Daily tests
on:
schedule:
- cron: '0 8,20 * * *' # Runs at 8 AM, 20 PM UTC every day
workflow_dispatch: # Allows manual triggering
jobs:
test:
if: github.repository == 'Protofy-xyz/Protofy'
runs-on: self-hosted
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js 20.4.x
uses: actions/setup-node@v4
with:
node-version: '20.4.x'
- name: Setup yarn
run: npm install -g yarn
- name: Set up Node.js 20.4.x
uses: actions/setup-node@v4
with:
node-version: '20.4.x'
cache: 'yarn'
- name: Install NodeJS dependencies
run: yarn
- name: Prepare dev
run: |
echo 'Packaging project'
yarn prepare-dev
- name: Start project
run: |
echo 'Started project'
yarn dev-fast > /dev/null &
- name: Healthcheck services start
run: node .github/scripts/healthcheck-start.js
- name: Install tests dependencies
run: cd ./apps/next && yarn test:deps
- name: Run tests
run: |
set -o pipefail
yarn test:all:long | tee ${{ runner.temp }}/test_output.txt
- name: Get test report
if: always() # executed always even if job fails
run: node .github/scripts/retrieveTestsReport.js ${{ runner.temp }}/test_output.txt > ${{ runner.temp }}/testsReport.txt
- name: Show output report
run: cat ${{ runner.temp }}/testsReport.txt
- name: Upload result # upload saved result as artifact to be consumed at notify job
if: always() # executed always even if job fails
uses: actions/upload-artifact@v3
with:
name: reports
path: ${{ runner.temp }}/testsReport.txt
notify:
runs-on: self-hosted
needs: test
if: always() && github.repository == 'Protofy-xyz/Protofy' # This ensures that the notify job runs whether the test job succeeds or fails
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Node.js 20.4.x
uses: actions/setup-node@v4
with:
node-version: '20.4.x'
- name: Download all artifacts
uses: actions/download-artifact@v3
- name: '[healthcheck] "test" job status and testsReprot content'
run: |
echo "${{ needs.test.result }}"
cat reports/testsReport.txt
- name: Save report to environment variable
run: |
echo "TEST_REPORT<<EOF" >> $GITHUB_ENV
cat reports/testsReport.txt | sed 's/\x1b\[[0-9;]*m//g' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Get shorten GitHub sha
run: echo "GITHUB_SHORT_SHA=$(echo ${{ github.sha }} | cut -c 1-7)" >> $GITHUB_ENV
- name: Get skipped status to retrieve color and save it to environment variable
run: |
if grep -q "🚧 PASS" reports/testsReport.txt; then
echo "SKIPPED=True" >> $GITHUB_ENV
echo "TEST_COLOR=#ffa600" >> $GITHUB_ENV
echo "TEST_AVATAR_COLOR=orange" >> $GITHUB_ENV
else
echo "SKIPPED=False" >> $GITHUB_ENV
echo "TEST_COLOR=#00e065" >> $GITHUB_ENV
echo "TEST_AVATAR_COLOR=green" >> $GITHUB_ENV
fi
- name: Test Success
uses: rjstone/discord-webhook-notify@v1
if: needs.test.result == 'success'
with:
severity: info
details: Test Succeeded!
username: ${{ github.event.pusher.name }}
color: ${{ env.TEST_COLOR }}
avatarUrl: https://raw.githubusercontent.com/Protofy-xyz/Protofy/assets/protofito_${{ env.TEST_AVATAR_COLOR}}.png
description: |
🚨🚨🚨Long Tests Report🚨🚨🚨
${{ env.TEST_REPORT }}
footer: "Workflow: ${{ github.workflow }}"
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
- name: Test Failure
uses: rjstone/discord-webhook-notify@v1
if: needs.test.result == 'failure'
with:
severity: error
details: Test Failed!
username: ${{ github.event.pusher.name }}
color: '#f13932'
avatarUrl: https://raw.githubusercontent.com/Protofy-xyz/Protofy/assets/protofito_red.png
description: |
🚨🚨🚨Long Tests Report🚨🚨🚨
${{ env.TEST_REPORT }}
footer: "Workflow: ${{ github.workflow }}"
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
- name: Test Cancelled
uses: rjstone/discord-webhook-notify@v1
if: needs.test.result == 'cancelled'
with:
severity: warn
details: Job Cancelled!
username: ${{ github.event.pusher.name }}
color: '#ffa600'
avatarUrl: https://raw.githubusercontent.com/Protofy-xyz/Protofy/assets/protofito_orange.png
description: |
🚨🚨🚨Long Tests Report🚨🚨🚨
*Long Tests have beeen cancelled!*
footer: "Workflow: ${{ github.workflow }}"
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}