Skip to content

Commit

Permalink
Fix integration with codecov (apache#29145)
Browse files Browse the repository at this point in the history
  • Loading branch information
Taragolis authored Jan 27, 2023
1 parent 4402456 commit 30ad26e
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 68 deletions.
27 changes: 19 additions & 8 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,25 @@
# specific language governing permissions and limitations
# under the License.

[report]
[run]
branch = True
relative_files = True
source = airflow
omit =
tests/*
scripts/*
dev/*
airflow/migrations/*
airflow/www/node_modules/**
airflow/_vendor/**
airflow/contrib/**
airflow/example_dags/**
airflow/migrations/**
airflow/providers/**/example_dags/**
airflow/www/node_modules/**

[run]
relative_files = True
[report]
skip_empty = True
exclude_lines =
pragma: no cover
@abstractmethod
@abstractproperty
def __repr__
raise NotImplementedError
if __name__ == .__main__.:
if TYPE_CHECKING:
1 change: 0 additions & 1 deletion .github/actions/codecov-action
Submodule codecov-action deleted from 1fc772
20 changes: 13 additions & 7 deletions .github/actions/post_tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,25 @@ runs:
name: container-logs-${{env.JOB_ID}}
path: "./files/container_logs*"
retention-days: 7
- name: "Upload artifact for coverage"
uses: actions/upload-artifact@v3
if: env.COVERAGE == 'true'
with:
name: coverage-${{env.JOB_ID}}
path: ./files/coverage*.xml
retention-days: 7
- name: "Upload artifact for warnings"
uses: actions/upload-artifact@v3
with:
name: test-warnings-${{env.JOB_ID}}
path: ./files/warnings-*.txt
retention-days: 7
- name: "Move coverage artifacts in separate directory"
if: env.COVERAGE == 'true' && 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.COVERAGE == 'true' && env.TEST_TYPES != 'Helm'
with:
name: coverage-${{env.JOB_ID}}
flags: python-${{env.PYTHON_MAJOR_MINOR_VERSION}},${{env.BACKEND}}-${{env.BACKEND_VERSION}}
directory: "./files/coverage-reposts/"
- name: "Fix ownership"
shell: bash
run: breeze ci fix-ownership
Expand Down
37 changes: 0 additions & 37 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1138,43 +1138,6 @@ jobs:
Post Tests: ${{needs.build-info.outputs.default-python-version}}:Quarantined"
uses: ./.github/actions/post_tests
upload-coverage:
timeout-minutes: 15
name: "Upload coverage"
runs-on: "${{needs.build-info.outputs.runs-on}}"
continue-on-error: true
needs:
- build-info
- tests-postgres
- tests-sqlite
- tests-mysql
- tests-mssql
- tests-quarantined
- tests-integration-postgres
- tests-integration-mysql
env:
RUNS_ON: "${{needs.build-info.outputs.runs-on}}"
# Only upload coverage on merges to main
if: needs.build-info.outputs.run-coverage == 'true'
steps:
- name: Cleanup repo
run: docker run -v "${GITHUB_WORKSPACE}:/workspace" -u 0:0 bash -c "rm -rf /workspace/*"
- name: "Checkout ${{ github.ref }} ( ${{ github.sha }} )"
uses: actions/checkout@v3
with:
persist-credentials: false
submodules: recursive
- name: "Download all artifacts from the current build"
uses: actions/download-artifact@v3
with:
path: ./coverage-files
- name: "Removes unnecessary artifacts"
run: ls ./coverage-files | grep -v coverage | xargs rm -rfv
- name: "Upload all coverage reports to codecov"
uses: ./.github/actions/codecov-action
with:
directory: "./coverage-files"

summarize-warnings:
timeout-minutes: 15
name: "Summarize warnings"
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
[submodule ".github/actions/configure-aws-credentials"]
path = .github/actions/configure-aws-credentials
url = https://github.com/aws-actions/configure-aws-credentials
[submodule ".github/actions/codecov-action"]
path = .github/actions/codecov-action
url = https://github.com/codecov/codecov-action
[submodule ".github/actions/github-push-action"]
path = .github/actions/github-push-action
url = https://github.com/ad-m/github-push-action
5 changes: 3 additions & 2 deletions Dockerfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -866,9 +866,10 @@ EXTRA_PYTEST_ARGS=(
if [[ "${TEST_TYPE}" == "Helm" ]]; then
_cpus="$(grep -c 'cpu[0-9]' /proc/stat)"
echo "Running tests with ${_cpus} CPUs in parallel"
# Enable parallelism
# Enable parallelism and disable coverage
EXTRA_PYTEST_ARGS+=(
"-n" "${_cpus}"
"--no-cov"
)
else
EXTRA_PYTEST_ARGS+=(
Expand All @@ -878,7 +879,7 @@ fi

if [[ ${ENABLE_TEST_COVERAGE:="false"} == "true" ]]; then
EXTRA_PYTEST_ARGS+=(
"--cov=airflow/"
"--cov=airflow"
"--cov-config=.coveragerc"
"--cov-report=xml:/files/coverage-${TEST_TYPE/\[*\]/}-${BACKEND}.xml"
)
Expand Down
15 changes: 8 additions & 7 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,13 @@ coverage:
only_pulls: false
paths:
- "airflow"
parsers:
gcov:
branch_detection:
conditional: true
loop: true
method: false
macro: false

ignore:
- "airflow/_vendor"
- "airflow/contrib"
- "airflow/example_dags"
- "airflow/migrations"
- "airflow/providers/**/example_dags"
- "airflow/www/node_modules"

comment: false
5 changes: 3 additions & 2 deletions scripts/docker/entrypoint_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,10 @@ EXTRA_PYTEST_ARGS=(
if [[ "${TEST_TYPE}" == "Helm" ]]; then
_cpus="$(grep -c 'cpu[0-9]' /proc/stat)"
echo "Running tests with ${_cpus} CPUs in parallel"
# Enable parallelism
# Enable parallelism and disable coverage
EXTRA_PYTEST_ARGS+=(
"-n" "${_cpus}"
"--no-cov"
)
else
EXTRA_PYTEST_ARGS+=(
Expand All @@ -328,7 +329,7 @@ fi

if [[ ${ENABLE_TEST_COVERAGE:="false"} == "true" ]]; then
EXTRA_PYTEST_ARGS+=(
"--cov=airflow/"
"--cov=airflow"
"--cov-config=.coveragerc"
"--cov-report=xml:/files/coverage-${TEST_TYPE/\[*\]/}-${BACKEND}.xml"
)
Expand Down
1 change: 0 additions & 1 deletion scripts/in_container/run_ci_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ fi
set +x
if [[ "${RES}" == "0" && ( ${CI:="false"} == "true" || ${CI} == "True" ) ]]; then
echo "All tests successful"
cp .coverage /files
fi

MAIN_GITHUB_REPOSITORY="apache/airflow"
Expand Down

0 comments on commit 30ad26e

Please sign in to comment.