Add step to report code coverage from GHA (#63373)
authorNikita Shulga <nshulga@fb.com>
Tue, 17 Aug 2021 03:35:12 +0000 (20:35 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Tue, 17 Aug 2021 03:42:38 +0000 (20:42 -0700)
Summary:
Similar to the logic provided in https://github.com/pytorch/pytorch/blob/b2069e7d01814d776c417042e28133c6b0e5082f/.circleci/verbatim-sources/job-specs/pytorch-job-specs.yml#L197-L201

Fixes https://github.com/pytorch/pytorch/issues/63366

Pull Request resolved: https://github.com/pytorch/pytorch/pull/63373

Reviewed By: walterddr

Differential Revision: D30357737

Pulled By: malfet

fbshipit-source-id: 20b115eb4d6412bd9895680308a9097742d2ae7b

.github/scripts/generate_ci_workflows.py
.github/templates/linux_ci_workflow.yml.j2
.github/workflows/generated-linux-bionic-py3.8-gcc9-coverage.yml

index 6faa27c..0d6844b 100755 (executable)
@@ -123,6 +123,7 @@ class CIWorkflow:
     docker_image_base: str = ''
     enable_doc_jobs: bool = False
     exclude_test: bool = False
+    is_coverage: bool = False
     is_libtorch: bool = False
     is_scheduled: str = ''
     num_test_shards: int = 1
@@ -359,6 +360,7 @@ LINUX_WORKFLOWS = [
         docker_image_base=f"{DOCKER_REGISTRY}/pytorch/pytorch-linux-bionic-py3.8-gcc9",
         test_runner_type=LINUX_CPU_TEST_RUNNER,
         on_pull_request=True,
+        is_coverage=True,
         num_test_shards=2,
         ciflow_config=CIFlowConfig(
             enabled=True,
index b063318..ec39ef6 100644 (file)
@@ -395,6 +395,12 @@ jobs:
         run: |
           # Ensure the working directory gets chowned back to the current user
           docker run --rm -v "$(pwd)":/v -w /v "${ALPINE_IMAGE}" chown -R "$(id -u):$(id -g)" .
+      {%- if is_coverage %}
+      - name: Report coverage
+        run: |
+          python3 -mpip install codecov
+          python3 -mcodecov
+      {%- endif %}
       - name: Zip test reports for upload
         if: always()
         env:
index 953d489..3663c59 100644 (file)
@@ -363,6 +363,10 @@ jobs:
         run: |
           # Ensure the working directory gets chowned back to the current user
           docker run --rm -v "$(pwd)":/v -w /v "${ALPINE_IMAGE}" chown -R "$(id -u):$(id -g)" .
+      - name: Report coverage
+        run: |
+          python3 -mpip install codecov
+          python3 -mcodecov
       - name: Zip test reports for upload
         if: always()
         env: