From fd0b0dc4a879fd05422d2509a7f27859ff6eb265 Mon Sep 17 00:00:00 2001 From: HardikGoyal2003 Date: Wed, 25 Dec 2024 14:29:58 +0530 Subject: [PATCH] Try to fix e2e test --- .github/workflows/all_lint_checks.yml | 164 +++++----- .github/workflows/all_type_checks.yml | 120 +++---- .github/workflows/backend_unit_tests.yml | 380 +++++++++++----------- .github/workflows/frontend_unit_tests.yml | 162 ++++----- 4 files changed, 413 insertions(+), 413 deletions(-) diff --git a/.github/workflows/all_lint_checks.yml b/.github/workflows/all_lint_checks.yml index 99b21fde5f8a..ac88df465a94 100644 --- a/.github/workflows/all_lint_checks.yml +++ b/.github/workflows/all_lint_checks.yml @@ -1,83 +1,83 @@ -# name: Lint checks -# on: -# merge_group: -# types: [checks_requested] -# push: -# branches: -# - develop -# - release-* -# pull_request: -# branches: -# - develop -# - release-* +name: Lint checks +on: + merge_group: + types: [checks_requested] + push: + branches: + - develop + - release-* + pull_request: + branches: + - develop + - release-* -# jobs: -# backend_lint: -# name: Backend -# 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 Python -# uses: ./.github/actions/merge-develop-and-setup-python -# with: -# use_cache: false -# - name: Initialize Docker containers -# uses: ./.github/actions/install-oppia-dependencies-docker -# - name: Third Party Size Check -# if: startsWith(github.head_ref, 'update-changelog-for-release') == false -# run: make run_tests.third_party_size_check -# - name: Run Lint Checks -# if: startsWith(github.head_ref, 'update-changelog-for-release') == false -# run: make run_tests.lint PYTHON_ARGS="--shard other --verbose" -# - 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: "Lint checks failed on the upstream develop branch." -# webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} -# frontend_lint: -# name: Custom ESLint checks -# 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 Python -# uses: ./.github/actions/merge-develop-and-setup-python -# with: -# use_cache: false -# - name: Initialize Docker containers -# if: startsWith(github.head_ref, 'update-changelog-for-release') == false -# uses: ./.github/actions/install-oppia-dependencies-docker -# - name: Run ESLint Tests -# if: startsWith(github.head_ref, 'update-changelog-for-release') == false -# run: make run_tests.custom_eslint -# - 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: "ESLint checks failed on the upstream develop branch." -# webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} -# frontend_formatter: -# name: Frontend formatting with prettier -# 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 Python -# uses: ./.github/actions/merge-develop-and-setup-python -# with: -# use_cache: false -# - name: Initialize Docker containers -# uses: ./.github/actions/install-oppia-dependencies-docker -# - name: Prettify code -# run: make run_tests.prettier -# - name: Explain how to fix the issue -# if: ${{ failure() }} -# run: echo "Read https://github.com/oppia/oppia/wiki/Formatters to understand how to fix this issue." -# - 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: "Prettier formatting failed on the upstream develop branch." -# webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} +jobs: + backend_lint: + name: Backend + 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 Python + uses: ./.github/actions/merge-develop-and-setup-python + with: + use_cache: false + - name: Initialize Docker containers + uses: ./.github/actions/install-oppia-dependencies-docker + - name: Third Party Size Check + if: startsWith(github.head_ref, 'update-changelog-for-release') == false + run: make run_tests.third_party_size_check + - name: Run Lint Checks + if: startsWith(github.head_ref, 'update-changelog-for-release') == false + run: make run_tests.lint PYTHON_ARGS="--shard other --verbose" + - 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: "Lint checks failed on the upstream develop branch." + webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} + frontend_lint: + name: Custom ESLint checks + 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 Python + uses: ./.github/actions/merge-develop-and-setup-python + with: + use_cache: false + - name: Initialize Docker containers + if: startsWith(github.head_ref, 'update-changelog-for-release') == false + uses: ./.github/actions/install-oppia-dependencies-docker + - name: Run ESLint Tests + if: startsWith(github.head_ref, 'update-changelog-for-release') == false + run: make run_tests.custom_eslint + - 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: "ESLint checks failed on the upstream develop branch." + webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} + frontend_formatter: + name: Frontend formatting with prettier + 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 Python + uses: ./.github/actions/merge-develop-and-setup-python + with: + use_cache: false + - name: Initialize Docker containers + uses: ./.github/actions/install-oppia-dependencies-docker + - name: Prettify code + run: make run_tests.prettier + - name: Explain how to fix the issue + if: ${{ failure() }} + run: echo "Read https://github.com/oppia/oppia/wiki/Formatters to understand how to fix this issue." + - 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: "Prettier formatting failed on the upstream develop branch." + webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} diff --git a/.github/workflows/all_type_checks.yml b/.github/workflows/all_type_checks.yml index 0aa95e5d1f65..ad2b680a106a 100644 --- a/.github/workflows/all_type_checks.yml +++ b/.github/workflows/all_type_checks.yml @@ -1,61 +1,61 @@ -# name: Type checks -# on: -# merge_group: -# types: [checks_requested] -# push: -# branches: -# - develop -# - release-* -# pull_request: -# branches: -# - develop -# - release-* +name: Type checks +on: + merge_group: + types: [checks_requested] + push: + branches: + - develop + - release-* + pull_request: + branches: + - develop + - release-* -# jobs: -# backend_type_checks: -# name: Backend -# 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 Python -# uses: ./.github/actions/merge-develop-and-setup-python -# with: -# use_cache: false -# - name: Initialize Docker containers -# run: | -# make build -# make stop -# - name: Run Mypy type checks -# if: startsWith(github.head_ref, 'update-changelog-for-release') == false -# run: make run_tests.mypy -# - 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: "Python type checks failed on the upstream develop branch." -# webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} -# frontend_type_checks: -# name: Frontend -# 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 Python -# uses: ./.github/actions/merge-develop-and-setup-python -# with: -# use_cache: false -# - name: Install Chrome -# uses: ./.github/actions/install-chrome -# - name: Initialize Containers -# uses: ./.github/actions/install-oppia-dependencies-docker -# - name: Run typescript tests -# run: make run_tests.typescript -# - name: Run typescript tests in strict mode -# run: make run_tests.typescript PYTHON_ARGS="--strict_checks" -# - 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: "A typescript test failed on the upstream develop branch." -# webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} +jobs: + backend_type_checks: + name: Backend + 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 Python + uses: ./.github/actions/merge-develop-and-setup-python + with: + use_cache: false + - name: Initialize Docker containers + run: | + make build + make stop + - name: Run Mypy type checks + if: startsWith(github.head_ref, 'update-changelog-for-release') == false + run: make run_tests.mypy + - 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: "Python type checks failed on the upstream develop branch." + webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} + frontend_type_checks: + name: Frontend + 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 Python + uses: ./.github/actions/merge-develop-and-setup-python + with: + use_cache: false + - name: Install Chrome + uses: ./.github/actions/install-chrome + - name: Initialize Containers + uses: ./.github/actions/install-oppia-dependencies-docker + - name: Run typescript tests + run: make run_tests.typescript + - name: Run typescript tests in strict mode + run: make run_tests.typescript PYTHON_ARGS="--strict_checks" + - 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: "A typescript test failed on the upstream develop branch." + webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} diff --git a/.github/workflows/backend_unit_tests.yml b/.github/workflows/backend_unit_tests.yml index 797bb08df1b9..1c8422ef3edf 100644 --- a/.github/workflows/backend_unit_tests.yml +++ b/.github/workflows/backend_unit_tests.yml @@ -1,191 +1,191 @@ -# name: Backend unit tests -# on: -# merge_group: -# types: [checks_requested] -# push: -# branches: -# - develop -# - release-* -# pull_request: -# branches: -# - develop -# - release-* +name: Backend unit tests +on: + merge_group: + types: [checks_requested] + push: + branches: + - develop + - release-* + pull_request: + branches: + - develop + - release-* -# jobs: -# run_backend_associated_test_file_checks: -# name: Verify associated test files -# 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 Python -# uses: ./.github/actions/merge-develop-and-setup-python -# with: -# use_cache: false -# - name: Run backend associated test file check -# run: make run_tests.check_backend_associated_tests -# - 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 }} -# runs-on: ubuntu-22.04 -# strategy: -# 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 Python -# uses: ./.github/actions/merge-develop-and-setup-python -# with: -# use_cache: false -# - name: Initialize Docker containers -# if: startsWith(github.head_ref, 'update-changelog-for-release') == false -# uses: ./.github/actions/install-oppia-dependencies-docker -# - name: Run backend test shard -# if: startsWith(github.head_ref, 'update-changelog-for-release') == false -# run: make run_tests.backend PYTHON_ARGS="--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: ${{ 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 -# 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 Python -# uses: ./.github/actions/merge-develop-and-setup-python -# with: -# use_cache: false -# - name: Install coverage -# if: startsWith(github.head_ref, 'update-changelog-for-release') == false -# run: pip install coverage -# - name: Initialize Containers -# if: startsWith(github.head_ref, 'update-changelog-for-release') == false -# run: | -# make build -# sudo make run-devserver -# make stop -# - 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 -# if: startsWith(github.head_ref, 'update-changelog-for-release') == false -# shell: bash -# run: make run_tests.check_overall_backend_test_coverage -# - 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: "Backend coverage checks failed on the upstream develop branch." -# webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} -# check_backend_test_times: -# name: Check test times -# needs: run_tests -# 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 Python -# uses: ./.github/actions/merge-develop-and-setup-python -# with: -# use_cache: false -# - 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 +jobs: + run_backend_associated_test_file_checks: + name: Verify associated test files + 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 Python + uses: ./.github/actions/merge-develop-and-setup-python + with: + use_cache: false + - name: Run backend associated test file check + run: make run_tests.check_backend_associated_tests + - 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 }} + runs-on: ubuntu-22.04 + strategy: + 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 Python + uses: ./.github/actions/merge-develop-and-setup-python + with: + use_cache: false + - name: Initialize Docker containers + if: startsWith(github.head_ref, 'update-changelog-for-release') == false + uses: ./.github/actions/install-oppia-dependencies-docker + - name: Run backend test shard + if: startsWith(github.head_ref, 'update-changelog-for-release') == false + run: make run_tests.backend PYTHON_ARGS="--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: ${{ 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 + 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 Python + uses: ./.github/actions/merge-develop-and-setup-python + with: + use_cache: false + - name: Install coverage + if: startsWith(github.head_ref, 'update-changelog-for-release') == false + run: pip install coverage + - name: Initialize Containers + if: startsWith(github.head_ref, 'update-changelog-for-release') == false + run: | + make build + sudo make run-devserver + make stop + - 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 + if: startsWith(github.head_ref, 'update-changelog-for-release') == false + shell: bash + run: make run_tests.check_overall_backend_test_coverage + - 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: "Backend coverage checks failed on the upstream develop branch." + webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} + check_backend_test_times: + name: Check test times + needs: run_tests + 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 Python + uses: ./.github/actions/merge-develop-and-setup-python + with: + use_cache: false + - 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 diff --git a/.github/workflows/frontend_unit_tests.yml b/.github/workflows/frontend_unit_tests.yml index 1227b1cf2e8f..d69ebe7a8c26 100644 --- a/.github/workflows/frontend_unit_tests.yml +++ b/.github/workflows/frontend_unit_tests.yml @@ -1,82 +1,82 @@ -# name: Frontend unit tests -# on: -# merge_group: -# types: [checks_requested] -# push: -# branches: -# - develop -# - release-* -# pull_request: -# branches: -# - develop -# - release-* +name: Frontend unit tests +on: + merge_group: + types: [checks_requested] + push: + branches: + - develop + - release-* + pull_request: + branches: + - develop + - release-* -# jobs: -# generate-job-strategy-matrix: -# name: Generate job strategy matrix -# runs-on: ubuntu-22.04 -# outputs: -# job-strategy-matrix: ${{ steps.generate.outputs.job-strategy-matrix }} -# steps: -# - name: Generate job strategy matrix -# id: generate -# env: -# standard-test-runs: 2 -# flakes-test-runs: 10 -# run: | -# if ${{ github.event_name == 'push' && github.repository == 'oppia/oppia' && github.ref == 'refs/heads/develop'}} -# then -# JOB_STRATEGY_MATRIX=$(node -e "let r=[]; for(let i = 1; i <= ${{ env.flakes-test-runs }}; i++) { r.push(i) }; console.log(JSON.stringify(r));") -# echo "job-strategy-matrix=$JOB_STRATEGY_MATRIX" >> $GITHUB_OUTPUT -# else -# JOB_STRATEGY_MATRIX=$(node -e "let r=[]; for(let i = 1; i <= ${{ env.standard-test-runs }}; i++) { r.push(i) }; console.log(JSON.stringify(r));") -# echo "job-strategy-matrix=$JOB_STRATEGY_MATRIX" >> $GITHUB_OUTPUT -# fi -# frontend-karma-tests: -# name: Run all tests -# needs: generate-job-strategy-matrix -# runs-on: ubuntu-22.04 -# strategy: -# max-parallel: 25 -# matrix: -# num_runs: ${{ fromJson(needs.generate-job-strategy-matrix.outputs.job-strategy-matrix) }} -# fail-fast: false -# steps: -# - name: Checkout repository so that local actions can be used -# uses: actions/checkout@v4 -# - name: Merge develop and set up Python -# uses: ./.github/actions/merge-develop-and-setup-python -# with: -# use_cache: false -# - name: Describe filesystem -# run: | -# pwd -# ls /home/runner/work -# ls /home/runner/work/oppia -# ls /home/runner/work/oppia/oppia -# echo $GITHUB_WORKSPACE -# - name: Suppress ENOSPC error from chokidar file watcher. See https://stackoverflow.com/a/32600959. -# run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p -# - name: Initialize Docker containers -# uses: ./.github/actions/install-oppia-dependencies-docker -# - name: Run frontend tests (attempt ${{ matrix.num_runs }}) -# run: make run_tests.frontend PYTHON_ARGS="--check_coverage" -# - name: Upload fronted coverage reports as an artifact -# if: ${{ failure() }} -# uses: actions/upload-artifact@v4 -# with: -# name: frontend-coverage-${{ matrix.num_runs }} -# path: /home/runner/work/oppia/karma_coverage_reports -# report-failure: -# name: Report failure -# needs: frontend-karma-tests -# runs-on: ubuntu-22.04 -# if: ${{ failure() && github.event_name == 'push' && github.repository == 'oppia/oppia' && github.ref == 'refs/heads/develop'}} -# steps: -# - name: Checkout repository -# uses: actions/checkout@v3 -# - name: Report failure if failed on oppia/oppia develop branch -# uses: ./.github/actions/send-webhook-notification -# with: -# message: "A frontend test failed on the upstream develop branch." -# webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }} +jobs: + generate-job-strategy-matrix: + name: Generate job strategy matrix + runs-on: ubuntu-22.04 + outputs: + job-strategy-matrix: ${{ steps.generate.outputs.job-strategy-matrix }} + steps: + - name: Generate job strategy matrix + id: generate + env: + standard-test-runs: 2 + flakes-test-runs: 10 + run: | + if ${{ github.event_name == 'push' && github.repository == 'oppia/oppia' && github.ref == 'refs/heads/develop'}} + then + JOB_STRATEGY_MATRIX=$(node -e "let r=[]; for(let i = 1; i <= ${{ env.flakes-test-runs }}; i++) { r.push(i) }; console.log(JSON.stringify(r));") + echo "job-strategy-matrix=$JOB_STRATEGY_MATRIX" >> $GITHUB_OUTPUT + else + JOB_STRATEGY_MATRIX=$(node -e "let r=[]; for(let i = 1; i <= ${{ env.standard-test-runs }}; i++) { r.push(i) }; console.log(JSON.stringify(r));") + echo "job-strategy-matrix=$JOB_STRATEGY_MATRIX" >> $GITHUB_OUTPUT + fi + frontend-karma-tests: + name: Run all tests + needs: generate-job-strategy-matrix + runs-on: ubuntu-22.04 + strategy: + max-parallel: 25 + matrix: + num_runs: ${{ fromJson(needs.generate-job-strategy-matrix.outputs.job-strategy-matrix) }} + fail-fast: false + steps: + - name: Checkout repository so that local actions can be used + uses: actions/checkout@v4 + - name: Merge develop and set up Python + uses: ./.github/actions/merge-develop-and-setup-python + with: + use_cache: false + - name: Describe filesystem + run: | + pwd + ls /home/runner/work + ls /home/runner/work/oppia + ls /home/runner/work/oppia/oppia + echo $GITHUB_WORKSPACE + - name: Suppress ENOSPC error from chokidar file watcher. See https://stackoverflow.com/a/32600959. + run: echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p + - name: Initialize Docker containers + uses: ./.github/actions/install-oppia-dependencies-docker + - name: Run frontend tests (attempt ${{ matrix.num_runs }}) + run: make run_tests.frontend PYTHON_ARGS="--check_coverage" + - name: Upload fronted coverage reports as an artifact + if: ${{ failure() }} + uses: actions/upload-artifact@v4 + with: + name: frontend-coverage-${{ matrix.num_runs }} + path: /home/runner/work/oppia/karma_coverage_reports + report-failure: + name: Report failure + needs: frontend-karma-tests + runs-on: ubuntu-22.04 + if: ${{ failure() && github.event_name == 'push' && github.repository == 'oppia/oppia' && github.ref == 'refs/heads/develop'}} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Report failure if failed on oppia/oppia develop branch + uses: ./.github/actions/send-webhook-notification + with: + message: "A frontend test failed on the upstream develop branch." + webhook-url: ${{ secrets.BUILD_FAILURE_ROOM_WEBHOOK_URL }}