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
File renamed without changes.
2 changes: 1 addition & 1 deletion ops/ci-checks.sh → .github/scripts/ci-checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ hatch fmt
echo SUCCESS: linting/fmt

# commit message validation
python ops/lintcommit.py
hatch run python .github/scripts/lintcommit.py
2 changes: 1 addition & 1 deletion ops/lintcommit.py → .github/scripts/lintcommit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# To run tests:
#
# python -m pytest ops/tests/test_lintcommit.py
# python -m pytest .github/scripts/tests/test_lintcommit.py

from __future__ import annotations

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

from __future__ import annotations

import os
import sys
from subprocess import CompletedProcess
from unittest.mock import patch

sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))

import pytest

from ops.lintcommit import lint_range, validate_message, validate_subject
from lintcommit import lint_range, validate_message, validate_subject


# region validate_subject: valid subjects
Expand Down Expand Up @@ -237,7 +241,7 @@ def test_lint_range_git_failure(mock_run) -> None:
@patch("subprocess.run")
def test_lint_range_dirty_worktree_skips(mock_run) -> None:
"""When skip_dirty_check=False and worktree is dirty, validation is skipped."""
mock_run.return_value = _completed(stdout=" M ops/lintcommit.py\n")
mock_run.return_value = _completed(stdout=" M .github/scripts/lintcommit.py\n")

result = lint_range("origin/main..HEAD", skip_dirty_check=False)

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
with:
python-version: "3.12"
- name: Lint commit messages
run: python ops/lintcommit.py --range "origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.sha }}"
run: python .github/scripts/lintcommit.py --range "origin/${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.sha }}"

build:
runs-on: ubuntu-latest
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/test-parser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ name: Test Parser
on:
pull_request:
paths:
- 'ops/parse_sdk_branch.py'
- 'ops/tests/**'
- '.github/scripts/parse_sdk_branch.py'
- '.github/scripts/tests/**'
push:
branches: [ main ]
paths:
- 'ops/parse_sdk_branch.py'
- 'ops/tests/**'
- '.github/scripts/parse_sdk_branch.py'
- '.github/scripts/tests/**'

permissions:
contents: read
Expand All @@ -21,4 +21,4 @@ jobs:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Run parser tests
run: python ops/tests/test_parse_sdk_branch.py
run: python .github/scripts/tests/test_parse_sdk_branch.py
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ hatch fmt

There is a convenience script for the above that you can run from the root of the repo as you prepare your PR:
```
ops/ci-checks.sh
.github/scripts/ci-checks.sh
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious if we have git hook for this

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No git hook currently. The linter runs in CI on PRs and locally via ci-checks.sh. We could add a commit-msg hook as a follow-up if that'd be useful.

```

This script also validates your commit messages against the [Conventional Commits](https://www.conventionalcommits.org/) format.
Commit all your changes before you run the check. If your working directory is dirty the script will skip commit message validation with a warning.

You can also run the commit message check independently:
```
python ops/lintcommit.py
hatch run python .github/scripts/lintcommit.py
```

## Coding Standards
Expand Down
Loading