Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 19 additions & 7 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,32 @@ name: Run test
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
pytest:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v6
with:
python-version: '3.10'
- name: Install dependencies
run: uv sync --all-groups
- name: Run pytest
shell: bash
run: |
python3 -m venv venv
source venv/bin/activate
pip install '.[dev]'
coverage run -m pytest
coverage report -m --fail-under=95
run: uv run pytest --cov=git_hooks --cov-report=xml:coverage.xml --durations=10
- name: Get Cover
uses: orgoro/coverage@v3.2
if: ${{ github.event_name == 'pull_request' }}
with:
coverageFile: coverage.xml
token: ${{ secrets.GITHUB_TOKEN }}
14 changes: 5 additions & 9 deletions git_hooks/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,18 @@

commit_type_regex: str = f"(?:{'|'.join(commit_types.keys())})"
teams: list[str] = [
"ABN",
"ATL",
"CET",
"DEL",
"FE",
"INF",
"KNA",
"L2",
"NOR",
"T",
"L2",
]
linear_ref: str = (
"(?:"
f"{'|'.join(t for t in teams)}"
"|"
r"[A-Z]{3}"
"|"
f"{'|'.join(t.lower() for t in teams)}"
"|"
r"[a-z]{3}"
")-[0-9]{1,5}"
)
valid_commit_regex: str = (
Expand Down
48 changes: 23 additions & 25 deletions git_hooks/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ def test_commit_type_regex(commit_type: str):
"issue",
[
"T-1234",
"KNA-1234",
"CET-1234",
"NOR-1234",
"L2-1234",
"DEL-14",
"ABC-1234",
"xyz-1234",
"T-1",
"L2-99999",
],
)
def test_linear_ref(issue: str):
Expand All @@ -37,12 +37,11 @@ def test_linear_ref(issue: str):
"commit",
[
"T-1234/feat: ",
"T-1234/fix: ",
"KNA-1234/hotfix: ",
"CET-1234/docs: ",
"NOR-1234/style: ",
"L2-1234/test: ",
"DEL-14/refactor: "
"L2-1234/fix: ",
"ABC-1234/hotfix: ",
"xyz-1234/docs: ",
"T-1/style: ",
"L2-99999/test: ",
],
)
def test_valid_commit_regex(commit: str):
Expand All @@ -53,11 +52,11 @@ def test_valid_commit_regex(commit: str):
"branch",
[
"hotfix/T-1234-fix-something",
"hotfix/brtknr/KNA-1234-add-something",
"feat/CET-1234-fix-something",
"bharat/L2-1234-add-something",
"brtkwr/cet-281-fix-company-search-gb-bucket-permission",
"shelmig/del-13-update-credentials",
"feat/L2-1234-add-something",
"fix/ABC-1234-fix-something",
"bharat/xyz-1234-add-something",
"brtkwr/abc-281-fix-company-search-gb-bucket-permission",
"shelmig/xyz-13-update-credentials",
],
)
def test_branch_regex(branch: str):
Expand Down Expand Up @@ -87,12 +86,11 @@ def test_commit_msg_title_regex(commit_msg: str):
"commit_msg",
[
"T-1234/feat: add something",
"KNA-1234/fix: fix something",
"CET-1234/hotfix: fix something",
"NOR-1234/docs: add something",
"L2-1234/style add something",
"T-1234/test: add something",
"DEL-1234/test: add something",
"L2-1234/fix: fix something",
"ABC-1234/hotfix: fix something",
"xyz-1234/docs: add something",
"T-1/style add something",
"L2-99999/test: add something",
],
)
def test_commit_msg_issue_regex(commit_msg: str):
Expand All @@ -105,11 +103,11 @@ def test_commit_msg_issue_regex(commit_msg: str):
"issue",
[
"T-1234",
"KNA-1234",
"CET-1234",
"NOR-1234",
"L2-1234",
"DEL-1234",
"ABC-1234",
"xyz-1234",
"T-1",
"L2-99999",
],
)
def test_issue_regex(issue: str):
Expand Down
41 changes: 25 additions & 16 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
[project]
name = "git-hooks"
version = "24.11.29"
dependencies = [
"gql[requests]==3.4.1",
]
dependencies = ["gql[requests]==3.4.1"]
requires-python = ">=3.10"

[tool.uv]
package = true


[project.optional-dependencies]
dev = [
[dependency-groups]
test = [
"bumpver==2022.1119",
"pytest==6.2.5",
"coverage==7.5.3",
"pytest-cov>=6.1.1",
"pre-commit==3.7.1",
]

Expand All @@ -26,13 +29,19 @@ tag = true
push = true

[tool.bumpver.file_patterns]
"pyproject.toml" = [
'^version = "{version}"',
'^current_version = "{version}"',
]
"README.md" = [
'rev: {version}',
]
"git_hooks/commit_msg.py" = [
'two-inc/git-hooks/blob/{version}/README.md'
]
"pyproject.toml" = ['^version = "{version}"', '^current_version = "{version}"']
"README.md" = ['rev: {version}']
"git_hooks/commit_msg.py" = ['two-inc/git-hooks/blob/{version}/README.md']

[tool.coverage.run]
branch = true

[tool.coverage.report]
show_missing = true
skip_covered = false
skip_empty = false
# Always show the report by default
fail_under = 0

[tool.pytest.ini_options]
addopts = "--cov=git_hooks --cov-report=term"
Loading