From 77bd72b7e02d86fa7112f6c94f7af0410ffd84b9 Mon Sep 17 00:00:00 2001 From: Mario Santa Cruz Date: Thu, 22 Feb 2024 15:48:31 +0000 Subject: [PATCH 1/9] change title --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f70d57..a08ec08 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# python-pytest-action +# Test repository for pytest GitHub action From f7c3f9b4acad887e5684263b4eab09b866c86f67 Mon Sep 17 00:00:00 2001 From: Mario Santa Cruz Date: Thu, 22 Feb 2024 15:50:08 +0000 Subject: [PATCH 2/9] Only run tests on PR to main --- .github/workflows/pytest_ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pytest_ci.yml b/.github/workflows/pytest_ci.yml index 7e34bd7..9f3abbd 100644 --- a/.github/workflows/pytest_ci.yml +++ b/.github/workflows/pytest_ci.yml @@ -1,8 +1,9 @@ name: Run pkg tests (pytest) on: - - push - - pull_request + pull_request: + branches: + - main jobs: build: From fae04232fda6eeaf3646383c89c998e4dfe1b440 Mon Sep 17 00:00:00 2001 From: Mario Santa Cruz Date: Thu, 22 Feb 2024 16:12:42 +0000 Subject: [PATCH 3/9] try report integration --- .github/workflows/pytest_ci.yml | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pytest_ci.yml b/.github/workflows/pytest_ci.yml index 9f3abbd..fc70f28 100644 --- a/.github/workflows/pytest_ci.yml +++ b/.github/workflows/pytest_ci.yml @@ -22,12 +22,23 @@ jobs: run: | python -m pip install --upgrade pip python -m pip install . - python -m pip install pytest + python -m pip install pytest pytest-md - name: Test with pytest - run: pytest --junitxml=junit/test-results-${{ matrix.python-version }}.xml - - name: Upload pytest test results - uses: actions/upload-artifact@v4 - with: - name: pytest-results-${{ matrix.python-version }} - path: junit/test-results-${{ matrix.python-version }}.xml - if: ${{ always() }} \ No newline at end of file + run: | + REPORT=${{ matrix.python-version }}.md + pytest --md $REPORT + - name: Add report to summary + if: always() + run: | + echo "::group::..." + FINAL_REPORT="$(mktemp)" + echo "# ${{ inputs.report-title }}" > "$FINAL_REPORT" + echo "
Click to expand!" >> "$FINAL_REPORT" + tail -n+2 "${{ steps.pytest.outputs.report-path }}" >> "$FINAL_REPORT" + echo "
" >> "$FINAL_REPORT" + cat "$FINAL_REPORT" >> "$GITHUB_STEP_SUMMARY" + echo "::endgroup::" + echo + echo "=====================================================================================" + echo Markdown summaries: "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" + echo "=====================================================================================" \ No newline at end of file From 240a48b19f21837d0527d4bf78a8523c9b7ee148 Mon Sep 17 00:00:00 2001 From: Mario Santa Cruz Date: Thu, 22 Feb 2024 16:16:47 +0000 Subject: [PATCH 4/9] Drop mktemp dependency --- .github/workflows/pytest_ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pytest_ci.yml b/.github/workflows/pytest_ci.yml index fc70f28..43736f1 100644 --- a/.github/workflows/pytest_ci.yml +++ b/.github/workflows/pytest_ci.yml @@ -25,13 +25,13 @@ jobs: python -m pip install pytest pytest-md - name: Test with pytest run: | - REPORT=${{ matrix.python-version }}.md + REPORT=pytest_${{ matrix.python-version }}.md pytest --md $REPORT - name: Add report to summary if: always() run: | echo "::group::..." - FINAL_REPORT="$(mktemp)" + FINAL_REPORT=pytest_report_${{ matrix.python-version }}.md echo "# ${{ inputs.report-title }}" > "$FINAL_REPORT" echo "
Click to expand!" >> "$FINAL_REPORT" tail -n+2 "${{ steps.pytest.outputs.report-path }}" >> "$FINAL_REPORT" From 81310489c88b5732a32a32079f36bb40aacda0eb Mon Sep 17 00:00:00 2001 From: Mario Santa Cruz Date: Fri, 23 Feb 2024 08:08:02 +0000 Subject: [PATCH 5/9] Add id to track outputs --- .github/workflows/pytest_ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pytest_ci.yml b/.github/workflows/pytest_ci.yml index 43736f1..844824e 100644 --- a/.github/workflows/pytest_ci.yml +++ b/.github/workflows/pytest_ci.yml @@ -24,6 +24,7 @@ jobs: python -m pip install . python -m pip install pytest pytest-md - name: Test with pytest + id: pytest run: | REPORT=pytest_${{ matrix.python-version }}.md pytest --md $REPORT From 4597659bea12cb00b016ec30f0affdd3e05eefbb Mon Sep 17 00:00:00 2001 From: Mario Santa Cruz Date: Fri, 23 Feb 2024 08:15:04 +0000 Subject: [PATCH 6/9] Fix title --- .github/workflows/pytest_ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pytest_ci.yml b/.github/workflows/pytest_ci.yml index 844824e..c001f5b 100644 --- a/.github/workflows/pytest_ci.yml +++ b/.github/workflows/pytest_ci.yml @@ -28,12 +28,13 @@ jobs: run: | REPORT=pytest_${{ matrix.python-version }}.md pytest --md $REPORT + shell: bash -el {0} - name: Add report to summary if: always() run: | echo "::group::..." FINAL_REPORT=pytest_report_${{ matrix.python-version }}.md - echo "# ${{ inputs.report-title }}" > "$FINAL_REPORT" + echo "# Test report (via pytest)" > "$FINAL_REPORT" echo "
Click to expand!" >> "$FINAL_REPORT" tail -n+2 "${{ steps.pytest.outputs.report-path }}" >> "$FINAL_REPORT" echo "
" >> "$FINAL_REPORT" From 8ff20f5f668df63e84023a0d2920e6b4fc5989c4 Mon Sep 17 00:00:00 2001 From: Mario Santa Cruz Date: Fri, 23 Feb 2024 08:22:05 +0000 Subject: [PATCH 7/9] point to report env var --- .github/workflows/pytest_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pytest_ci.yml b/.github/workflows/pytest_ci.yml index c001f5b..530fe3f 100644 --- a/.github/workflows/pytest_ci.yml +++ b/.github/workflows/pytest_ci.yml @@ -36,7 +36,7 @@ jobs: FINAL_REPORT=pytest_report_${{ matrix.python-version }}.md echo "# Test report (via pytest)" > "$FINAL_REPORT" echo "
Click to expand!" >> "$FINAL_REPORT" - tail -n+2 "${{ steps.pytest.outputs.report-path }}" >> "$FINAL_REPORT" + tail -n+2 "$REPORT" >> "$FINAL_REPORT" echo "
" >> "$FINAL_REPORT" cat "$FINAL_REPORT" >> "$GITHUB_STEP_SUMMARY" echo "::endgroup::" From eda55ad4d3cac3d61acce8e7478f05e5dfe4002a Mon Sep 17 00:00:00 2001 From: Mario Santa Cruz Date: Fri, 23 Feb 2024 08:29:12 +0000 Subject: [PATCH 8/9] use GITHUB_OUTPUT env var --- .github/workflows/pytest_ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pytest_ci.yml b/.github/workflows/pytest_ci.yml index 530fe3f..9948239 100644 --- a/.github/workflows/pytest_ci.yml +++ b/.github/workflows/pytest_ci.yml @@ -27,6 +27,7 @@ jobs: id: pytest run: | REPORT=pytest_${{ matrix.python-version }}.md + echo "report-path=$REPORT" >> $GITHUB_OUTPUT pytest --md $REPORT shell: bash -el {0} - name: Add report to summary @@ -36,7 +37,7 @@ jobs: FINAL_REPORT=pytest_report_${{ matrix.python-version }}.md echo "# Test report (via pytest)" > "$FINAL_REPORT" echo "
Click to expand!" >> "$FINAL_REPORT" - tail -n+2 "$REPORT" >> "$FINAL_REPORT" + tail -n+2 "${{ steps.pytest.outputs.report-path }}" >> "$FINAL_REPORT" echo "
" >> "$FINAL_REPORT" cat "$FINAL_REPORT" >> "$GITHUB_STEP_SUMMARY" echo "::endgroup::" From 6725e361d0af38c78f79860add283611c6f6e40b Mon Sep 17 00:00:00 2001 From: Mario Santa Cruz Date: Fri, 23 Feb 2024 08:36:46 +0000 Subject: [PATCH 9/9] verbose --- .github/workflows/pytest_ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pytest_ci.yml b/.github/workflows/pytest_ci.yml index 9948239..505332f 100644 --- a/.github/workflows/pytest_ci.yml +++ b/.github/workflows/pytest_ci.yml @@ -28,14 +28,14 @@ jobs: run: | REPORT=pytest_${{ matrix.python-version }}.md echo "report-path=$REPORT" >> $GITHUB_OUTPUT - pytest --md $REPORT + pytest --verbose --md $REPORT shell: bash -el {0} - name: Add report to summary if: always() run: | echo "::group::..." FINAL_REPORT=pytest_report_${{ matrix.python-version }}.md - echo "# Test report (via pytest)" > "$FINAL_REPORT" + echo "# Test report (python ${{ matrix.python-version }})" > "$FINAL_REPORT" echo "
Click to expand!" >> "$FINAL_REPORT" tail -n+2 "${{ steps.pytest.outputs.report-path }}" >> "$FINAL_REPORT" echo "
" >> "$FINAL_REPORT"