Skip to content

Commit

Permalink
fixup! feat(action): add check for package versions
Browse files Browse the repository at this point in the history
  • Loading branch information
pchorus committed Apr 12, 2024
1 parent d9abe8c commit 9aa816e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:

- uses: moneymeets/moneymeets-composite-actions/lint-python@master

- run: poetry run python -m pytest --cov --cov-fail-under=93
- run: poetry run python -m pytest --cov --cov-fail-under=45
10 changes: 5 additions & 5 deletions invalid_package_versions/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def check_invalid_package_versions(pyproject_data):
invalid_versions = []

for package, version in (
*poetry_data["dependencies"].items(),
*poetry_data["dev-dependencies"].items(),
*itertools.chain.from_iterable(
(group["dependencies"].items() for _, group in poetry_data.get("group", {}).items()),
),
*poetry_data["dependencies"].items(),
*poetry_data["dev-dependencies"].items(),
*itertools.chain.from_iterable(
(group["dependencies"].items() for _, group in poetry_data.get("group", {}).items()),
),
):
version_str = get_version(version)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@


class CheckInvalidPackageVersions(TestCase):
valid_pyproject_toml = tomllib.loads(Path("data/pyproject_mock_valid.toml").read_text())
invalid_pyproject_toml = tomllib.loads(Path("data/pyproject_mock_invalid.toml").read_text())
valid_pyproject_toml = tomllib.loads(
Path("invalid_package_versions/tests/data/pyproject_mock_valid.toml").read_text()
)
invalid_pyproject_toml = tomllib.loads(
Path("invalid_package_versions/tests/data/pyproject_mock_invalid.toml").read_text()
)

def test_check_invalid_package_versions_success(self):
self.assertEqual((), check_invalid_package_versions(self.valid_pyproject_toml))

def test_check_invalid_package_versions_failed(self):
self.assertEqual((
("python", ">=3.12"),
("pytest", ">=8"),
("test-package-1", ">=1"),
("test-package-2", ">=1"),
), check_invalid_package_versions(self.invalid_pyproject_toml))
self.assertEqual(
(
("python", ">=3.12"),
("pytest", ">=8"),
("test-package-1", ">=1"),
("test-package-2", ">=1"),
),
check_invalid_package_versions(self.invalid_pyproject_toml),
)

0 comments on commit 9aa816e

Please sign in to comment.