diff --git a/.github/workflows/check-mergeable.yml b/.github/workflows/check-mergeable.yml new file mode 100644 index 0000000..b76fca8 --- /dev/null +++ b/.github/workflows/check-mergeable.yml @@ -0,0 +1,16 @@ +--- +name: Block PR Merge If BLOCK-MERGE Label Exists + +on: + pull_request: + types: [labeled, unlabeled, synchronize, opened, reopened] + +jobs: + fail-by-label: + if: contains(join(github.event.pull_request.labels.*.name, ' '), 'Block Merge') + runs-on: ubuntu-latest + steps: + - name: Fail if PR is labeled "Block Merge" + run: |- + echo "❌ This PR is labeled as 'Block Merge' and cannot be merged." + exit 1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0b8383c..ef16765 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: check-useless-excludes - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v5.0.0 hooks: - id: trailing-whitespace - id: end-of-file-fixer @@ -21,17 +21,22 @@ repos: args: ['-f=lf'] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.8 + rev: v0.9.4 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.11.2 + rev: v1.15.0 hooks: - id: mypy + - repo: https://github.com/jendrikseipp/vulture + rev: v2.14 + hooks: + - id: vulture + - repo: https://github.com/espressif/conventional-precommit-linter rev: v1.10.0 hooks: @@ -39,14 +44,14 @@ repos: stages: [commit-msg] - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.1 hooks: - id: codespell args: ['--write-changes'] additional_dependencies: [tomli] - repo: https://github.com/executablebooks/mdformat - rev: 0.7.17 + rev: 0.7.22 hooks: - id: mdformat args: [--number] diff --git a/Justfile b/Justfile index 04beff4..7e1d5ed 100644 --- a/Justfile +++ b/Justfile @@ -5,9 +5,6 @@ # This setting will allow passing arguments through to recipes set positional-arguments -# Parse current version from pyproject.toml -current_version := `grep -Po 'version\s*=\s*"\K[^"]*' pyproject.toml | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+'` - # Custom git log format gitstyle := '%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' @@ -17,58 +14,33 @@ gitstyle := '%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s @default: just --list - # .Edit this Justfile @edit-just: $EDITOR ./Justfile - -# PROJECT: Install development environment +# Install development environment @install: pip install --require-virtualenv -e '.[dev,test]' pip install --require-virtualenv --upgrade pip -# PROJECT: Install and autoupdate pre-commit hooks +# Install and autoupdate pre-commit hooks @install-pre-commit: pre-commit install git add .pre-commit-config.yaml pre-commit autoupdate git reset HEAD -- -# PROJECT: Re-compile requirements.txt +# Re-compile requirements.txt @lock-requirements: pip-compile --strip-extras --output-file=requirements.txt pyproject.toml > /dev/null -# PROJECT: Release version info, commits since last release) -@version: - cz bump --dry-run | grep -E 'change\(bump\)|tag to create|increment detected'; \ - echo "\nCommits since last release:"; \ - git log -n 30 --graph --pretty="{{gitstyle}}" v{{current_version}}..HEAD - - -# TESTS: Run local tests with pytest (config in pyproject.toml) +# Run local tests with pytest (config in pyproject.toml) @test: python -m pytest - -# DOCKER: Build Docker image -docker-build: - docker build -t espressif/sample-project:latest . - - -# DOCKER: Run in Docker container -docker-run: - docker run espressif/sample-project - - -# Build and run Docker -docker: - just docker-build - just docker-run - -# PROJECT: Remove caches, builds, reports and other generated files +# Remove caches, builds, reports and other generated files @clean: rm -rf \ dist \ @@ -80,23 +52,3 @@ docker: .coverage* \ .ruff_cache \ : - - -# GIT: Revert the last commit - keeping changes staged -@uncommit: - git reset --soft HEAD~1 - - -# GIT: Fix failed commit message -@recommit: - git commit --edit --file=$(git rev-parse --git-dir)/COMMIT_EDITMSG - - -# GIT: Show commits only on current branch -@branch-commits base="v1": - if git rev-parse --verify "{{base}}" > /dev/null 2>&1; then \ - git log --first-parent --no-merges --graph --pretty="{{gitstyle}}" {{base}}..HEAD; \ - else \ - echo 'E: Provide base (target) branch as argument to `just branch-commits `' >&2; \ - exit 128; \ - fi diff --git a/pyproject.toml b/pyproject.toml index f3c3d75..36018ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,21 +42,29 @@ extend-exclude = ["tests/"] format.quote-style = "single" line-length = 120 + lint.exclude = ["tests/**/*"] lint.ignore = ["S603", "S607"] lint.isort.force-single-line = true lint.isort.lines-between-types = 1 - lint.select = ["B", "C4", "C901", "E", "F", "I", "N", "PL", "S", "UP", "W"] + lint.select = ["A", "B", "C4", "C901", "E", "F", "I", "N", "PL", "S", "UP", "W"] [tool.mypy] disallow_incomplete_defs = true disallow_untyped_defs = false exclude = ["^__init__.py$", "^build/.*", "^dist/.*", "^docs/.*", "^tests/.*"] ignore_missing_imports = true - packages = "sample_python_app" + packages = "sync_jira_actions" pretty = true python_version = "3.11" warn_return_any = true + [tool.vulture] + make_whitelist = true + min_confidence = 80 + paths = ["sync_jira_actions"] + sort_by_size = true + verbose = true + [tool.commitizen] annotated_tag = true bump_message = 'change(bump): [skip-ci] release $current_version → $new_version' @@ -83,4 +91,4 @@ [tool.coverage] run.branch = true run.parallel = true - run.source = ["sample_python_app"] + run.source = ["sync_jira_actions"] diff --git a/taplo.toml b/taplo.toml index f3ca0ef..4ab9b81 100644 --- a/taplo.toml +++ b/taplo.toml @@ -1,7 +1,3 @@ -# Configuration file for Taplo, taplo pre-commit hook and VS Cooe extension Even Better TOML -# TODO: This config needs to be in this config file, until closing: https://github.com/tamasfe/taplo/issues/603 (pyproject.toml support) -# TODO: Pre-commit hook 'taplo-format' is now excluded in Gitlab CI job 'pre-commit-mr', until closing: https://github.com/tamasfe/taplo/pull/659 (Alpine Linux - MUSL image support) - # General rules for all TOML files, if not specified otherwise exclude = ["**/.venv/**", "**/node_modules/**", "**/venv/**", "tests/**"] include = ["**/*.toml"]