We have a need to lock the version of Django for production and tests, but also to test on newer versions of Django so that we can get the repo ready for long-term-support releases. We've been doing that by extracting the `django==x.y.z` from the pip-compiled files and moving it to a django.txt that is then co-installed but can be overridden during tests. The problem is that this can result in broken packages. The approach here is to have `make test-requirements` continue to ensure a consistent set of packages, and then install a different Django on top of that in the CI script -- and call `pip check` to make sure that combination isn't broken. Adding Django 4.0 to the unit-tests.yml matrix will now correctly result in this error and a failing job: `django-splash 1.2.1 has requirement Django<4.0, but you have django 4.0.8.` The other half of this is to change other CI runners to remove their ability to control the Django version, since it's complicated to make this work, and we probably only need it in unit-tests.yml. Convert them to just use `make test-requirements`. Also: - Simplify handling of `pip --src` by setting `PIP_SRC` (rather than our own `PIP_SRC_DIR`, which pip ignores because `--src-dir` isn't an option that it knows). This is needed to allow `make test-requirements` to do the pip calls. An alternative would be to set a pip-options env var for the make target to use, but `PIP_SRC` already exists. - Remove outdated modifications to common_constraints - Add comment explaining why pylint tests need dev-requirements
120 lines
3.6 KiB
YAML
120 lines
3.6 KiB
YAML
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.0"
|
|
shard_name:
|
|
- "lms-1"
|
|
- "lms-2"
|
|
- "lms-3"
|
|
- "lms-4"
|
|
- "lms-5"
|
|
- "lms-6"
|
|
- "openedx-1"
|
|
- "openedx-2"
|
|
- "openedx-3"
|
|
- "openedx-4"
|
|
- "cms-1"
|
|
- "cms-2"
|
|
- "common-1"
|
|
- "common-2"
|
|
- "xmodule-1"
|
|
# 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@v2
|
|
|
|
# This gives Mongo several chances to start. We started getting flakiness
|
|
# around 2022-02-15 wherein the start command would sometimes exit with:
|
|
#
|
|
# * Starting database mongodb
|
|
# ...fail!
|
|
#
|
|
# ...not having produced any logs or other output. We couldn't figure out
|
|
# what was causing Mongo to fail, so this is a (temporary?) hack to get
|
|
# PRs unblocked.
|
|
- 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
|
|
|
|
# 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: Tests successful
|
|
if: always()
|
|
needs:
|
|
- run-tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Decide whether the needed jobs succeeded or failed
|
|
# uses: re-actors/alls-green@v1.2.1
|
|
uses: re-actors/alls-green@13b4244b312e8a314951e03958a2f91519a6a3c9
|
|
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@v2
|
|
- name: collect pytest warnings files
|
|
uses: actions/download-artifact@v2
|
|
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@v2
|
|
with:
|
|
name: pytest-warning-report-html
|
|
path: |
|
|
reports/pytest_warnings/warning_report_all.html
|