diff --git a/.gitlab/source_test/linux.yml b/.gitlab/source_test/linux.yml index 0857a65459d5a..c6b3c47fc7d1f 100644 --- a/.gitlab/source_test/linux.yml +++ b/.gitlab/source_test/linux.yml @@ -35,7 +35,7 @@ - inv -e test $FLAVORS --include-sds --race --profile --rerun-fails=2 --python-runtimes "$PYTHON_RUNTIMES" --coverage --cpus $KUBERNETES_CPU_REQUEST $EXTRA_OPTS --save-result-json $TEST_OUTPUT_FILE --junit-tar "junit-${CI_JOB_NAME}.tgz" --build-stdlib $FAST_TESTS_FLAG --test-washer # Upload coverage files to Codecov. Never fail on coverage upload. - export CODECOV_TOKEN=$($CI_PROJECT_DIR/tools/ci/aws_ssm_get_wrapper.sh $CODECOV_TOKEN_SSM_NAME) - - inv -e codecov $COVERAGE_CACHE_FLAG --debug || true + - inv -e coverage.upload-to-codecov $COVERAGE_CACHE_FLAG || true - inv -e gitlab.generate-ci-visibility-links --output=$EXTERNAL_LINKS_PATH artifacts: expire_in: 2 weeks diff --git a/tasks/__init__.py b/tasks/__init__.py index 6f97fd78d7121..896ac6419ea12 100644 --- a/tasks/__init__.py +++ b/tasks/__init__.py @@ -11,6 +11,7 @@ cluster_agent, cluster_agent_cloudfoundry, components, + coverage, cws_instrumentation, devcontainer, diff, @@ -51,7 +52,6 @@ vscode, ) from tasks.build_tags import audit_tag_impact, print_default_build_tags -from tasks.codecov import apply_missing_coverage, codecov, upload_coverage_to_s3 from tasks.components import lint_components, lint_fxutil_oneshot_test from tasks.custom_task.custom_task import custom__call__ from tasks.fuzz import fuzz @@ -102,9 +102,6 @@ # add single tasks to the root ns.add_task(test) -ns.add_task(codecov) -ns.add_task(upload_coverage_to_s3) -ns.add_task(apply_missing_coverage) ns.add_task(integration_tests) ns.add_task(deps) ns.add_task(deps_vendored) @@ -150,6 +147,7 @@ ns.add_collection(cluster_agent) ns.add_collection(cluster_agent_cloudfoundry) ns.add_collection(components) +ns.add_collection(coverage) ns.add_collection(docs) ns.add_collection(bench) ns.add_collection(trace_agent) diff --git a/tasks/codecov.py b/tasks/coverage.py similarity index 99% rename from tasks/codecov.py rename to tasks/coverage.py index e83d412c6ea83..f0a0061aaf1ce 100644 --- a/tasks/codecov.py +++ b/tasks/coverage.py @@ -96,7 +96,7 @@ def __exit__(self, *_): @task -def codecov( +def upload_to_codecov( ctx: Context, pull_coverage_cache: bool = False, push_coverage_cache: bool = False, @@ -143,7 +143,6 @@ def _get_coverage_cache_uri(): return f"{os.environ[BUCKET_CI_VAR]}/coverage-cache" -@task def upload_coverage_to_s3(ctx: Context): """ Create an archive with all the coverage.out files from the inv test --coverage command. @@ -174,7 +173,6 @@ def upload_coverage_to_s3(ctx: Context): print(color_message(f'Successfully removed the local {COV_ARCHIVE_NAME}', Color.GREEN)) -@task def apply_missing_coverage(ctx: Context, from_commit_sha: str, debug: bool = False): """ Download the coverage cache archive from S3 for the given commit SHA diff --git a/tasks/gotest.py b/tasks/gotest.py index d9615905b5386..d739806ca5f32 100644 --- a/tasks/gotest.py +++ b/tasks/gotest.py @@ -25,7 +25,7 @@ from tasks.agent import integration_tests as agent_integration_tests from tasks.build_tags import compute_build_tags_for_flavor from tasks.cluster_agent import integration_tests as dca_integration_tests -from tasks.codecov import PROFILE_COV, CodecovWorkaround +from tasks.coverage import PROFILE_COV, CodecovWorkaround from tasks.devcontainer import run_on_devcontainer from tasks.dogstatsd import integration_tests as dsd_integration_tests from tasks.flavor import AgentFlavor diff --git a/tasks/winbuildscripts/unittests.ps1 b/tasks/winbuildscripts/unittests.ps1 index 5bff61143e512..467e83453b35d 100644 --- a/tasks/winbuildscripts/unittests.ps1 +++ b/tasks/winbuildscripts/unittests.ps1 @@ -65,7 +65,7 @@ if($err -ne 0){ # Upload coverage reports to Codecov $Env:CODECOV_TOKEN=$(& "$UT_BUILD_ROOT\tools\ci\aws_ssm_get_wrapper.ps1" $Env:CODECOV_TOKEN_SSM_NAME) -& inv -e codecov $Env:COVERAGE_CACHE_FLAG --debug +& inv -e coverage.upload-to-codecov $Env:COVERAGE_CACHE_FLAG $ErrorActionPreference = "Continue" # Ignore upload errors now, until we change the logic to ignore empty files in the upload script $Env:DATADOG_API_KEY=$(& "$UT_BUILD_ROOT\tools\ci\aws_ssm_get_wrapper.ps1" $Env:API_KEY_ORG2_SSM_NAME)