The test count was off because without warnings disabled, it was also counting warning lines as tests. The `head -n -2` grabs everything but the last two lines which contain a count (not sure why this isn't used). If you run without `--disable-warnings` this will include any warnings that occur during test collection which we don't want in this case.
50 lines
2.6 KiB
YAML
50 lines
2.6 KiB
YAML
name: 'Verify unit tests count'
|
|
description: 'shared steps to verify unit tests count on both Github hosted and self hosted runners.'
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: collect tests from all modules
|
|
shell: bash
|
|
run: |
|
|
echo "root_cms_unit_tests_count=$(pytest --disable-warnings --collect-only --ds=cms.envs.test cms/ -q | head -n -2 | wc -l)" >> $GITHUB_ENV
|
|
echo "root_lms_unit_tests_count=$(pytest --disable-warnings --collect-only --ds=lms.envs.test lms/ openedx/ common/djangoapps/ xmodule/ -q | head -n -2 | wc -l)" >> $GITHUB_ENV
|
|
|
|
- name: get GHA unit test paths
|
|
shell: bash
|
|
run: |
|
|
echo "cms_unit_test_paths=$(python scripts/gha_unit_tests_collector.py --cms-only)" >> $GITHUB_ENV
|
|
echo "lms_unit_test_paths=$(python scripts/gha_unit_tests_collector.py --lms-only)" >> $GITHUB_ENV
|
|
|
|
|
|
- name: collect tests from GHA unit test shards
|
|
shell: bash
|
|
run: |
|
|
echo "cms_unit_tests_count=$(pytest --disable-warnings --collect-only --ds=cms.envs.test ${{ env.cms_unit_test_paths }} -q | head -n -2 | wc -l)" >> $GITHUB_ENV
|
|
echo "lms_unit_tests_count=$(pytest --disable-warnings --collect-only --ds=lms.envs.test ${{ env.lms_unit_test_paths }} -q | head -n -2 | wc -l)" >> $GITHUB_ENV
|
|
|
|
|
|
- name: add unit tests count
|
|
shell: bash
|
|
run: |
|
|
echo "root_all_unit_tests_count=$((${{ env.root_cms_unit_tests_count }}+${{ env.root_lms_unit_tests_count }}))" >> $GITHUB_ENV
|
|
echo "shards_all_unit_tests_count=$((${{ env.cms_unit_tests_count }}+${{ env.lms_unit_tests_count }}))" >> $GITHUB_ENV
|
|
|
|
- name: print unit tests count
|
|
shell: bash
|
|
run: |
|
|
echo CMS unit tests from root: ${{ env.root_cms_unit_tests_count }}
|
|
echo LMS unit tests from root: ${{ env.root_lms_unit_tests_count }}
|
|
echo CMS unit tests from shards: ${{ env.cms_unit_tests_count }}
|
|
echo LMS unit tests from shards: ${{ env.lms_unit_tests_count }}
|
|
echo All root unit tests count: ${{ env.root_all_unit_tests_count }}
|
|
echo All shards unit tests count: ${{ env.shards_all_unit_tests_count }}
|
|
|
|
- name: fail the check
|
|
shell: bash
|
|
if: ${{ env.root_all_unit_tests_count != env.shards_all_unit_tests_count }}
|
|
run: |
|
|
echo "::error title='Unit test modules in unit-test-shards.json (unit-tests.yml workflow) are outdated'::unit tests running in unit-tests
|
|
workflow don't match the count for unit tests for entire edx-platform suite, please update the unit-test-shards.json under .github/workflows
|
|
to add any missing apps and match the count. for more details please take a look at scripts/gha-shards-readme.md"
|
|
exit 1
|