From 9b169c1f301ecd57a878a4a80c0c2e6d2b526a9a Mon Sep 17 00:00:00 2001 From: David Butenhof Date: Fri, 6 Dec 2024 12:16:01 -0500 Subject: [PATCH] Can you hear me now? --- .github/workflows/test.yaml | 10 ++++++++-- backend/pyproject.toml | 11 ++++++++++- backend/tests/test_crucible.py | 1 - 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index cc5b047..bc5c09c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,4 +1,4 @@ -name: Run Unit Test via Pytest +name: Python checks on: push: @@ -6,6 +6,9 @@ on: tags-ignore: ["**"] pull_request: +env: + COVERAGE: ${{ github.workspace }}/coverage + jobs: build: runs-on: ubuntu-latest @@ -24,6 +27,7 @@ jobs: python -m pip install --upgrade pip pip install tox>=4.19 - name: Check for lint + # Report errors but don't fail until we achieve stability! continue-on-error: true run: | cd backend @@ -32,10 +36,12 @@ jobs: run: | cd backend tox -e unit + - name: Add coverage data to conversation + run: cat $COVERAGE/coverage.txt >> $GITHUB_STEP_SUMMARY - name: Publish coverage data uses: actions/upload-artifact@v4 with: name: Coverage for ${{ github.event.head_commit.id }} - path: backend/.tox/unit/tmp/coverage.db + path: ${{ env.COVERAGE }}/html if-no-files-found: warn retention-days: 30 diff --git a/backend/pyproject.toml b/backend/pyproject.toml index eb52732..c3b3b6c 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -57,8 +57,17 @@ deps = [ "pytest", "pytest-asyncio", "pytest-cov", + "coverage", +] +set_env.COVERAGE = { replace = "env", name = "COVERAGE", default = "/var/tmp/{env:USER}" } +allowlist_externals = ["bash", "echo", "coverage"] +commands = [ + ["echo", "{env:COVERAGE}"], + ["pip", "list"], + ["pytest", "-s", "--cov-branch", "--cov=app", "tests"], + ["coverage", "html", "--directory={env:COVERAGE}/html"], + ["bash", "-c", "coverage report --format=markdown >{env:COVERAGE}/coverage.txt"], ] -commands = [["pip", "list"],["pytest", "-s", "--cov-report=term", "--cov-branch", "--cov-report=html:.tox/unit/tmp/coverage.db", "--cov=app", "tests"]] [tool.tox.env.format] description = "check code format" diff --git a/backend/tests/test_crucible.py b/backend/tests/test_crucible.py index c71450a..6265278 100644 --- a/backend/tests/test_crucible.py +++ b/backend/tests/test_crucible.py @@ -128,7 +128,6 @@ async def test_metric_ids_none(self, fake_elastic): """A simple query for failure matching metric IDs""" crucible = CrucibleService("TEST") - print(f"Elastic is {type(crucible.elastic).__name__}") crucible.elastic.set_query("metric_desc", []) with pytest.raises(HTTPException) as e: await crucible._get_metric_ids("runid", "source::type")