Skip to content

Commit

Permalink
feat: setup coverage and codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
outloudvi committed Aug 3, 2024
1 parent c135f64 commit 6747791
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 26 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Install libime
run: sudo apt install -y libime-bin
Expand All @@ -25,7 +25,7 @@ jobs:
run: pipx install poetry

- name: Set up Python 3.12
uses: actions/setup-python@v3
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: '3.12'
cache: 'poetry'
Expand All @@ -40,4 +40,12 @@ jobs:
run: poetry run yapf -i -r mw2fcitx

- name: Test with pytest
run: poetry run pytest
run: |
poetry run coverage erase
poetry run coverage run -m pytest tests/
poetry run coverage run -a -m mw2fcitx.main -c tests/cli/conf_one.py
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
43 changes: 22 additions & 21 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,23 @@ pypinyin = "^0.52.0.dev1"
python = "^3.9"

[tool.poetry.group.dev.dependencies]
coverage = "^7.6.0"
pylint = "^3.2.5"
pytest = "^8.3.1"
yapf = "^0.40.2"
coverage = "^7.6.0"

[build-system]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core"]

[tool.yapf]
based_on_style = "google"

[tool.coverage.run]
branch = true
omit = [
"*/.venv/*",
]

[tool.coverage.html]
directory = "coverage_html_report"
4 changes: 4 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[pytest]
python_files = test_*.py
addopts = -slv --cov-report term-missing --tb=short --durations=10
norecursedirs = .git __pycache__ .venv
2 changes: 1 addition & 1 deletion utils/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ set -e

poetry install
poetry run coverage erase
poetry run coverage run -m pytest
poetry run coverage run -m pytest tests/
poetry run coverage run -a -m mw2fcitx.main -c tests/cli/conf_one.py
poetry run coverage html

0 comments on commit 6747791

Please sign in to comment.