/
githubmirror
/
oppia
Обзор
Документация
Войти
/
githubmirror
/
oppia
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
.github/workflows/backend_unit_tests.yml
222 строки
10 KB
kundan
Fix #25031: Pin develop SHA for backend coverage checks to ensure consistency across CI jobs (#25318)
01 апр 2026, 09:59
Не верифицирован
01 апр 2026, 09:59
dd3bb47
Код
Авторство
О чём код?
name: Backend unit tests permissions: read-all on: merge_group: types: - checks_requested - destroyed push: branches: - develop - release-* pull_request: branches: - develop - release-* types: - opened - synchronize - reopened - closed concurrency: group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.event.merge_group.head_ref || github.ref || github.run_id }} cancel-in-progress: true jobs: setup_merge_sha: name: Capture develop SHA runs-on: ubuntu-22.04 outputs: develop_sha: ${{ steps.get_sha.outputs.sha }} steps: - name: Get latest develop SHA id: get_sha run: | SHA=$(git ls-remote https://github.com/oppia/oppia.git refs/heads/develop | awk '{print $1}') echo "sha=$SHA" >> "$GITHUB_OUTPUT" run_backend_associated_test_file_checks: name: Verify associated test files needs: setup_merge_sha runs-on: ubuntu-22.04 # Skip the job if we were only launched to cancel running jobs via the concurrency key above. if: ${{ ! ( (github.event_name == 'merge_group' && github.event.action == 'destroyed') || (github.event_name == 'pull_request' && github.event.action == 'closed') ) }} steps: - name: Checkout repository so that local actions can be used uses: actions/checkout@v4 - name: Merge develop and set up dependencies uses: ./.github/actions/merge-develop-and-set-up-dependencies with: merge_sha: ${{ needs.setup_merge_sha.outputs.develop_sha }} - name: Run backend associated test file check run: python -m scripts.check_backend_associated_test_file - name: Report failure if failed on oppia/oppia develop branch if: ${{ failure() && github.event_name == 'push' && github.repository == 'oppia/oppia' && github.ref == 'refs/heads/develop'}} uses: ./.github/actions/send-webhook-notification with: message: "Some backend files lack an associated test file." webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} run_tests: name: Shard ${{ matrix.shard }} needs: setup_merge_sha runs-on: ubuntu-22.04 # Skip the job if we were only launched to cancel running jobs via the concurrency key above. if: ${{ ! ( (github.event_name == 'merge_group' && github.event.action == 'destroyed') || (github.event_name == 'pull_request' && github.event.action == 'closed') ) }} strategy: fail-fast: ${{ github.event_name == 'merge_group' }} matrix: shard: [1, 2, 3, 4, 5] steps: - name: Checkout repository so that local actions can be used uses: actions/checkout@v4 - name: Merge develop and set up dependencies uses: ./.github/actions/merge-develop-and-set-up-dependencies with: merge_sha: ${{ needs.setup_merge_sha.outputs.develop_sha }} - name: Run backend test shard id: run_backend_test_shard if: startsWith(github.head_ref, 'update-changelog-for-release') == false run: python -m scripts.run_backend_tests --generate_coverage_report --generate_time_report --ignore_coverage --exclude_load_tests --test_shard ${{ matrix.shard }} - name: Report failure if failed on oppia/oppia develop branch if: ${{ steps.run_backend_test_shard.outputs.WORKFLOW_STATUS == 'failure' && github.event_name == 'push' && github.repository == 'oppia/oppia' && github.ref == 'refs/heads/develop'}} uses: ./.github/actions/send-webhook-notification with: message: "A backend test failed on the upstream develop branch." webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} - name: Upload time report uses: actions/upload-artifact@v4 with: name: ${{ format('backend_test_time_shard_{0}', matrix.shard) }} path: backend_test_time_report.json retention-days: 1 - name: Upload coverage report if: startsWith(github.head_ref, 'update-changelog-for-release') == false uses: actions/upload-artifact@v4 with: name: ${{ format('backend_test_coverage_shard_{0}', matrix.shard) }} include-hidden-files: true path: .coverage retention-days: 1 check_combined_coverage: name: Check coverage needs: [run_tests, setup_merge_sha] runs-on: ubuntu-22.04 steps: - name: Checkout repository so that local actions can be used uses: actions/checkout@v4 - name: Merge develop and set up dependencies uses: ./.github/actions/merge-develop-and-set-up-dependencies with: merge_sha: ${{ needs.setup_merge_sha.outputs.develop_sha }} - name: Download coverage report for shard 1 if: startsWith(github.head_ref, 'update-changelog-for-release') == false uses: actions/download-artifact@v4 with: name: backend_test_coverage_shard_1 path: coverage/coverage_1 - name: Download coverage report for shard 2 if: startsWith(github.head_ref, 'update-changelog-for-release') == false uses: actions/download-artifact@v4 with: name: backend_test_coverage_shard_2 path: coverage/coverage_2 - name: Download coverage report for shard 3 if: startsWith(github.head_ref, 'update-changelog-for-release') == false uses: actions/download-artifact@v4 with: name: backend_test_coverage_shard_3 path: coverage/coverage_3 - name: Download coverage report for shard 4 if: startsWith(github.head_ref, 'update-changelog-for-release') == false uses: actions/download-artifact@v4 with: name: backend_test_coverage_shard_4 path: coverage/coverage_4 - name: Download coverage report for shard 5 if: startsWith(github.head_ref, 'update-changelog-for-release') == false uses: actions/download-artifact@v4 with: name: backend_test_coverage_shard_5 path: coverage/coverage_5 - name: Move coverage reports from artifact folders to coverage folder if: startsWith(github.head_ref, 'update-changelog-for-release') == false shell: bash run: | for i in {1..5}; do cp coverage/coverage_$i/.coverage coverage/.coverage.$i; done - name: Combine coverage reports if: startsWith(github.head_ref, 'update-changelog-for-release') == false shell: bash run: coverage combine coverage/.coverage.* - name: Check coverage id: check_backend_coverage if: startsWith(github.head_ref, 'update-changelog-for-release') == false shell: bash run: python -m scripts.check_backend_test_coverage - name: Report failure if failed on oppia/oppia develop branch if: ${{ steps.check_backend_coverage.outputs.WORKFLOW_STATUS == 'failure' && github.event_name == 'push' && github.repository == 'oppia/oppia' && github.ref == 'refs/heads/develop'}} uses: ./.github/actions/send-webhook-notification with: message: "Backend coverage checks failed on the upstream develop branch." webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} permissions: pull-requests: write check_backend_test_times: name: Check test times needs: [run_tests, setup_merge_sha] runs-on: ubuntu-22.04 steps: - name: Checkout repository so that local actions can be used uses: actions/checkout@v4 - name: Merge develop and set up dependencies uses: ./.github/actions/merge-develop-and-set-up-dependencies with: merge_sha: ${{ needs.setup_merge_sha.outputs.develop_sha }} - name: Download time report for shard 1 uses: actions/download-artifact@v4 with: name: backend_test_time_shard_1 path: backend_test_time_reports_artifacts/backend_test_time_1 - name: Download time report for shard 2 uses: actions/download-artifact@v4 with: name: backend_test_time_shard_2 path: backend_test_time_reports_artifacts/backend_test_time_2 - name: Download time report for shard 3 uses: actions/download-artifact@v4 with: name: backend_test_time_shard_3 path: backend_test_time_reports_artifacts/backend_test_time_3 - name: Download time report for shard 4 uses: actions/download-artifact@v4 with: name: backend_test_time_shard_4 path: backend_test_time_reports_artifacts/backend_test_time_4 - name: Download time report for shard 5 uses: actions/download-artifact@v4 with: name: backend_test_time_shard_5 path: backend_test_time_reports_artifacts/backend_test_time_5 - name: Move time reports from artifact folders to backend_test_time_reports folder shell: bash run: | mkdir -p backend_test_time_reports for i in {1..5}; do cp backend_test_time_reports_artifacts/backend_test_time_$i/backend_test_time_report.json backend_test_time_reports/backend_test_time_report_$i.json; done - name: Check test times run: python -m scripts.check_backend_test_times shell: bash - name: Upload test times artifact if: ${{ github.event_name == 'push' && github.repository == 'oppia/oppia' && github.ref == 'refs/heads/develop' }} uses: actions/upload-artifact@v4 with: name: backend_test_times path: backend_test_times.txt retention-days: 7