forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (136 loc) · 4.63 KB
/
unit-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
name: unit-tests
on:
pull_request:
push:
branches:
- master
jobs:
run-tests:
name: python-${{ matrix.python-version }},django-${{ matrix.django-version }},${{ matrix.shard_name }}
if: (github.repository == 'edx/edx-platform-private') || (github.repository == 'openedx/edx-platform' && (startsWith(github.base_ref, 'open-release') == false))
runs-on: [ edx-platform-runner ]
strategy:
matrix:
python-version:
- "3.8"
django-version:
- "pinned"
- "4.2"
# When updating the shards, remember to make the same changes in
# .github/workflows/unit-tests-gh-hosted.yml
shard_name:
- "lms-1"
- "lms-2"
- "lms-3"
- "lms-4"
- "lms-5"
- "lms-6"
- "openedx-1-with-lms"
- "openedx-2-with-lms"
- "openedx-1-with-cms"
- "openedx-2-with-cms"
- "cms-1"
- "cms-2"
- "common-with-lms"
- "common-with-cms"
- "xmodule-with-lms"
- "xmodule-with-cms"
# We expect Django 4.0 to fail, so don't stop when it fails.
continue-on-error: ${{ matrix.django-version == '4.0' }}
steps:
- name: sync directory owner
run: sudo chown runner:runner -R .*
- name: checkout repo
uses: actions/checkout@v3
- name: start mongod server for tests
run: |
sudo mkdir -p /data/db
sudo chmod -R a+rw /data/db
mongod &
- name: install requirements
run: |
sudo make test-requirements
if [[ "${{ matrix.django-version }}" != "pinned" ]]; then
sudo pip install "django~=${{ matrix.django-version }}.0"
sudo pip check # fail if this test-reqs/Django combination is broken
fi
- name: list installed package versions
run: |
sudo pip freeze
- name: Setup and run tests
uses: ./.github/actions/unit-tests
- name: Renaming coverage data file
run: |
mv reports/.coverage reports/${{ matrix.shard_name }}.coverage
- name: Upload coverage
uses: actions/upload-artifact@v3
with:
name: coverage
path: reports/${{matrix.shard_name}}.coverage
# This job aggregates test results. It's the required check for branch protection.
# https://github.com/marketplace/actions/alls-green#why
# https://github.com/orgs/community/discussions/33579
success:
name: Unit tests successful
if: (github.repository == 'edx/edx-platform-private') || (github.repository == 'openedx/edx-platform' && (startsWith(github.base_ref, 'open-release') == false))
needs:
- run-tests
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
# uses: re-actors/[email protected]
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe
with:
jobs: ${{ toJSON(needs) }}
compile-warnings-report:
runs-on: [ edx-platform-runner ]
needs: [ run-tests ]
steps:
- name: sync directory owner
run: sudo chown runner:runner -R .*
- uses: actions/checkout@v3
- name: collect pytest warnings files
uses: actions/download-artifact@v3
with:
name: pytest-warnings-json
path: test_root/log
- name: display structure of downloaded files
run: ls -la test_root/log
- name: compile warnings report
run: |
python openedx/core/process_warnings.py --dir-path test_root/log --html-path reports/pytest_warnings/warning_report_all.html
- name: save warning report
if: success()
uses: actions/upload-artifact@v3
with:
name: pytest-warning-report-html
path: |
reports/pytest_warnings/warning_report_all.html
# Combine and upload coverage reports.
coverage:
needs: run-tests
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.8 ]
steps:
- name: Checkout repo
uses: actions/checkout@v3
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
name: coverage
path: reports
- name: Install Python dependencies
run: |
pip install -r requirements/edx/coverage.txt
- name: Run coverage
run: |
coverage combine reports/*
coverage report
coverage xml
- uses: codecov/codecov-action@v3