From ae0e579747860d2d2c4e5de9400408ed0d3f588c Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Fri, 17 May 2024 12:14:40 +0100 Subject: [PATCH] Improve/fix the condition of when the reports jobs run --- .github/workflows/test-action-linux.yml | 5 +++- .github/workflows/test-action-macos.yml | 5 +++- .github/workflows/test-action-windows.yml | 5 +++- .../workflows/test-packages-action-linux.yml | 4 ++- .../workflows/test-packages-action-macos.yml | 4 ++- .../test-packages-action-windows.yml | 4 ++- tools/ci.py | 28 ++++++++++++++++--- 7 files changed, 45 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test-action-linux.yml b/.github/workflows/test-action-linux.yml index e9ecb5d349f..0f1f8fd3272 100644 --- a/.github/workflows/test-action-linux.yml +++ b/.github/workflows/test-action-linux.yml @@ -305,7 +305,7 @@ jobs: report: name: Test Reports - if: always() && fromJSON(needs.generate-matrix.outputs.build-reports) && inputs.skip-code-coverage == false && needs.test.result != 'cancelled' && needs.test.result != 'skipped' + if: always() && fromJSON(needs.generate-matrix.outputs.build-reports) && needs.test.result != 'cancelled' && needs.test.result != 'skipped' runs-on: ubuntu-latest needs: - test @@ -322,6 +322,7 @@ jobs: - name: Merge JUnit XML Test Run Artifacts uses: actions/upload-artifact/merge@v4 + if: always() && needs.test.result != 'cancelled' && needs.test.result != 'skipped' with: name: testrun-junit-artifacts-${{ inputs.distro-slug }}${{ inputs.fips && '-fips' || '' }}-${{ inputs.nox-session }} pattern: testrun-junit-artifacts-${{ inputs.distro-slug }}${{ inputs.fips && '-fips' || '' }}-${{ inputs.nox-session }}-* @@ -330,6 +331,7 @@ jobs: - name: Merge Log Test Run Artifacts uses: actions/upload-artifact/merge@v4 + if: always() && needs.test.result != 'cancelled' && needs.test.result != 'skipped' with: name: testrun-log-artifacts-${{ inputs.distro-slug }}${{ inputs.fips && '-fips' || '' }}-${{ inputs.nox-session }} pattern: testrun-log-artifacts-${{ inputs.distro-slug }}${{ inputs.fips && '-fips' || '' }}-${{ inputs.nox-session }}-* @@ -355,6 +357,7 @@ jobs: path: artifacts/coverage/ - name: Show Downloaded Test Run Artifacts + if: ${{ inputs.skip-code-coverage == false }} run: | tree -a artifacts diff --git a/.github/workflows/test-action-macos.yml b/.github/workflows/test-action-macos.yml index bbd8b387d68..eff2d7baa65 100644 --- a/.github/workflows/test-action-macos.yml +++ b/.github/workflows/test-action-macos.yml @@ -333,7 +333,7 @@ jobs: report: name: Test Reports - if: always() && fromJSON(needs.generate-matrix.outputs.build-reports) && inputs.skip-code-coverage == false && needs.test.result != 'cancelled' && needs.test.result != 'skipped' + if: always() && fromJSON(needs.generate-matrix.outputs.build-reports) && needs.test.result != 'cancelled' && needs.test.result != 'skipped' runs-on: ubuntu-latest needs: - test @@ -350,6 +350,7 @@ jobs: - name: Merge JUnit XML Test Run Artifacts uses: actions/upload-artifact/merge@v4 + if: always() && needs.test.result != 'cancelled' && needs.test.result != 'skipped' with: name: testrun-junit-artifacts-${{ inputs.distro-slug }}-${{ inputs.nox-session }} pattern: testrun-junit-artifacts-${{ inputs.distro-slug }}-${{ inputs.nox-session }}-* @@ -358,6 +359,7 @@ jobs: - name: Merge Log Test Run Artifacts uses: actions/upload-artifact/merge@v4 + if: always() && needs.test.result != 'cancelled' && needs.test.result != 'skipped' with: name: testrun-log-artifacts-${{ inputs.distro-slug }}-${{ inputs.nox-session }} pattern: testrun-log-artifacts-${{ inputs.distro-slug }}-${{ inputs.nox-session }}-* @@ -383,6 +385,7 @@ jobs: path: artifacts/coverage/ - name: Show Downloaded Test Run Artifacts + if: ${{ inputs.skip-code-coverage == false }} run: | tree -a artifacts diff --git a/.github/workflows/test-action-windows.yml b/.github/workflows/test-action-windows.yml index cdb284d8c02..0bf51fe36f1 100644 --- a/.github/workflows/test-action-windows.yml +++ b/.github/workflows/test-action-windows.yml @@ -306,7 +306,7 @@ jobs: report: name: Test Reports - if: always() && fromJSON(needs.generate-matrix.outputs.build-reports) && inputs.skip-code-coverage == false && needs.test.result != 'cancelled' && needs.test.result != 'skipped' + if: always() && fromJSON(needs.generate-matrix.outputs.build-reports) && needs.test.result != 'cancelled' && needs.test.result != 'skipped' runs-on: ubuntu-latest needs: - test @@ -323,6 +323,7 @@ jobs: - name: Merge JUnit XML Test Run Artifacts uses: actions/upload-artifact/merge@v4 + if: always() && needs.test.result != 'cancelled' && needs.test.result != 'skipped' with: name: testrun-junit-artifacts-${{ inputs.distro-slug }}-${{ inputs.nox-session }} pattern: testrun-junit-artifacts-${{ inputs.distro-slug }}-${{ inputs.nox-session }}-* @@ -331,6 +332,7 @@ jobs: - name: Merge Log Test Run Artifacts uses: actions/upload-artifact/merge@v4 + if: always() && needs.test.result != 'cancelled' && needs.test.result != 'skipped' with: name: testrun-log-artifacts-${{ inputs.distro-slug }}-${{ inputs.nox-session }} pattern: testrun-log-artifacts-${{ inputs.distro-slug }}-${{ inputs.nox-session }}-* @@ -356,6 +358,7 @@ jobs: path: artifacts/coverage/ - name: Show Downloaded Test Run Artifacts + if: ${{ inputs.skip-code-coverage == false }} run: | tree -a artifacts diff --git a/.github/workflows/test-packages-action-linux.yml b/.github/workflows/test-packages-action-linux.yml index adb2ad8635c..06bcc43c9a3 100644 --- a/.github/workflows/test-packages-action-linux.yml +++ b/.github/workflows/test-packages-action-linux.yml @@ -83,6 +83,7 @@ jobs: - x86_64 outputs: pkg-matrix-include: ${{ steps.generate-pkg-matrix.outputs.matrix }} + build-reports: ${{ steps.generate-pkg-matrix.outputs.build-reports }} steps: - name: "Throttle Builds" @@ -236,8 +237,9 @@ jobs: report: name: Report runs-on: ubuntu-latest - if: always() && inputs.skip-code-coverage == false && needs.test.result != 'cancelled' && needs.test.result != 'skipped' + if: always() && fromJSON(needs.generate-matrix.outputs.build-reports) && needs.test.result != 'cancelled' && needs.test.result != 'skipped' needs: + - generate-matrix - test steps: diff --git a/.github/workflows/test-packages-action-macos.yml b/.github/workflows/test-packages-action-macos.yml index 352f059d997..f98a58de2ea 100644 --- a/.github/workflows/test-packages-action-macos.yml +++ b/.github/workflows/test-packages-action-macos.yml @@ -79,6 +79,7 @@ jobs: - x86_64 outputs: pkg-matrix-include: ${{ steps.generate-pkg-matrix.outputs.matrix }} + build-reports: ${{ steps.generate-pkg-matrix.outputs.build-reports }} steps: - name: "Throttle Builds" @@ -219,8 +220,9 @@ jobs: report: name: Report runs-on: ubuntu-latest - if: always() && inputs.skip-code-coverage == false && needs.test.result != 'cancelled' && needs.test.result != 'skipped' + if: always() && fromJSON(needs.generate-matrix.outputs.build-reports) && needs.test.result != 'cancelled' && needs.test.result != 'skipped' needs: + - generate-matrix - test steps: diff --git a/.github/workflows/test-packages-action-windows.yml b/.github/workflows/test-packages-action-windows.yml index ef1505bc5bd..d16a01707e3 100644 --- a/.github/workflows/test-packages-action-windows.yml +++ b/.github/workflows/test-packages-action-windows.yml @@ -82,6 +82,7 @@ jobs: - x86_64 outputs: pkg-matrix-include: ${{ steps.generate-pkg-matrix.outputs.matrix }} + build-reports: ${{ steps.generate-pkg-matrix.outputs.build-reports }} steps: - name: "Throttle Builds" @@ -235,8 +236,9 @@ jobs: report: name: Report runs-on: ubuntu-latest - if: always() && inputs.skip-code-coverage == false && needs.test.result != 'cancelled' && needs.test.result != 'skipped' + if: always() && fromJSON(needs.generate-matrix.outputs.build-reports) && needs.test.result != 'cancelled' && needs.test.result != 'skipped' needs: + - generate-matrix - test steps: diff --git a/tools/ci.py b/tools/ci.py index 8a09af5bc05..635462d282f 100644 --- a/tools/ci.py +++ b/tools/ci.py @@ -713,7 +713,11 @@ def matrix( _matrix.append({"transport": transport, "tests-chunk": chunk}) ctx.info("Generated matrix:") - ctx.print(_matrix, soft_wrap=True) + if not _matrix: + ctx.print(" * `None`") + else: + for entry in _matrix: + ctx.print(" * ", entry, soft_wrap=True) if ( gh_event["repository"]["fork"] is True @@ -723,11 +727,17 @@ def matrix( ctx.warn("Forks don't have access to MacOS 13 Arm64. Clearning the matrix.") _matrix.clear() + if not _matrix: + build_reports = False + ctx.info("Not building reports because the matrix is empty") + else: + build_reports = True + github_output = os.environ.get("GITHUB_OUTPUT") if github_output is not None: with open(github_output, "a", encoding="utf-8") as wfh: wfh.write(f"matrix={json.dumps(_matrix)}\n") - wfh.write(f"build-reports={json.dumps(len(_matrix) > 0)}\n") + wfh.write(f"build-reports={json.dumps(build_reports)}\n") ctx.exit(0) @@ -899,7 +909,11 @@ def pkg_matrix( ctx.info(f"No {version} ({backend}) for {distro_slug} at {prefix}") ctx.info("Generated matrix:") - ctx.print(_matrix, soft_wrap=True) + if not _matrix: + ctx.print(" * `None`") + else: + for entry in _matrix: + ctx.print(" * ", entry, soft_wrap=True) if ( gh_event is not None @@ -910,10 +924,16 @@ def pkg_matrix( ctx.warn("Forks don't have access to MacOS 13 Arm64. Clearning the matrix.") _matrix.clear() + if not _matrix: + build_reports = False + ctx.info("Not building reports because the matrix is empty") + else: + build_reports = True + if github_output is not None: with open(github_output, "a", encoding="utf-8") as wfh: wfh.write(f"matrix={json.dumps(_matrix)}\n") - wfh.write(f"build-reports={json.dumps(len(_matrix) > 0)}\n") + wfh.write(f"build-reports={json.dumps(build_reports)}\n") ctx.exit(0)