generated from cpp-for-yourself/homeworks
-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (154 loc) · 5.65 KB
/
check-homework.yml
File metadata and controls
170 lines (154 loc) · 5.65 KB
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
name: CI
on: [pull_request]
jobs:
add_progress_bar_comment:
runs-on: ubuntu-latest
steps:
- name: Find Comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: With ❤️ from Homework Bot 🤖
- name: Create comment
if: steps.fc.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
## Tests are running! Please wait!

> Progress gif from https://dribbble.com/shots/6592242-Please-wait-Animation#
With ❤️ from Homework Bot 🤖
- name: Update comment
if: steps.fc.outputs.comment-id != ''
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
body: |
## Tests are running! Please wait!

> Progress gif from https://dribbble.com/shots/6592242-Please-wait-Animation#
With ❤️ from Homework Bot 🤖
check_homework:
runs-on: ubuntu-latest
steps:
- name: Checkout this homework
uses: actions/checkout@v2
with:
path: homework
- name: Checkout homework definitions
uses: actions/checkout@v2
with:
repository: cpp-for-yourself/homework-definitions
path: definitions
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: 'x64'
- name: Install prerequisites
run: |
sudo apt install -y libgtest-dev
python -m pip install --upgrade pip pipenv ruamel.yaml schema homework-checker
- name: Run tests
run: |
mkdir checker
cp definitions/homework.yml checker/
cp -r homework/homeworks checker/
cd checker
check_homework -v -i homework.yml -o results.md
- name: Upload result md file
uses: actions/upload-artifact@v2
with:
name: homework_result
path: checker/results.md
upload_results_as_comment:
needs: check_homework
runs-on: ubuntu-latest
steps:
- name: Download result md file
uses: actions/download-artifact@v2
with:
name: homework_result
- name: Render template
id: template
uses: chuhlomin/render-template@v1.2
with:
template: results.md
- name: Find Comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: With ❤️ from Homework Bot 🤖
- name: Update comment with test results
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: ${{ steps.template.outputs.result }}
edit-mode: replace
upload_results_to_wiki:
needs: check_homework
runs-on: ubuntu-latest
steps:
- name: Download result md file
uses: actions/download-artifact@v2
with:
name: homework_result
- name: Find Comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: With 💙 from Homework Bot 🤖
- name: Checkout wiki
uses: actions/checkout@v2
with:
repository: ${{ github.repository }}.wiki
path: wiki
- name: Upload result to wiki
run: |
echo \`\`\` > wiki/Home.md
echo Author: ${{ github.actor }} >> wiki/Home.md
echo Branch: ${{ github.head_ref }} >> wiki/Home.md
echo Commit: ${{ github.sha }} >> wiki/Home.md
echo \`\`\` >> wiki/Home.md
cat results.md >> wiki/Home.md
cd wiki
git config user.name homework-bot
git config user.email homework-bot@github.com
git add .
git commit -m "Update results" --allow-empty
git push
- name: Comment on wiki access failure
uses: peter-evans/create-or-update-comment@v1
if: failure()
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
# ‼️ Wiki is empty ‼️
To fix this error you will have to perform the following actions once:
1. Create _any_ (even empty) page in the wiki by clicking this link: ${{ github.server_url }}/${{ github.repository }}/wiki/_new
2. Rerun the actions by clicking the <kbd>🔄 Re-run all jobs</kbd> button here: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
---
With 💙 from Homework Bot 🤖
edit-mode: replace
- name: Comment on wiki access success
uses: peter-evans/create-or-update-comment@v1
if: success()
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
# ✅ Wiki is available
Check it out at: ${{ github.server_url }}/${{ github.repository }}/wiki
With 💙 from Homework Bot 🤖
edit-mode: replace