thombashi / pytest-md-report

A pytest plugin to generate test outcomes reports with markdown table format.
MIT License
33 stars 5 forks source link

Github Actions Nice Report? #3

Closed randykleinman closed 1 year ago

randykleinman commented 1 year ago

No problems with the library, just a usage question. Do you have an example of how we could use this in Github Actions and render the markdown report nicely in a PR comment?

thombashi commented 1 year ago

@randykleinman For example, the following workflow will render the report to the PR when some test failed.

name: md-report

on:
  pull_request:

jobs:
  run-tests:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-python@v4
        with:
          python-version: '3.11'
          cache: pip

      - name: Install dependencies
        run: pip install --upgrade pytest-md-report

      - name: Run tests
        run: pytest tests --md-report --md-report-output md_report.md

      - name: Render report to the PR
        if: failure()
        env:
          GH_TOKEN: ${{ github.token }}
          PR_NUMBER: ${{ github.event.number }}
        run:
          gh pr comment $PR_NUMBER --body-file md_report.md 

Rendering output example:

image

randykleinman commented 1 year ago

Thank you! I will give that a try.

On Fri, Aug 11, 2023 at 3:46 AM Tsuyoshi Hombashi @.***> wrote:

@randykleinman https://github.com/randykleinman For example, the following workflow will render the report to the PR when some test failed.

name: md-report on: pull_request: jobs: run-tests: runs-on: ubuntu-latest

steps:
  - uses: ***@***.***

  - uses: ***@***.***
    with:
      python-version: '3.11'
      cache: pip

  - name: Install dependencies
    run: pip install --upgrade pytest-md-report

  - name: Run tests
    run: pytest tests --md-report --md-report-output md_report.md

  - name: Render report to the PR
    if: failure()
    env:
      GH_TOKEN: ${{ github.token }}
      PR_NUMBER: ${{ github.event.number }}
    run:
      gh pr comment $PR_NUMBER --body-file md_report.md

Rendering output example:

[image: image] https://user-images.githubusercontent.com/15517661/259961657-c4cfc893-eadb-4599-a55e-f717fa5753c9.png

— Reply to this email directly, view it on GitHub https://github.com/thombashi/pytest-md-report/issues/3#issuecomment-1674404124, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYPNZS4SZ44I4NBXT5KQIW3XUXWMZANCNFSM6AAAAAA3DLOMSI . You are receiving this because you were mentioned.Message ID: @.***>

thombashi commented 1 year ago

I added descriptions of how to do it in README.

dzid26 commented 2 months ago

I had all tests passing and the md_report.md was not getting created and I needed to debug why. - Finally was able to generate the nice report on actions summary.

From that experience, I think: