From ad6b4e07073a0e1ce9da962b273cbf6fd131eaba Mon Sep 17 00:00:00 2001 From: Aaron <7063649+ahcode0919@users.noreply.github.com> Date: Wed, 4 Nov 2026 15:57:34 -0800 Subject: [PATCH] Add Gitleaks --- .github/workflows/python.yml | 15 +++++++++++++-- Brewfile | 3 ++- README.md | 18 +++++++++++------- justfile | 4 ++++ prek.toml | 7 +++++++ pyproject.toml | 4 ++++ 6 files changed, 41 insertions(+), 10 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 870ff75..e527eb9 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -6,18 +6,29 @@ on: pull_request: branches: [ main ] +permissions: + contents: read + pull-requests: read + jobs: code-check-and-unit-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 + with: + fetch-depth: 0 - name: Setup just uses: extractions/setup-just@v3 - name: Install uv - uses: astral-sh/setup-uv@v1 + uses: astral-sh/setup-uv@v7 with: enable-cache: true - version: latest + version: ">=0.11,<0.12" + - name: Check gitleaks + uses: gitleaks/gitleaks-action@v3 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITLEAKS_ENABLE_COMMENTS: false - name: Setup environment run: | just sync diff --git a/Brewfile b/Brewfile index f58ecdf..3448ca2 100644 --- a/Brewfile +++ b/Brewfile @@ -1,2 +1,3 @@ +brew "gitleaks" brew "just" -brew "uv" \ No newline at end of file +brew "uv" diff --git a/README.md b/README.md index 248a22f..f5a8bb6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -# Python Project Template ![](https://github.com/ahcode0919/python-project-template/actions/workflows/python.yml/badge.svg?branch=main) +# Python Project Template + +[![CI](https://github.com/ahcode0919/python-project-template/actions/workflows/python.yml/badge.svg?branch=main)](https://github.com/ahcode0919/python-project-template/actions/workflows/python.yml) +[![gitleaks](https://img.shields.io/badge/protected%20by-gitleaks-blue)](https://github.com/gitleaks/gitleaks) Baseline Python project template @@ -23,12 +26,13 @@ Note: Project uses `uv` and `just` to manage project configuration and commands ## Project Commands -* Local - * `just lint` - lint project files -* Dev container - * `just lint` - lint and stylecheck project files -* Run unit tests: `just test` -* Install dependency: `uv add {package}` +* `just sync` - sync project dependencies (all groups) +* `just lint` - type check, lint, format, and spellcheck project files (applies fixes) +* `just ci-lint` - run the same checks without modifying files (used in CI) +* `just test` - run unit tests +* `just prek` - run pre-commit hooks via prek +* `just git-leaks` - scan staged changes for secrets with gitleaks +* `uv add {package}` - install a dependency ## Usage diff --git a/justfile b/justfile index 5e36771..87b89ff 100644 --- a/justfile +++ b/justfile @@ -3,11 +3,15 @@ ci-lint: uv run ruff check . uv run ruff format --check . uv run codespell +git-leaks: + gitleaks git --pre-commit --staged --redact lint: uv run ty check uv run ruff check . --fix uv run ruff format . uv run codespell +prek: + uv run prek sync: uv sync --all-groups test: diff --git a/prek.toml b/prek.toml index e09c21e..3f9dd3d 100644 --- a/prek.toml +++ b/prek.toml @@ -31,5 +31,12 @@ hooks = [ language = "system", entry = "just test", pass_filenames = false + }, + { + id = "git-leaks", + name = "git leaks", + language = "system", + entry = "gitleaks git --pre-commit --staged --redact", + pass_filenames = false } ] diff --git a/pyproject.toml b/pyproject.toml index ed42e13..c30e2cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,6 +3,7 @@ name = "example" description = "example" version = "0.0.1" requires-python = ">=3.14" + dependencies = [] [build-system] @@ -37,3 +38,6 @@ extend-ignore = ["E501"] # Line too long (handled by formatter) [tool.ruff.format] quote-style = "double" + +[tool.uv] +required-version = ">=0.11,<0.12"