From 42cb64a832e3197ad10e9bd22e0d522fc295324d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 3 Nov 2022 13:44:37 +0100 Subject: [PATCH 01/10] =?UTF-8?q?=E2=9E=95=20Move=20from=20pytest-cov=20to?= =?UTF-8?q?=20pure=20coverage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 17 ++++++++++++++++- scripts/test-cov-html.sh | 6 +++++- scripts/test.sh | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ad088ce33527f..706eb793bfdec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -50,7 +50,7 @@ Documentation = "https://fastapi.tiangolo.com/" [project.optional-dependencies] test = [ "pytest >=7.1.3,<8.0.0", - "pytest-cov >=2.12.0,<5.0.0", + "coverage[toml] >= 6.5.0,<7.0", "mypy ==0.982", "flake8 >=3.8.3,<6.0.0", "black == 22.8.0", @@ -147,3 +147,18 @@ filterwarnings = [ # TODO remove pytest-cov 'ignore::pytest.PytestDeprecationWarning:pytest_cov', ] + +[tool.coverage.run] +parallel = true +source = [ + "docs_src", + "tests", + "fastapi" +] + +[tool.coverage.report] +exclude_lines = [ + "pragma: no cover", + "@overload", + "if TYPE_CHECKING:", +] diff --git a/scripts/test-cov-html.sh b/scripts/test-cov-html.sh index 7957277fc354f..d017d27768f10 100755 --- a/scripts/test-cov-html.sh +++ b/scripts/test-cov-html.sh @@ -3,4 +3,8 @@ set -e set -x -bash scripts/test.sh --cov-report=html ${@} +bash scripts/test.sh ${@} +coverage combine +coverage report --show-missing +coverage xml +coverage html diff --git a/scripts/test.sh b/scripts/test.sh index d445ca174200b..62449ea41549b 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -6,4 +6,4 @@ set -x # Check README.md is up to date python ./scripts/docs.py verify-readme export PYTHONPATH=./docs_src -pytest --cov=fastapi --cov=tests --cov=docs_src --cov-report=term-missing:skip-covered --cov-report=xml tests ${@} +coverage run -m pytest tests ${@} From 87671dd97308c4f9cefbf1637931f3e315deea5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 3 Nov 2022 14:27:54 +0100 Subject: [PATCH 02/10] =?UTF-8?q?=F0=9F=92=9A=20Trigger=20CI,=20because=20?= =?UTF-8?q?Codecov?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From fddebe350e1cce94258840f6967ad7c1d49781cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 3 Nov 2022 19:09:53 +0100 Subject: [PATCH 03/10] =?UTF-8?q?=F0=9F=92=9A=20Trigger=20CI,=20Codecov,?= =?UTF-8?q?=20please=20work,=20one=20of=20the=20last=20times?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 222457a04e857b233466877fcd51c13850fb333c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 3 Nov 2022 19:48:19 +0100 Subject: [PATCH 04/10] =?UTF-8?q?=F0=9F=94=A7=20Add=20Smokeshow=20to=20rep?= =?UTF-8?q?lace=20Codecov?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/smokeshow.yml | 35 +++++++++++++++++++++++++++++ .github/workflows/test.yml | 40 +++++++++++++++++++++++++++++++-- pyproject.toml | 1 + scripts/test-cov-html.sh | 1 - 4 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/smokeshow.yml diff --git a/.github/workflows/smokeshow.yml b/.github/workflows/smokeshow.yml new file mode 100644 index 0000000000000..606633a99dece --- /dev/null +++ b/.github/workflows/smokeshow.yml @@ -0,0 +1,35 @@ +name: Smokeshow + +on: + workflow_run: + workflows: [Test] + types: [completed] + +permissions: + statuses: write + +jobs: + smokeshow: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + + steps: + - uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - run: pip install smokeshow + + - uses: dawidd6/action-download-artifact@v2 + with: + workflow: test.yml + commit: ${{ github.event.workflow_run.head_sha }} + + - run: smokeshow upload coverage-html + 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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e492c1adacf8..552766bcec102 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -31,7 +31,43 @@ jobs: run: pip install -e .[all,dev,doc,test] - name: Lint run: bash scripts/lint.sh + - run: mkdir coverage - name: Test run: bash scripts/test.sh - - name: Upload coverage - uses: codecov/codecov-action@v3 + env: + COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} + CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} + - name: store coverage files + uses: actions/upload-artifact@v3 + with: + name: coverage + path: coverage + coverage-combine: + needs: [test] + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: '3.8' + + - name: get coverage files + uses: actions/download-artifact@v3 + with: + name: coverage + path: coverage + + - run: pip install coverage[toml] + + - run: ls -la coverage + - run: coverage combine coverage + - run: coverage report + - run: coverage html --show-contexts --title "Coverage for ${{ github.sha }}" + + - name: Store coverage html + uses: actions/upload-artifact@v3 + with: + name: coverage-html + path: htmlcov diff --git a/pyproject.toml b/pyproject.toml index 706eb793bfdec..488ba24cfd3b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -155,6 +155,7 @@ source = [ "tests", "fastapi" ] +context = '${CONTEXT}' [tool.coverage.report] exclude_lines = [ diff --git a/scripts/test-cov-html.sh b/scripts/test-cov-html.sh index d017d27768f10..d1bdfced2abc5 100755 --- a/scripts/test-cov-html.sh +++ b/scripts/test-cov-html.sh @@ -6,5 +6,4 @@ set -x bash scripts/test.sh ${@} coverage combine coverage report --show-missing -coverage xml coverage html From 776f653e751aaa738bd8738faa97e4c7c26d765b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 3 Nov 2022 20:07:03 +0100 Subject: [PATCH 05/10] =?UTF-8?q?=F0=9F=92=9A=20Try=20an=20empty=20commit,?= =?UTF-8?q?=20in=20case=20that=20triggers=20Smokeshow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From 8ab07cf15d1a46111c4b90a5cfbdc2370c3793e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 3 Nov 2022 20:46:44 +0100 Subject: [PATCH 06/10] =?UTF-8?q?=F0=9F=94=A7=20Rename=20workflow=20to=20T?= =?UTF-8?q?est=20Coverage=20to=20make=20it=20easier=20to=20understand=20in?= =?UTF-8?q?=20GitHub=20Actions=20what=20it=20refers=20to?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/smokeshow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smokeshow.yml b/.github/workflows/smokeshow.yml index 606633a99dece..11c960abf4950 100644 --- a/.github/workflows/smokeshow.yml +++ b/.github/workflows/smokeshow.yml @@ -1,4 +1,4 @@ -name: Smokeshow +name: Test Coverage Preview on: workflow_run: From bdcf9e57aa7148786a4af291cd087f647876eb23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 3 Nov 2022 20:48:08 +0100 Subject: [PATCH 07/10] =?UTF-8?q?=F0=9F=94=A5=20Remove=20unnecessary=20cov?= =?UTF-8?q?erage=20configuration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 488ba24cfd3b6..d7b848502c12e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -156,10 +156,3 @@ source = [ "fastapi" ] context = '${CONTEXT}' - -[tool.coverage.report] -exclude_lines = [ - "pragma: no cover", - "@overload", - "if TYPE_CHECKING:", -] From af1c8dcad0fa294c6b042ed82ae787f9127f564a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 3 Nov 2022 20:49:07 +0100 Subject: [PATCH 08/10] =?UTF-8?q?=F0=9F=94=A7=20Change=20workflow=20name?= =?UTF-8?q?=20again=20to=20Smokeshow,=20everything=20else=20in=20it=20is?= =?UTF-8?q?=20called=20like=20that?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/smokeshow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/smokeshow.yml b/.github/workflows/smokeshow.yml index 11c960abf4950..606633a99dece 100644 --- a/.github/workflows/smokeshow.yml +++ b/.github/workflows/smokeshow.yml @@ -1,4 +1,4 @@ -name: Test Coverage Preview +name: Smokeshow on: workflow_run: From 2136c9f1326d29a60e65234ec895fa792a1378a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 3 Nov 2022 20:54:52 +0100 Subject: [PATCH 09/10] =?UTF-8?q?=F0=9F=94=A7=20Tweak=20GitHub=20step=20na?= =?UTF-8?q?mes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 552766bcec102..ecd40529df659 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -53,7 +53,7 @@ jobs: with: python-version: '3.8' - - name: get coverage files + - name: Get coverage files uses: actions/download-artifact@v3 with: name: coverage @@ -66,7 +66,7 @@ jobs: - run: coverage report - run: coverage html --show-contexts --title "Coverage for ${{ github.sha }}" - - name: Store coverage html + - name: Store coverage HTML uses: actions/upload-artifact@v3 with: name: coverage-html From d75c214e24731ae72f880219c31b88af6f1a2622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 3 Nov 2022 20:55:23 +0100 Subject: [PATCH 10/10] =?UTF-8?q?=F0=9F=94=A7=20Tweak=20GitHub=20Action=20?= =?UTF-8?q?step=20names?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ecd40529df659..7f87be700b0e6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,7 +37,7 @@ jobs: env: COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} - - name: store coverage files + - name: Store coverage files uses: actions/upload-artifact@v3 with: name: coverage