Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix semantic versioning check in tech-review hook #194

Merged
merged 25 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c7d4cc4
fix semver check for dev strings
klmcadams Jul 1, 2024
4861218
chore: adding changelog file 194.fixed.md
pyansys-ci-bot Jul 1, 2024
b392bb0
Merge branch 'main' into fix/semver-check
klmcadams Jul 1, 2024
00dbb27
uncomment tech review hook
klmcadams Jul 1, 2024
07e4988
Merge branch 'fix/semver-check' of https://github.com/ansys/pre-commi…
klmcadams Jul 1, 2024
0f151f5
add try except for ConnectionError in license download
klmcadams Jul 1, 2024
d5b4a2b
remove return False when license can't be downloaded
klmcadams Jul 1, 2024
6b6822e
add return False
klmcadams Jul 1, 2024
1b155fc
update setup.py and pyproject.toml to download license.json on install
klmcadams Jul 10, 2024
fb2b6df
install importlib?
klmcadams Jul 10, 2024
b7076c0
verbose pip install
klmcadams Jul 10, 2024
47ece9a
Merge branch 'main' into fix/semver-check
klmcadams Jul 10, 2024
ba5a944
remove reuse from tech review
klmcadams Jul 12, 2024
6334a14
Merge branch 'fix/semver-check' of https://github.com/ansys/pre-commi…
klmcadams Jul 12, 2024
fe529e7
build and install wheels
klmcadams Jul 12, 2024
3113538
hardcode packages
klmcadams Jul 12, 2024
25f5a24
use the action
klmcadams Jul 12, 2024
da2c06b
create version file
klmcadams Jul 12, 2024
a5320f7
fix path
klmcadams Jul 12, 2024
a45d013
try version py file
klmcadams Jul 12, 2024
df92a5a
fix version issues?
klmcadams Jul 15, 2024
d484422
Merge branch 'main' of https://github.com/ansys/pre-commit-hooks into…
klmcadams Jul 15, 2024
a9e4fc9
fix setup.py checks
klmcadams Jul 15, 2024
0efec34
test case when setup.py and pyproject.toml exist
klmcadams Jul 15, 2024
b6d4cc2
remove commented lines
klmcadams Jul 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ repos:
- id: check-github-workflows

- repo: https://github.com/ansys/pre-commit-hooks
rev: v0.3.1
rev: v0.4.0
hooks:
- id: add-license-headers
args:
Expand All @@ -54,3 +54,7 @@ repos:
tests/test_reuse_files/bad_chars.py |
tests/test_reuse_files/index_error.scss
)$
- id: tech-review
args:
- --product=pre_commit_hooks
- --non_compliant_name
1 change: 1 addition & 0 deletions doc/changelog.d/194.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix semantic versioning check in tech-review hook
5 changes: 3 additions & 2 deletions src/ansys/pre_commit_hooks/tech_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,9 @@ def check_pyproject_toml(
try:
version = semver.Version.parse(project_version)
except ValueError:
is_compliant = False
print("Project version does not follow semantic versioning")
if not bool(re.match(r"^[0-9]+.[0-9]+.dev[0-9]+$", project_version)):
klmcadams marked this conversation as resolved.
Show resolved Hide resolved
is_compliant = False
print("Project version does not follow semantic versioning")

# Check the project author and maintainer names and emails match argument input
category, metadata = ["authors", "maintainers"], ["name", "email"]
Expand Down
20 changes: 20 additions & 0 deletions tests/test_tech_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,26 @@ def test_bad_version(tmp_path: pytest.TempPathFactory, capsys):
os.chdir(REPO_PATH)


@pytest.mark.tech_review
def test_dev_version(tmp_path: pytest.TempPathFactory, capsys):
"""Test the error message appears when the project does not use semantic versioning."""
tmp_path = tmp_path / "pytechreview"
setup_repo(tmp_path)

# Replace the version in the pyproject.toml file to be invalid
search = 'version = "0.1.0"'
replace = 'version = "11.1.dev1"'
replace_line(tmp_path, "pyproject.toml", search, replace)

assert hook.main() == 1

# Check error message is printed
output = capsys.readouterr()
assert "Project version does not follow semantic versioning" not in output.out

os.chdir(REPO_PATH)


@pytest.mark.tech_review
def test_bad_author_maint_name_email(tmp_path: pytest.TempPathFactory, capsys):
"""Test the error message appears when author and maintainers name and emails do not exist."""
Expand Down
Loading