Skip to content

Commit

Permalink
Merge pull request #3 from DeanWay/github-actions
Browse files Browse the repository at this point in the history
switch to github actions
  • Loading branch information
DeanWay authored Sep 25, 2024
2 parents f242495 + 8b25b25 commit 7147c98
Show file tree
Hide file tree
Showing 10 changed files with 350 additions and 348 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: pull request check

on:
pull_request:

jobs:
test:
uses: ./.github/workflows/test.yml
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: test

on:
workflow_call:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install tox and any other packages
run: pip install tox
- name: Run tox
# Run tox using the version of Python in `PATH`
run: tox -e py
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ black = "*"
typing_extensions = "*"
hypothesis = "*"
flake8 = "*"
types-toml = "*"

[packages]
toml = ">= 0.10.2"
Expand Down
599 changes: 298 additions & 301 deletions Pipfile.lock

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions coverage_threshold/lib/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ def __call__(
summary: CoverageSummaryModel,
threshold: Optional[T],
failure_message_prefix: str,
) -> CheckResult:
...
) -> CheckResult: ...


def _safe_percent(numerator: int, denomenator: int) -> Decimal:
Expand Down
8 changes: 5 additions & 3 deletions coverage_threshold/model/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ def parse(obj: Any) -> Config:
file_combined_coverage_min=parse_option_field(
obj, Decimal, "file_combined_coverage_min"
),
modules={k: ModuleConfig.parse(v) for k, v in obj["modules"].items()}
if "modules" in obj
else None,
modules=(
{k: ModuleConfig.parse(v) for k, v in obj["modules"].items()}
if "modules" in obj
else None
),
)


Expand Down
35 changes: 12 additions & 23 deletions tests/unit/lib/test_all_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,10 @@ def test_check_totals() -> None:
)
== Pass()
)
assert (
check_all(
create_report(
totals=CoverageSummaryModel(covered_lines=2, num_statements=3)
),
Config(line_coverage_min=Decimal("67.0")),
)
== Fail(["Total line coverage metric failed, expected 67.0, was 66.6667"])
)
assert check_all(
create_report(totals=CoverageSummaryModel(covered_lines=2, num_statements=3)),
Config(line_coverage_min=Decimal("67.0")),
) == Fail(["Total line coverage metric failed, expected 67.0, was 66.6667"])


def test_check_totals__with_number_missing_lines_max() -> None:
Expand Down Expand Up @@ -125,13 +120,10 @@ def test_check_totals_with_branch_coverage() -> None:
)
== Pass()
)
assert (
check_all(
report,
Config(branch_coverage_min=Decimal("75.001")),
)
== Fail(["Total branch coverage metric failed, expected 75.001, was 75.0000"])
)
assert check_all(
report,
Config(branch_coverage_min=Decimal("75.001")),
) == Fail(["Total branch coverage metric failed, expected 75.001, was 75.0000"])


def test_check_totals_with_combined_coverage() -> None:
Expand All @@ -151,13 +143,10 @@ def test_check_totals_with_combined_coverage() -> None:
)
== Pass()
)
assert (
check_all(
report,
Config(combined_coverage_min=Decimal("80.001")),
)
== Fail(["Total combined coverage metric failed, expected 80.001, was 80.0000"])
)
assert check_all(
report,
Config(combined_coverage_min=Decimal("80.001")),
) == Fail(["Total combined coverage metric failed, expected 80.001, was 80.0000"])


def test_check_all_files_with_branch_coverage() -> None:
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/lib/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ def test_safe_percent__100_percent_when_denomenator_is_zero(numerator: int) -> N
assert _safe_percent(numerator, 0) == Decimal(100)


@given(
integers(min_value=0, max_value=10 ** 10), integers(min_value=1, max_value=10 ** 10)
)
@given(integers(min_value=0, max_value=10**10), integers(min_value=1, max_value=10**10))
def test_safe_percent__regular_fraction_otherwise(
numerator: int, denomenator: int
) -> None:
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py37, py38, py39
envlist = py38, py39, py310, py311, py312

[testenv]
deps = pipenv
Expand Down

0 comments on commit 7147c98

Please sign in to comment.