Improve/fix the condition of when the reports jobs run

This commit is contained in:
Pedro Algarvio 2024-05-17 12:14:40 +01:00
parent 738b373b4b
commit ae0e579747
7 changed files with 45 additions and 10 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -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:

View file

@ -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:

View file

@ -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)