-
Notifications
You must be signed in to change notification settings - Fork 52
186 lines (153 loc) · 6.47 KB
/
protofy_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
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
name: Protofy CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
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: Install Python dependencies (venv)
run: sudo apt-get install -y python3-venv
- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Setup yarn
run: npm install -g yarn
- name: Set up Node.js 20.4.x with yarn
uses: actions/setup-node@v4
with:
node-version: '20.4.x'
cache: 'yarn'
- name: Install NodeJS dependencies
run: yarn
- name: Modify requirements.txt with absolute paths
run: |
sed -i 's|../../packages/protopy|'"$GITHUB_WORKSPACE"'/packages/protopy|' requirements.txt
sed -i 's|../../packages/app|'"$GITHUB_WORKSPACE"'/packages/app|' requirements.txt
- name: Install Python dependencies
run: pip install -r requirements.txt
- name: Prepare dev
run: |
echo 'Packaging project'
yarn prepare-dev
- name: Start project
run: |
echo 'Started project'
yarn start-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 | 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.event_name != 'pull_request' && github.repository == 'Protofy-xyz/Protofy' }} # This job runs only if the trigger is not a pull request
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: |
${{ env.TEST_REPORT }}
- **Event:** push
- **Repo:** Protofy-xyz/Protofy at ${{ github.ref }}
- **Author:** ${{ github.event.head_commit.author.name }}
- **Committer [pusher]:** ${{ github.event.head_commit.committer.name }} [${{ github.event.pusher.name }}]
- **Commit [[${{ env.GITHUB_SHORT_SHA }}](${{ github.event.head_commit.url }})]:** ${{ github.event.head_commit.message }}
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: |
${{ env.TEST_REPORT }}
- **Event:** push
- **Repo:** Protofy-xyz/Protofy at ${{ github.ref }}
- **Author:** ${{ github.event.head_commit.author.name }}
- **Committer [pusher]:** ${{ github.event.head_commit.committer.name }} [${{ github.event.pusher.name }}]
- **Commit [[${{ env.GITHUB_SHORT_SHA }}](${{ github.event.head_commit.url }})]:** ${{ github.event.head_commit.message }}
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: |
- **Event:** push
- **Repo:** Protofy-xyz/Protofy at ${{ github.ref }}
- **Author:** ${{ github.event.head_commit.author.name }}
- **Committer [pusher]:** ${{ github.event.head_commit.committer.name }} [${{ github.event.pusher.name }}]
- **Commit [[${{ env.GITHUB_SHORT_SHA }}](${{ github.event.head_commit.url }})]:** ${{ github.event.head_commit.message }}
footer: "Workflow: ${{ github.workflow }}"
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}