Skip to content

Commit

Permalink
fix: github action artifact upload issue
Browse files Browse the repository at this point in the history
  • Loading branch information
irtazaakram committed Jun 25, 2024
1 parent c596736 commit 4fa1a4b
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 102 deletions.
35 changes: 0 additions & 35 deletions .github/actions/unit-tests/action.yml

This file was deleted.

47 changes: 0 additions & 47 deletions .github/actions/verify-tests-count/action.yml

This file was deleted.

12 changes: 0 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,3 @@ updates:
interval: "weekly"
reviewers:
- "openedx/arbi-bom"
- package-ecosystem: "github-actions"
directory: "/.github/actions/unit-tests/"
schedule:
interval: "weekly"
reviewers:
- "openedx/arbi-bom"
- package-ecosystem: "github-actions"
directory: "/.github/actions/verify-tests-count/"
schedule:
interval: "weekly"
reviewers:
- "openedx/arbi-bom"
105 changes: 97 additions & 8 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,36 @@ jobs:
run: |
pip freeze
- name: Setup and run tests
uses: ./.github/actions/unit-tests
- name: set settings path
shell: bash
run: |
echo "settings_path=$(python scripts/unit_test_shards_parser.py --shard-name=${{ matrix.shard_name }} --output settings )" >> $GITHUB_ENV
- name: get unit tests for shard
shell: bash
run: |
echo "unit_test_paths=$(python scripts/unit_test_shards_parser.py --shard-name=${{ matrix.shard_name }} )" >> $GITHUB_ENV
- name: run tests
shell: bash
run: |
python -Wd -m pytest -p no:randomly --ds=${{ env.settings_path }} ${{ env.unit_test_paths }} --cov=.
- name: rename warnings json file
if: success()
shell: bash
run: |
cd test_root/log
mv pytest_warnings.json pytest_warnings_${{ matrix.shard_name }}.json
- name: save pytest warnings json file
if: success()
uses: actions/upload-artifact@v4
with:
name: pytest-warnings-json-${{ matrix.shard_name }}
path: |
test_root/log/pytest_warnings*.json
overwrite: true

- name: Renaming coverage data file
run: |
Expand All @@ -109,8 +137,8 @@ jobs:
- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: coverage
path: reports/${{matrix.shard_name}}.coverage
name: coverage-${{ matrix.shard_name }}
path: reports/${{ matrix.shard_name }}.coverage
overwrite: true

collect-and-verify:
Expand All @@ -130,8 +158,49 @@ jobs:
run: |
make test-requirements
- name: verify unit tests count
uses: ./.github/actions/verify-tests-count
- 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/ pavelib/ -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
# This job aggregates test results. It's the required check for branch protection.
# https://github.com/marketplace/actions/alls-green#why
Expand All @@ -156,7 +225,8 @@ jobs:
- name: collect pytest warnings files
uses: actions/download-artifact@v4
with:
name: pytest-warnings-json
pattern: pytest-warnings-json-*
merge-multiple: true
path: test_root/log

- name: display structure of downloaded files
Expand All @@ -175,6 +245,24 @@ jobs:
reports/pytest_warnings/warning_report_all.html
overwrite: true

merge-artifacts:
runs-on: ubuntu-20.04
needs: [compile-warnings-report]
steps:
- name: Merge Pytest Warnings JSON Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: pytest-warnings-json
pattern: pytest-warnings-json-*
delete-merged: true

- name: Merge Coverage Artifacts
uses: actions/upload-artifact/merge@v4
with:
name: coverage
pattern: coverage-*
delete-merged: true

# Combine and upload coverage reports.
coverage:
if: (github.repository == 'edx/edx-platform-private') || (github.repository == 'openedx/edx-platform' && (startsWith(github.base_ref, 'open-release') == false))
Expand All @@ -196,7 +284,8 @@ jobs:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
name: coverage
pattern: coverage-*
merge-multiple: true
path: reports

- name: Install Python dependencies
Expand Down

0 comments on commit 4fa1a4b

Please sign in to comment.