From 86aba978bd181d2f7b9793a92663a51314f452c6 Mon Sep 17 00:00:00 2001 From: Ephraim Anierobi Date: Fri, 2 Feb 2024 22:03:06 +0100 Subject: [PATCH 1/5] Integrate the run coverage command to the CI This is an attempt to prevent a file with full test coverage from slipping below 100% coverage. Use multiprocessing for coverage Remove non-db test files from covered when running db tests Remove files that have full coverage from not fully covered files Add color to error message Update hashes Add back run-coverage for hatch regenerate images Move the reporting out of analyzing and make this non-fatal Report coverage before analysing Fix static checks --- .github/actions/post_tests_success/action.yml | 4 +- .github/workflows/ci.yml | 22 +- .../doc/images/output_ci-image_build.txt | 1 + dev/breeze/doc/images/output_k8s_logs.txt | 1 + .../doc/images/output_testing_db-tests.svg | 110 +++--- .../doc/images/output_testing_db-tests.txt | 2 +- .../output_testing_integration-tests.svg | 72 ++-- .../output_testing_integration-tests.txt | 2 +- .../images/output_testing_non-db-tests.svg | 98 +++-- .../images/output_testing_non-db-tests.txt | 2 +- .../doc/images/output_testing_tests.svg | 130 ++++--- .../doc/images/output_testing_tests.txt | 2 +- .../airflow_breeze/commands/ci_commands.py | 4 +- .../commands/testing_commands.py | 16 - .../commands/testing_commands_config.py | 4 - .../src/airflow_breeze/params/shell_params.py | 1 - .../src/airflow_breeze/utils/run_tests.py | 19 +- dev/breeze/tests/test_pr_info.py | 16 +- scripts/ci/docker-compose/local.yml | 3 - scripts/in_container/run_ci_tests.py | 356 ++++++++++++++++++ scripts/in_container/run_ci_tests.sh | 4 +- 21 files changed, 588 insertions(+), 281 deletions(-) create mode 100644 scripts/in_container/run_ci_tests.py diff --git a/.github/actions/post_tests_success/action.yml b/.github/actions/post_tests_success/action.yml index 214f731989ffd..a3a681acab5c0 100644 --- a/.github/actions/post_tests_success/action.yml +++ b/.github/actions/post_tests_success/action.yml @@ -28,14 +28,14 @@ runs: path: ./files/warnings-*.txt retention-days: 7 - name: "Move coverage artifacts in separate directory" - if: env.ENABLE_COVERAGE == 'true' && env.TEST_TYPES != 'Helm' + if: env.TEST_TYPES != 'Helm' shell: bash run: | mkdir ./files/coverage-reposts mv ./files/coverage*.xml ./files/coverage-reposts/ || true - name: "Upload all coverage reports to codecov" uses: codecov/codecov-action@v3 - if: env.ENABLE_COVERAGE == 'true' && env.TEST_TYPES != 'Helm' + if: env.UPLOAD_COVERAGE == 'true' && env.TEST_TYPES != 'Helm' with: name: coverage-${{env.JOB_ID}} flags: python-${{env.PYTHON_MAJOR_MINOR_VERSION}},${{env.BACKEND}}-${{env.BACKEND_VERSION}} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1cb19201ddb05..75d33f5a0d2ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -135,7 +135,7 @@ jobs: in-workflow-build: ${{ steps.source-run-info.outputs.in-workflow-build }} build-job-description: ${{ steps.source-run-info.outputs.build-job-description }} canary-run: ${{ steps.source-run-info.outputs.canary-run }} - run-coverage: ${{ steps.source-run-info.outputs.run-coverage }} + upload-coverage: ${{ steps.source-run-info.outputs.upload-coverage }} steps: - name: Cleanup repo run: docker run -v "${GITHUB_WORKSPACE}:/workspace" -u 0:0 bash -c "rm -rf /workspace/*" @@ -1174,7 +1174,7 @@ jobs: POSTGRES_VERSION: "${{matrix.postgres-version}}" BACKEND_VERSION: "${{matrix.postgres-version}}" JOB_ID: "postgres-${{matrix.postgres-version}}-${{matrix.python-version}}" - ENABLE_COVERAGE: "${{needs.build-info.outputs.run-coverage}}" + UPLOAD_COVERAGE: "${{needs.build-info.outputs.upload-coverage}}" if: needs.build-info.outputs.run-tests == 'true' steps: - name: Cleanup repo @@ -1271,7 +1271,7 @@ jobs: FULL_TESTS_NEEDED: "${{needs.build-info.outputs.full-tests-needed}}" DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}" BACKEND: "postgres" - ENABLE_COVERAGE: "${{needs.build-info.outputs.run-coverage}}" + UPLOAD_COVERAGE: "${{needs.build-info.outputs.upload-coverage}}" PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}" PYTHON_VERSION: "${needs.build-info.outputs.default-python-version}}" POSTGRES_VERSION: "${{needs.build-info.outputs.default-postgres-version}}" @@ -1323,7 +1323,7 @@ jobs: FULL_TESTS_NEEDED: "${{needs.build-info.outputs.full-tests-needed}}" DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}" BACKEND: "postgres" - ENABLE_COVERAGE: "${{needs.build-info.outputs.run-coverage}}" + UPLOAD_COVERAGE: "${{needs.build-info.outputs.upload-coverage}}" PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}" PYTHON_VERSION: "${needs.build-info.outputs.default-python-version}}" POSTGRES_VERSION: "${{needs.build-info.outputs.default-postgres-version}}" @@ -1372,7 +1372,7 @@ jobs: FULL_TESTS_NEEDED: "${{needs.build-info.outputs.full-tests-needed}}" DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}" BACKEND: "postgres" - ENABLE_COVERAGE: "${{needs.build-info.outputs.run-coverage}}" + UPLOAD_COVERAGE: "${{needs.build-info.outputs.upload-coverage}}" PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}" PYTHON_VERSION: "${needs.build-info.outputs.default-python-version}}" POSTGRES_VERSION: "${{needs.build-info.outputs.default-postgres-version}}" @@ -1421,7 +1421,7 @@ jobs: FULL_TESTS_NEEDED: "${{needs.build-info.outputs.full-tests-needed}}" DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}" BACKEND: "postgres" - ENABLE_COVERAGE: "${{needs.build-info.outputs.run-coverage}}" + UPLOAD_COVERAGE: "${{needs.build-info.outputs.upload-coverage}}" PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}" PYTHON_VERSION: "${needs.build-info.outputs.default-python-version}}" POSTGRES_VERSION: "${{needs.build-info.outputs.default-postgres-version}}" @@ -1476,7 +1476,7 @@ jobs: PARALLEL_TEST_TYPES: "${{needs.build-info.outputs.parallel-test-types-list-as-string}}" DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}" BACKEND: "mysql" - ENABLE_COVERAGE: "${{needs.build-info.outputs.run-coverage}}" + UPLOAD_COVERAGE: "${{needs.build-info.outputs.upload-coverage}}" PYTHON_MAJOR_MINOR_VERSION: "${{matrix.python-version}}" MYSQL_VERSION: "${{matrix.mysql-version}}" BACKEND_VERSION: "${{matrix.mysql-version}}" @@ -1531,7 +1531,7 @@ jobs: FULL_TESTS_NEEDED: "${{needs.build-info.outputs.full-tests-needed}}" DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}" BACKEND: "sqlite" - ENABLE_COVERAGE: "${{needs.build-info.outputs.run-coverage}}" + UPLOAD_COVERAGE: "${{needs.build-info.outputs.upload-coverage}}" BACKEND_VERSION: "" JOB_ID: "sqlite-${{matrix.python-version}}" steps: @@ -1574,7 +1574,7 @@ jobs: FULL_TESTS_NEEDED: "${{needs.build-info.outputs.full-tests-needed}}" DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}" BACKEND: "postgres" - ENABLE_COVERAGE: "${{needs.build-info.outputs.run-coverage}}" + UPLOAD_COVERAGE: "${{needs.build-info.outputs.upload-coverage}}" PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}" POSTGRES_VERSION: "${{needs.build-info.outputs.default-postgres-version}}" BACKEND_VERSION: "${{needs.build-info.outputs.default-postgres-version}}" @@ -1649,7 +1649,7 @@ jobs: FULL_TESTS_NEEDED: "${{needs.build-info.outputs.full-tests-needed}}" DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}" BACKEND: "mysql" - ENABLE_COVERAGE: "${{needs.build-info.outputs.run-coverage}}" + UPLOAD_COVERAGE: "${{needs.build-info.outputs.upload-coverage}}" PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}" MYSQL_VERSION: "${{needs.build-info.outputs.default-mysql-version}}" BACKEND_VERSION: "${{needs.build-info.outputs.default-mysql-version}}" @@ -1695,7 +1695,7 @@ jobs: PYTHON_MAJOR_MINOR_VERSION: "${{needs.build-info.outputs.default-python-version}}" DEBUG_RESOURCES: "${{needs.build-info.outputs.debug-resources}}" JOB_ID: "quarantined-${{needs.build-info.outputs.default-python-version}}" - ENABLE_COVERAGE: "${{needs.build-info.outputs.run-coverage}}" + UPLOAD_COVERAGE: "${{needs.build-info.outputs.upload-coverage}}" if: needs.build-info.outputs.run-tests == 'true' && needs.build-info.outputs.is-airflow-runner == 'true' steps: - name: Cleanup repo diff --git a/dev/breeze/doc/images/output_ci-image_build.txt b/dev/breeze/doc/images/output_ci-image_build.txt index b59fb9fc0b24d..4ba67b42b6446 100644 --- a/dev/breeze/doc/images/output_ci-image_build.txt +++ b/dev/breeze/doc/images/output_ci-image_build.txt @@ -1 +1,2 @@ f535999147ac00393852eb3b28d7125b + diff --git a/dev/breeze/doc/images/output_k8s_logs.txt b/dev/breeze/doc/images/output_k8s_logs.txt index be09a24b39f67..ad7d5b4e18f65 100644 --- a/dev/breeze/doc/images/output_k8s_logs.txt +++ b/dev/breeze/doc/images/output_k8s_logs.txt @@ -1 +1,2 @@ 7bf7460f5e8dadcb2a97271908735572 + diff --git a/dev/breeze/doc/images/output_testing_db-tests.svg b/dev/breeze/doc/images/output_testing_db-tests.svg index cdbfe5918d599..7c0013f91412d 100644 --- a/dev/breeze/doc/images/output_testing_db-tests.svg +++ b/dev/breeze/doc/images/output_testing_db-tests.svg @@ -1,4 +1,4 @@ - +