Skip to content

Commit

Permalink
Code coverage added (openedx#31630)
Browse files Browse the repository at this point in the history
* fix: code coverage added

* fix: .coverage folder added

* fix: .coverage folder location changed

* fix: combine folder modified

* fix: combine command updated

* fix: .coverage folder rollback

* fix: path commented

* fix: upload path modified

* fix: path updated to root

* fix: .coveragerc added

* fix: new coverage folder added

* fix: combine path removed

* fix: coverage files path changed

* fix: data files path updated

* fix: .coverage added as path

* fix: coveragerc updated

* fix: env TEST_SUIT rollbacked

* fix: renaming coverage files step added

* fix: ls added for testing

* fix: debugging commands added

* fix: triggeering cov command in tox.in

* fix: cd coverage added

* fix: commands modified

* fix: triggering coverage using command

* fix: removed omitteed files

* fix: removed all omited files

* fix: skipped all omitted files

* fix: source updated to root in coveragern

* fix: coveragerc files rolledback

* fix: source changed to edx-platform

* fix: cms-2 shard name reemoved

* fix: rmeoved coveragee trigger

* fix: removed shard added back

* fix: --cov-config=setup.cfg added

* fix: combining cov paths format changed to comma

* fix: bash changeeed for coveerage

* fix: paths updateed for testing

* fix: coverage combine command fixed

* fix: final check applied

* fix: final coveragee step addeed and tested

* fix: actions version upgraded in unit tests

* fix: testing space separated commands

* fix: coverage data files path removeed from combine command

* fix: coverage combine reports/* addedd

* fix: updated --cov path

* fix: data_file path updated by removing TEST_SUIT variable

---------

Co-authored-by: Awais Qureshi <[email protected]>
  • Loading branch information
zubairshakoorarbisoft and awais786 authored Feb 3, 2023
1 parent 7d8409e commit 59a1995
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# .coveragerc for edx-platform
[run]
data_file = reports/${TEST_SUITE}.coverage
branch=true
data_file = reports/.coverage
source =
cms
common/djangoapps
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/unit-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ runs:
- name: run tests
shell: bash
run: |
python -Wd -m pytest -p no:randomly --ds=${{ env.settings_path }} ${{ env.unit_test_paths }}
python -Wd -m pytest -p no:randomly --ds=${{ env.settings_path }} ${{ env.unit_test_paths }} --cov=.
- name: rename warnings json file
if: success()
Expand Down
49 changes: 46 additions & 3 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: sudo chown runner:runner -R .*

- name: checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v3

# This gives Mongo several chances to start. We started getting flakiness
# around 2022-02-15 wherein the start command would sometimes exit with:
Expand Down Expand Up @@ -74,6 +74,16 @@ jobs:
- 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
Expand All @@ -96,7 +106,7 @@ jobs:
steps:
- name: sync directory owner
run: sudo chown runner:runner -R .*
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: collect pytest warnings files
uses: actions/download-artifact@v2
with:
Expand All @@ -112,8 +122,41 @@ jobs:
- name: save warning report
if: success()
uses: actions/upload-artifact@v2
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

0 comments on commit 59a1995

Please sign in to comment.