Skip to content

Commit

Permalink
👷 Move from pytest-cov to coverage and Codecov to Smokeshow (fastapi#483
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tiangolo authored and alexreg committed Nov 6, 2022
1 parent a0c9c5e commit 4117263
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 13 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ source =
docs_src

parallel = True
context = '${CONTEXT}'
35 changes: 35 additions & 0 deletions .github/workflows/smokeshow.yml
Original file line number Diff line number Diff line change
@@ -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 }}
41 changes: 38 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,46 @@ jobs:
- name: Install Flit
run: pip install flit
- name: Install Dependencies
# run: flit install --deps=develop --symlink
run: python -m pip install ".[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
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
<a href="https://github.com/alexreg/typer/actions?query=workflow%3APublish" target="_blank">
<img src="https://github.com/alexreg/typer/workflows/Publish/badge.svg" alt="Publish">
</a>
<a href="https://codecov.io/gh/alexreg/typer" target="_blank">
<img src="https://img.shields.io/codecov/c/github/alexreg/typer?color=%2334D058" alt="Coverage">
</a>
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/alexreg/typer" target="_blank">
<img src="https://coverage-badge.samuelcolvin.workers.dev/alexreg/typer.svg" alt="Coverage">
<a href="https://pypi.org/project/typer" target="_blank">
<img src="https://img.shields.io/pypi/v/typer?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
Expand Down
5 changes: 2 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
<a href="https://github.com/alexreg/typer/actions?query=workflow%3APublish" target="_blank">
<img src="https://github.com/alexreg/typer/workflows/Publish/badge.svg" alt="Publish">
</a>
<a href="https://codecov.io/gh/alexreg/typer" target="_blank">
<img src="https://img.shields.io/codecov/c/github/alexreg/typer?color=%2334D058" alt="Coverage">
</a>
<a href="https://coverage-badge.samuelcolvin.workers.dev/redirect/alexreg/typer" target="_blank">
<img src="https://coverage-badge.samuelcolvin.workers.dev/alexreg/typer.svg" alt="Coverage">
<a href="https://pypi.org/project/typer" target="_blank">
<img src="https://img.shields.io/pypi/v/typer?color=%2334D058&label=pypi%20package" alt="Package version">
</a>
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@ repository = "https://github.com/alexreg/typer"
[project.optional-dependencies]
test = [
"black ~= 22.3.0",
"coverage ~= 5.2",
"coverage ~= 6.0.0",
"docstring_parser ~= 0.15",
"isort ~= 5.10.1",
"mypy ~= 0.950",
"pytest ~= 7.1.2",
"pytest-cov ~= 3.0.0",
"pytest-sugar ~= 0.9.4",
"pytest-xdist ~= 2.1.0",
"shellingham ~= 1.4.0",
Expand Down
5 changes: 4 additions & 1 deletion scripts/test-cov-html.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
set -e
set -x

bash scripts/test.sh --cov-report=html ${@}
bash scripts/test.sh ${@}
coverage combine
coverage report --show-missing
coverage html
2 changes: 1 addition & 1 deletion scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set -x

bash ./scripts/test-files.sh
# Use xdist-pytest --forked to ensure modified sys.path to import relative modules in examples keeps working
pytest --cov=typer --cov=tests --cov=docs_src --cov-report=term-missing --cov-report=xml -o console_output_style=progress --forked --numprocesses=auto ${@}
coverage run -m pytest -o console_output_style=progress --forked --numprocesses=auto ${@}

0 comments on commit 4117263

Please sign in to comment.