From b7eac9cb4ca86eca9423db091dccb791b3fcb57b Mon Sep 17 00:00:00 2001 From: confarg <280620574+confarg@users.noreply.github.com> Date: Mon, 8 Jun 2026 21:30:43 +0200 Subject: [PATCH] ci: Add linter --- .github/workflows/ci-check-pr-title.yml | 18 +++++++ .github/workflows/ci-lint.yml | 21 +++++++++ .github/workflows/ci-tests.yml | 15 ++++++ .github/workflows/pr-title.yml | 18 ------- .github/workflows/publish.yml | 32 ------------- .github/workflows/release-publish.yml | 32 +++++++++++++ .github/workflows/tests.yml | 13 ------ .pre-commit-config.yaml | 62 ++++++++++++++----------- 8 files changed, 120 insertions(+), 91 deletions(-) create mode 100644 .github/workflows/ci-check-pr-title.yml create mode 100644 .github/workflows/ci-lint.yml create mode 100644 .github/workflows/ci-tests.yml delete mode 100644 .github/workflows/pr-title.yml delete mode 100644 .github/workflows/publish.yml create mode 100644 .github/workflows/release-publish.yml delete mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/ci-check-pr-title.yml b/.github/workflows/ci-check-pr-title.yml new file mode 100644 index 0000000..dd67679 --- /dev/null +++ b/.github/workflows/ci-check-pr-title.yml @@ -0,0 +1,18 @@ +name: CI / Check PR Title + +on: + pull_request: + branches: [master] + types: [opened, edited] + +permissions: + pull-requests: read + +jobs: + validate: + name: Validate PR title + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci-lint.yml b/.github/workflows/ci-lint.yml new file mode 100644 index 0000000..c526e4b --- /dev/null +++ b/.github/workflows/ci-lint.yml @@ -0,0 +1,21 @@ +name: CI / Lint + +on: + pull_request: + branches: [master] + types: [opened, synchronize] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v5 + - run: | + git fetch --depth=1 origin ${{ github.event.pull_request.base.sha }} + git fetch --depth=1 origin ${{ github.event.pull_request.head.sha }} + uv run pre-commit run \ + --from-ref ${{ github.event.pull_request.base.sha }} \ + --to-ref ${{ github.event.pull_request.head.sha }} \ + --show-diff-on-failure \ + --color always diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml new file mode 100644 index 0000000..163d378 --- /dev/null +++ b/.github/workflows/ci-tests.yml @@ -0,0 +1,15 @@ +name: CI / Tests + +on: + pull_request: + branches: [master] + types: [opened, synchronize] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v5 + - run: uv lock --check + - run: uv run pytest ./tests/ diff --git a/.github/workflows/pr-title.yml b/.github/workflows/pr-title.yml deleted file mode 100644 index 51f831e..0000000 --- a/.github/workflows/pr-title.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: PR Title - -on: - pull_request: - types: [opened, edited, reopened, synchronize] - branches: [master] - -permissions: - pull-requests: read - -jobs: - validate: - name: Validate PR title - runs-on: ubuntu-latest - steps: - - uses: amannn/action-semantic-pull-request@v5 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index d24f045..0000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Publish to PyPI - -on: - release: - types: [published] - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v5 - - run: uv build - - uses: actions/upload-artifact@v4 - with: - name: dist - path: dist/ - - publish: - needs: build - runs-on: ubuntu-latest - environment: pypi - permissions: - id-token: write - steps: - - uses: actions/download-artifact@v4 - with: - name: dist - path: dist/ - - uses: pypa/gh-action-pypi-publish@release/v1 - with: - attestations: true diff --git a/.github/workflows/release-publish.yml b/.github/workflows/release-publish.yml new file mode 100644 index 0000000..bcb6bf0 --- /dev/null +++ b/.github/workflows/release-publish.yml @@ -0,0 +1,32 @@ +name: Release / Publish to PyPI + +on: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: astral-sh/setup-uv@v5 + - run: uv build + - uses: actions/upload-artifact@v4 + with: + name: dist + path: dist/ + + publish: + needs: build + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + name: dist + path: dist/ + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + attestations: true diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 528e0d2..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Tests -on: - pull_request: - branches: - - master - types: [opened, reopened, synchronize, ready_for_review] -jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v5 - - run: uv run pytest ./tests/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 14de8cc..58313df 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,28 +1,34 @@ -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v6.0.0 - hooks: - - id: check-added-large-files - args: ['--maxkb=128'] - - id: check-ast - - id: check-case-conflict - - id: check-illegal-windows-names - - id: check-json - - id: check-merge-conflict - - id: check-toml - - id: check-yaml - - id: debug-statements - - id: detect-private-key - - id: end-of-file-fixer - - id: mixed-line-ending - - id: no-commit-to-branch - args: [--branch, master] - - id: trailing-whitespace - args: [--markdown-linebreak-ext=md] - - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.13 - hooks: - - id: ruff-check - args: [--fix] - - id: ruff-format +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # v6.0.0 + hooks: + - id: check-added-large-files + args: [--maxkb=128] + - id: check-ast + - id: check-case-conflict + - id: check-illegal-windows-names + - id: check-json + - id: check-merge-conflict + - id: check-toml + - id: check-yaml + - id: debug-statements + - id: detect-private-key + - id: end-of-file-fixer + - id: mixed-line-ending + - id: no-commit-to-branch + args: [--branch, master] + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + +- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks + rev: 4380fbb73a154b5f5624794c1c78d9719ccc860f # v2.16.0 + hooks: + - id: pretty-format-yaml + args: [--autofix, --indent, '2'] + +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: 22f0422809455ec89ffdcf5a00170ba816e42ddb # v0.15.16 + hooks: + - id: ruff-check + args: [--fix] + - id: ruff-format