Skip to content

Commit ad6b4e0

Browse files
committed
Add Gitleaks
1 parent e9d0397 commit ad6b4e0

6 files changed

Lines changed: 41 additions & 10 deletions

File tree

‎.github/workflows/python.yml‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,29 @@ on:
66
pull_request:
77
branches: [ main ]
88

9+
permissions:
10+
contents: read
11+
pull-requests: read
12+
913
jobs:
1014
code-check-and-unit-test:
1115
runs-on: ubuntu-latest
1216
steps:
1317
- uses: actions/checkout@v7
18+
with:
19+
fetch-depth: 0
1420
- name: Setup just
1521
uses: extractions/setup-just@v3
1622
- name: Install uv
17-
uses: astral-sh/setup-uv@v1
23+
uses: astral-sh/setup-uv@v7
1824
with:
1925
enable-cache: true
20-
version: latest
26+
version: ">=0.11,<0.12"
27+
- name: Check gitleaks
28+
uses: gitleaks/gitleaks-action@v3
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
GITLEAKS_ENABLE_COMMENTS: false
2132
- name: Setup environment
2233
run: |
2334
just sync

‎Brewfile‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
brew "gitleaks"
12
brew "just"
2-
brew "uv"
3+
brew "uv"

‎README.md‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
# Python Project Template ![](https://github.com/ahcode0919/python-project-template/actions/workflows/python.yml/badge.svg?branch=main)
1+
# Python Project Template
2+
3+
[![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)
4+
[![gitleaks](https://img.shields.io/badge/protected%20by-gitleaks-blue)](https://github.com/gitleaks/gitleaks)
25

36
Baseline Python project template
47

@@ -23,12 +26,13 @@ Note: Project uses `uv` and `just` to manage project configuration and commands
2326

2427
## Project Commands
2528

26-
* Local
27-
* `just lint` - lint project files
28-
* Dev container
29-
* `just lint` - lint and stylecheck project files
30-
* Run unit tests: `just test`
31-
* Install dependency: `uv add {package}`
29+
* `just sync` - sync project dependencies (all groups)
30+
* `just lint` - type check, lint, format, and spellcheck project files (applies fixes)
31+
* `just ci-lint` - run the same checks without modifying files (used in CI)
32+
* `just test` - run unit tests
33+
* `just prek` - run pre-commit hooks via prek
34+
* `just git-leaks` - scan staged changes for secrets with gitleaks
35+
* `uv add {package}` - install a dependency
3236

3337
## Usage
3438

‎justfile‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ ci-lint:
33
uv run ruff check .
44
uv run ruff format --check .
55
uv run codespell
6+
git-leaks:
7+
gitleaks git --pre-commit --staged --redact
68
lint:
79
uv run ty check
810
uv run ruff check . --fix
911
uv run ruff format .
1012
uv run codespell
13+
prek:
14+
uv run prek
1115
sync:
1216
uv sync --all-groups
1317
test:

‎prek.toml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,12 @@ hooks = [
3131
language = "system",
3232
entry = "just test",
3333
pass_filenames = false
34+
},
35+
{
36+
id = "git-leaks",
37+
name = "git leaks",
38+
language = "system",
39+
entry = "gitleaks git --pre-commit --staged --redact",
40+
pass_filenames = false
3441
}
3542
]

‎pyproject.toml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = "example"
33
description = "example"
44
version = "0.0.1"
55
requires-python = ">=3.14"
6+
67
dependencies = []
78

89
[build-system]
@@ -37,3 +38,6 @@ extend-ignore = ["E501"] # Line too long (handled by formatter)
3738

3839
[tool.ruff.format]
3940
quote-style = "double"
41+
42+
[tool.uv]
43+
required-version = ">=0.11,<0.12"

0 commit comments

Comments
 (0)