forked from oppia/oppia
-
Notifications
You must be signed in to change notification settings - Fork 0
205 lines (204 loc) · 8.64 KB
/
backend_tests.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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: Backend tests
on:
merge_group:
types: [checks_requested]
push:
branches:
- develop
- release-*
pull_request:
branches:
- develop
- release-*
jobs:
run_tests:
name: Run backend tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-22.04]
shard: [1, 2, 3, 4, 5]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8.15'
architecture: 'x64'
- name: Cache node modules and third_party/static
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: |
/home/runner/work/oppia/yarn_cache
/home/runner/work/oppia/oppia/third_party/static
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock', 'dependencies.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install Oppia dependencies
uses: ./.github/actions/install-oppia-dependencies
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
- name: Install packages for optimized coverage
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
run: sudo apt-get install -y python-dev-is-python3 gcc
- name: Install coverage and configparser
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
run: pip install coverage configparser
- name: Run backend test shard
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
run: PYTHONIOENCODING=utf-8 python -m scripts.run_backend_tests --generate_coverage_report --generate_time_report --ignore_coverage --exclude_load_tests --test_shard ${{ matrix.shard }}
- name: Report failure if failed on oppia/oppia develop branch
if: ${{ failure() && github.event_name == 'push' && github.repository == 'oppia/oppia' && github.ref == 'refs/heads/develop'}}
uses: ./.github/actions/send-webhook-notification
with:
message: "A backend test failed on the upstream develop branch."
webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }}
- name: Upload time report
uses: actions/upload-artifact@v3
with:
name: ${{ format('backend_test_time_shard_{0}', matrix.shard) }}
path: backend_test_time_report.json
retention-days: 1
- name: Upload coverage report
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
uses: actions/upload-artifact@v3
with:
name: ${{ format('backend_test_coverage_shard_{0}', matrix.shard) }}
include-hidden-files: true
path: .coverage
retention-days: 1
check_combined_coverage:
name: Check combined backend test coverage
needs: run_tests
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8.15'
architecture: 'x64'
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: /home/runner/work/oppia/yarn_cache
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
# We need this so that we can check coverage of autogenerated code
- name: Install Oppia dependencies
uses: ./.github/actions/install-oppia-dependencies
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
- name: Install coverage
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
run: pip install coverage
- name: Download coverage report for shard 1
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
uses: actions/download-artifact@v3
with:
name: backend_test_coverage_shard_1
path: coverage/coverage_1
- name: Download coverage report for shard 2
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
uses: actions/download-artifact@v3
with:
name: backend_test_coverage_shard_2
path: coverage/coverage_2
- name: Download coverage report for shard 3
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
uses: actions/download-artifact@v3
with:
name: backend_test_coverage_shard_3
path: coverage/coverage_3
- name: Download coverage report for shard 4
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
uses: actions/download-artifact@v3
with:
name: backend_test_coverage_shard_4
path: coverage/coverage_4
- name: Download coverage report for shard 5
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
uses: actions/download-artifact@v3
with:
name: backend_test_coverage_shard_5
path: coverage/coverage_5
- name: Move coverage reports from artifact folders to coverage folder
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
shell: bash
run: |
for i in {1..5}; do cp coverage/coverage_$i/.coverage coverage/.coverage.$i; done
- name: Combine coverage reports
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
shell: bash
run: coverage combine coverage/.coverage.*
- name: Check coverage
if: startsWith(github.head_ref, 'update-changelog-for-release') == false
shell: bash
run: PYTHONIOENCODING=utf-8 python -m scripts.check_overall_backend_test_coverage
- name: Report failure if failed on oppia/oppia develop branch
if: ${{ failure() && github.event_name == 'push' && github.repository == 'oppia/oppia' && github.ref == 'refs/heads/develop'}}
uses: ./.github/actions/send-webhook-notification
with:
message: "Backend coverage checks failed on the upstream develop branch."
webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }}
check_backend_test_times:
name: Check backend test times
needs: run_tests
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python 3.8
uses: actions/setup-python@v4
with:
python-version: '3.8.15'
architecture: 'x64'
- name: Download time report for shard 1
uses: actions/download-artifact@v3
with:
name: backend_test_time_shard_1
path: backend_test_time_reports_artifacts/backend_test_time_1
- name: Download time report for shard 2
uses: actions/download-artifact@v3
with:
name: backend_test_time_shard_2
path: backend_test_time_reports_artifacts/backend_test_time_2
- name: Download time report for shard 3
uses: actions/download-artifact@v3
with:
name: backend_test_time_shard_3
path: backend_test_time_reports_artifacts/backend_test_time_3
- name: Download time report for shard 4
uses: actions/download-artifact@v3
with:
name: backend_test_time_shard_4
path: backend_test_time_reports_artifacts/backend_test_time_4
- name: Download time report for shard 5
uses: actions/download-artifact@v3
with:
name: backend_test_time_shard_5
path: backend_test_time_reports_artifacts/backend_test_time_5
- name: Move time reports from artifact folders to backend_test_time_reports folder
shell: bash
run: |
mkdir -p backend_test_time_reports
for i in {1..5}; do cp backend_test_time_reports_artifacts/backend_test_time_$i/backend_test_time_report.json backend_test_time_reports/backend_test_time_report_$i.json; done
- name: Check test times
run: python -m scripts.check_backend_test_times
shell: bash
- name: Upload test times artifact
if: ${{ github.event_name == 'push' && github.repository == 'oppia/oppia' && github.ref == 'refs/heads/develop' }}
uses: actions/upload-artifact@v3
with:
name: backend_test_times
path: backend_test_times.txt
retention-days: 7