From 87b9aa4993bd97c1fc86a8ea27cfc039ada58fd8 Mon Sep 17 00:00:00 2001 From: Brett Rowan <121075405+b-rowan@users.noreply.github.com> Date: Fri, 23 Aug 2024 09:58:53 -0600 Subject: [PATCH] Add `pyest` github action. --- .github/workflows/pr-run-tests.yml | 34 ++++++++++++++++++++++++++++++ pyproject.toml | 1 + 2 files changed, 35 insertions(+) create mode 100644 .github/workflows/pr-run-tests.yml diff --git a/.github/workflows/pr-run-tests.yml b/.github/workflows/pr-run-tests.yml new file mode 100644 index 00000000..38e7f7c9 --- /dev/null +++ b/.github/workflows/pr-run-tests.yml @@ -0,0 +1,34 @@ +name: Test PRs + +on: + pull_request: +jobs: + run-tests: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + cache: pip + - name: Install poetry + uses: abatilo/actions-poetry@v2 + - name: Install dependencies + run: poetry install --with tests + - name: Run tests + env: + REPORT_OUTPUT: md_report.md + shell: bash + run: | + echo "REPORT_FILE=${REPORT_OUTPUT}" >> "$GITHUB_ENV" + poetry run pytest -v --md-report --md-report-flavor gfm --md-report-exclude-outcomes passed skipped xpassed --md-report-output "$REPORT_OUTPUT" + - name: Render the report to the PR when tests fail + uses: marocchino/sticky-pull-request-comment@v2 + if: failure() + with: + header: test-report + recreate: true + path: ${{ env.REPORT_FILE }} diff --git a/pyproject.toml b/pyproject.toml index f5bdf848..e502f913 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -44,6 +44,7 @@ mkdocs-material = "^9.5.29" [tool.poetry.group.tests.dependencies] pytest = "^8.3.1" pytest-asyncio = "^0.23.8" +pytest-md-report = "^0.6.2" [tool.isort] profile = "black"