diff --git a/ops/__init__.py b/.github/scripts/__init__.py similarity index 100% rename from ops/__init__.py rename to .github/scripts/__init__.py diff --git a/ops/ci-checks.sh b/.github/scripts/ci-checks.sh similarity index 81% rename from ops/ci-checks.sh rename to .github/scripts/ci-checks.sh index 838ebe5..77f962d 100755 --- a/ops/ci-checks.sh +++ b/.github/scripts/ci-checks.sh @@ -15,4 +15,4 @@ hatch fmt echo SUCCESS: linting/fmt # commit message validation -python ops/lintcommit.py +hatch run python .github/scripts/lintcommit.py diff --git a/ops/lintcommit.py b/.github/scripts/lintcommit.py similarity index 99% rename from ops/lintcommit.py rename to .github/scripts/lintcommit.py index 3986427..37f0d51 100644 --- a/ops/lintcommit.py +++ b/.github/scripts/lintcommit.py @@ -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 diff --git a/ops/parse_sdk_branch.py b/.github/scripts/parse_sdk_branch.py old mode 100755 new mode 100644 similarity index 100% rename from ops/parse_sdk_branch.py rename to .github/scripts/parse_sdk_branch.py diff --git a/ops/tests/__init__.py b/.github/scripts/tests/__init__.py similarity index 100% rename from ops/tests/__init__.py rename to .github/scripts/tests/__init__.py diff --git a/ops/tests/test_lintcommit.py b/.github/scripts/tests/test_lintcommit.py similarity index 96% rename from ops/tests/test_lintcommit.py rename to .github/scripts/tests/test_lintcommit.py index c7b0f04..93d8670 100644 --- a/ops/tests/test_lintcommit.py +++ b/.github/scripts/tests/test_lintcommit.py @@ -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 @@ -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) diff --git a/ops/tests/test_parse_sdk_branch.py b/.github/scripts/tests/test_parse_sdk_branch.py old mode 100755 new mode 100644 similarity index 100% rename from ops/tests/test_parse_sdk_branch.py rename to .github/scripts/tests/test_parse_sdk_branch.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34843fd..0a89a4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/test-parser.yml b/.github/workflows/test-parser.yml index ac8729f..4d6249a 100644 --- a/.github/workflows/test-parser.yml +++ b/.github/workflows/test-parser.yml @@ -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 @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dfd80e9..8a65b26 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,7 +27,7 @@ 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 ``` This script also validates your commit messages against the [Conventional Commits](https://www.conventionalcommits.org/) format. @@ -35,7 +35,7 @@ Commit all your changes before you run the check. If your working directory is d You can also run the commit message check independently: ``` -python ops/lintcommit.py +hatch run python .github/scripts/lintcommit.py ``` ## Coding Standards