From 891361cc93b622842975900fecdedcccbc613904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sat, 5 Dec 2026 11:54:21 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Publish=20coverage=20reports=20w?= =?UTF-8?q?ith=20Artifact=20Viewer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/artifact-viewer.yml | 4 +++ .github/workflows/actions.lock | 12 ++++--- .github/workflows/coverage-status.yml | 19 +++++++++++ .github/workflows/smokeshow.yml | 48 --------------------------- .github/workflows/test.yml | 27 ++++++++++++--- README.md | 5 +-- pyproject.toml | 3 -- uv.lock | 17 ---------- 8 files changed, 55 insertions(+), 80 deletions(-) create mode 100644 .github/artifact-viewer.yml create mode 100644 .github/workflows/coverage-status.yml delete mode 100644 .github/workflows/smokeshow.yml diff --git a/.github/artifact-viewer.yml b/.github/artifact-viewer.yml new file mode 100644 index 00000000..023aca68 --- /dev/null +++ b/.github/artifact-viewer.yml @@ -0,0 +1,4 @@ +workflows: + .github/workflows/test.yml: + - coverage-html + - coverage-summary diff --git a/.github/workflows/actions.lock b/.github/workflows/actions.lock index f6372e50..8a61a330 100644 --- a/.github/workflows/actions.lock +++ b/.github/workflows/actions.lock @@ -10,6 +10,8 @@ workflows: - 'actions/setup-python@v7.1.0' - 'astral-sh/setup-uv@v10.4.0' - 'tiangolo/pr-submit@0.0.1' + '.github/workflows/coverage-status.yml': + - 'tiangolo/artifact-viewer@0.0.1' '.github/workflows/create-draft-release.yml': - 'actions/checkout@v7.0.1' - 'actions/setup-python@v7.1.0' @@ -36,11 +38,6 @@ workflows: - 'actions/checkout@v7.0.1' - 'actions/setup-python@v7.1.0' - 'astral-sh/setup-uv@v10.4.0' - '.github/workflows/smokeshow.yml': - - 'actions/checkout@v7.0.1' - - 'actions/download-artifact@v8.0.2' - - 'actions/setup-python@v7.1.0' - - 'astral-sh/setup-uv@v10.4.0' '.github/workflows/test-redistribute.yml': - 'actions/checkout@v7.0.1' - 'actions/setup-python@v7.1.0' @@ -116,6 +113,11 @@ dependencies: commit: 'sha1-b5b5b37504aa4183270bd3d855c52a67f212be35' owner_id: 46427759 repo_id: 434447646 + 'tiangolo/artifact-viewer@0.0.1': + ref: '0.0.1' + commit: 'sha1-12a42514ef1e5b20269f8e2ccd1dff0861987746' + owner_id: 1326112 + repo_id: 1483846098 'tiangolo/issue-manager@0.8.1': ref: '0.8.1' commit: 'sha1-dc846170c36eb62fb434b3d943b36399fe240fb5' diff --git a/.github/workflows/coverage-status.yml b/.github/workflows/coverage-status.yml new file mode 100644 index 00000000..4d109b8f --- /dev/null +++ b/.github/workflows/coverage-status.yml @@ -0,0 +1,19 @@ +name: Coverage status + +on: + workflow_run: # zizmor: ignore[dangerous-triggers] + workflows: [Test] + types: [completed] + +permissions: {} + +jobs: + report: + if: github.event.workflow_run.event == 'pull_request' + runs-on: ubuntu-latest + permissions: + actions: read + statuses: write + timeout-minutes: 5 + steps: + - uses: tiangolo/artifact-viewer@0.0.1 diff --git a/.github/workflows/smokeshow.yml b/.github/workflows/smokeshow.yml deleted file mode 100644 index da3dce71..00000000 --- a/.github/workflows/smokeshow.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Smokeshow - -on: - workflow_run: # zizmor: ignore[dangerous-triggers] - workflows: [Test] - types: [completed] - -permissions: {} - -jobs: - smokeshow: - runs-on: ubuntu-latest - permissions: - statuses: write - timeout-minutes: 5 - steps: - - name: Dump GitHub context - env: - GITHUB_CONTEXT: ${{ toJson(github) }} - run: echo "$GITHUB_CONTEXT" - - uses: actions/checkout@v7.0.1 - with: - persist-credentials: false - - uses: actions/setup-python@v7.1.0 - with: - python-version-file: ".python-version" - - name: Setup uv - uses: astral-sh/setup-uv@v10.4.0 - with: - version: "latest-known" - cache-dependency-glob: | - pyproject.toml - uv.lock - - run: uv sync --locked --no-dev --group github-actions - - uses: actions/download-artifact@v8.0.2 - with: - name: coverage-html - path: htmlcov - github-token: ${{ secrets.GITHUB_TOKEN }} - run-id: ${{ github.event.workflow_run.id }} - - run: uv run smokeshow upload htmlcov - env: - SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage} - SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 100 - SMOKESHOW_GITHUB_CONTEXT: coverage - SMOKESHOW_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SMOKESHOW_GITHUB_PR_HEAD_SHA: ${{ github.event.workflow_run.head_sha }} - SMOKESHOW_AUTH_KEY: ${{ secrets.SMOKESHOW_AUTH_KEY }} # zizmor: ignore[secrets-outside-env] diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e4028028..2ae78af4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -93,9 +93,10 @@ jobs: - name: Store coverage files uses: actions/upload-artifact@v7.0.2 with: - name: coverage-${{ runner.os }}-${{ matrix.python-version }} + name: coverage-data-${{ runner.os }}-${{ matrix.python-version }} path: coverage include-hidden-files: true + overwrite: true coverage-combine: needs: [test] @@ -123,20 +124,36 @@ jobs: - name: Get coverage files uses: actions/download-artifact@v8.0.2 with: - pattern: coverage-* + pattern: coverage-data-* path: coverage merge-multiple: true - name: Install dependencies run: uv sync --locked --no-dev --group tests --extra standard - - run: ls -la coverage - run: uv run coverage combine coverage - - run: uv run coverage html --title "Coverage for ${{ github.sha }}" + - name: Generate coverage reports + run: | + uv run coverage html --fail-under=0 --title "Coverage for $GITHUB_SHA" + total=$(uv run coverage report --format=total --precision=2 --fail-under=0) + printf '{"coverage": %s}\n' "$total" > summary.json - name: Store coverage HTML + id: coverage-html uses: actions/upload-artifact@v7.0.2 with: name: coverage-html path: htmlcov - include-hidden-files: true + if-no-files-found: error + overwrite: true + - name: Store coverage summary + uses: actions/upload-artifact@v7.0.2 + with: + name: coverage-summary + path: summary.json + if-no-files-found: error + overwrite: true + - name: Link to the coverage report + env: + ARTIFACT_ID: ${{ steps.coverage-html.outputs.artifact-id }} + run: echo "[Coverage report](https://artifact-viewer.fastapicloud.dev/artifacts/$GITHUB_REPOSITORY/$ARTIFACT_ID/)" >> "$GITHUB_STEP_SUMMARY" - run: uv run coverage report --fail-under=100 # https://github.com/marketplace/actions/alls-green#why diff --git a/README.md b/README.md index 1ba31b57..88ae66f5 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,9 @@ Test - - Coverage + + Coverage + Package version diff --git a/pyproject.toml b/pyproject.toml index d1b22033..febda8f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,9 +61,6 @@ dev = [ "prek>=0.2.24,<1.0.0", "zizmor>=1.24.1", ] -github-actions = [ - "smokeshow>=0.5.0", -] tests = [ "coverage[toml]>=7.9,<8.0", "fastapi>=0.128.0", diff --git a/uv.lock b/uv.lock index e6c557fa..9037615f 100644 --- a/uv.lock +++ b/uv.lock @@ -349,9 +349,6 @@ dev = [ { name = "uvicorn" }, { name = "zizmor" }, ] -github-actions = [ - { name = "smokeshow" }, -] tests = [ { name = "coverage" }, { name = "fastapi" }, @@ -386,7 +383,6 @@ dev = [ { name = "uvicorn", specifier = ">=0.39.0" }, { name = "zizmor", specifier = ">=1.24.1" }, ] -github-actions = [{ name = "smokeshow", specifier = ">=0.5.0" }] tests = [ { name = "coverage", extras = ["toml"], specifier = ">=7.9,<8.0" }, { name = "fastapi", specifier = ">=0.128.0" }, @@ -1434,19 +1430,6 @@ wheels = [ { url = "https://files.pythonhosted.org/packages/e0/f9/0595336914c5619e5f28a1fb793285925a8cd4b432c9da0a987836c7f822/shellingham-1.5.4-py2.py3-none-any.whl", hash = "sha256:7ecfff8f2fd72616f7481040475a65b2bf8af90a56c89140852d1120324e8686", size = 9755, upload-time = "2023-10-24T04:13:38.866Z" }, ] -[[package]] -name = "smokeshow" -version = "0.5.0" -source = { registry = "https://pypi.org/simple" } -dependencies = [ - { name = "httpx" }, - { name = "typer" }, -] -sdist = { url = "https://files.pythonhosted.org/packages/75/94/c99b76517c268ef8d5c2ff88faba5a019664bd69e4754944afa294b4f24c/smokeshow-0.5.0.tar.gz", hash = "sha256:91dcabc29ac3116bff59b4d8a7bda4ae3ccc4c70742a38cec7127b8162e4a0f6", size = 101349, upload-time = "2025-01-07T19:41:51.732Z" } -wheels = [ - { url = "https://files.pythonhosted.org/packages/77/10/0d23e4953eb7c1e1ad848084b3115f19234f34f907658ed11bed0d826aee/smokeshow-0.5.0-py3-none-any.whl", hash = "sha256:da12a960fc7cb525efc4035a0c3c9363b6217ea7e66bc39b9ed3cd8bed6eeedc", size = 8389, upload-time = "2025-01-07T19:41:49.194Z" }, -] - [[package]] name = "starlette" version = "0.50.0"