From d30cdc2f71d879a9498ce4087a2c582181f22335 Mon Sep 17 00:00:00 2001 From: oferqm <138665730+oferqm@users.noreply.github.com> Date: Thu, 15 Feb 2024 15:42:14 +0200 Subject: [PATCH] . --- .github/workflows/quam_test.yaml | 33 +++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/.github/workflows/quam_test.yaml b/.github/workflows/quam_test.yaml index d80ac3ad..4f0af40b 100644 --- a/.github/workflows/quam_test.yaml +++ b/.github/workflows/quam_test.yaml @@ -25,4 +25,35 @@ jobs: - name: Test with pytest run: | pip install pytest - pytest \ No newline at end of file + pytest + + - name: Run pytest and generate a report + run: pytest --junitxml=pytest-report.xml + + - name: Upload pytest report as an artifact + uses: actions/upload-artifact@v2 + with: + name: pytest-report-${{ matrix.python-version }} + path: pytest-report.xml + + - name: Add test report summary to run summary + if: success() || failure() # This makes it run regardless of the job outcome + uses: actions/github-script@v5 + with: + script: | + const reportPath = '${{ github.workspace }}/pytest-report.xml'; + const report = require('fs').readFileSync(reportPath, 'utf-8'); + // Parse the XML report or extract relevant information here + // This example assumes you have a way to extract a summary from your report + // For simplicity, we're just adding a placeholder message + const summary = `### Test Report Summary\n\n- Total Tests: X\n- Passed: Y\n- Failed: Z\n\nSee [pytest-report-${{ matrix.python-version }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts) for more details.`; + console.log(summary); + github.rest.actions.createWorkflowRunSummary({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.runId, + text: summary, + headers: { + 'Content-Type': 'text/markdown', + }, + }); \ No newline at end of file