Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scaffold/.go/.github/workflows/test-and-lint.yaml.tmplt
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ jobs:
- name: Lint with golangci-lint
uses: golangci/golangci-lint-action@v8
with:
version: "{% .GolangcilintVersion %}"
version: "{% .GolangcilintTag %}"
4 changes: 2 additions & 2 deletions scaffold/.go/.pre-commit-config.yaml.tmplt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
repos:
- repo: https://github.com/golangci/golangci-lint
rev: "{% .GolangcilintVersion %}"
rev: "{% .GolangcilintTag %}"
hooks:
- id: golangci-lint-config-verify
- id: golangci-lint-fmt
- id: golangci-lint-full

- repo: https://github.com/godaddy/tartufo
rev: "{% .TartufoVersion %}"
rev: "{% .TartufoTag %}"
hooks:
- id: tartufo
33 changes: 11 additions & 22 deletions scaffold/.python/.github/workflows/publish-docs.yaml.tmplt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
paths:
- "docs/**"
- "src/**.py"
- "poetry.lock"
- "pyproject.toml"
- "uv.lock"

workflow_dispatch:

Expand All @@ -31,34 +31,23 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Get poetry from cache
id: poetry-cache
uses: actions/cache@v4
- name: Set up Python
uses: actions/setup-python@v6
with:
path: ${{ github.workspace }}/pipx/venvs/poetry/**
key: default-branch-poetry-cache
python-version-file: "pyproject.toml"

- name: Install poetry if cache misses
if: ${{ steps.poetry-cache.outputs.cache-hit != 'true' }}
run: PIPX_HOME=$GITHUB_WORKSPACE/pipx pipx install poetry

- name: Add poetry executable to PATH
run: echo "$GITHUB_WORKSPACE/pipx/venvs/poetry/bin" >> $GITHUB_PATH

- name: Set up Python and cache poetry install
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: '{% .PythonVersion %}'
cache: 'poetry'
enable-cache: true

- name: Install dependencies with poetry
run: poetry install
- name: Install the project
run: uv sync --locked

- name: Make HTML
run: poetry run make clean && poetry run make html
working-directory: ./docs
run: uv run --directory=docs sphinx-build -M html . _build

- name: Setup Pages
uses: actions/configure-pages@v4
Expand Down
12 changes: 6 additions & 6 deletions scaffold/.python/.github/workflows/python-lint-on-pr.yaml.tmplt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- 'src/**.py'
- 'tests/**.py'
- 'pyproject.toml'
- 'poetry.lock'
- 'uv.lock'

workflow_call:

Expand All @@ -20,21 +20,21 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Set up Python
uses: actions/setup-python@v5
uses: actions/setup-python@v6
with:
python-version: "{% .PythonVersion %}"
python-version-file: "pyproject.toml"

- name: Install pre-commit
run: pip install pre-commit

- name: Cache pre-commit environments
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}

- name: Run pre-commit hooks
- name: Run pre-commit hooks
run: pre-commit run --show-diff-on-failure --color=never --all-files --hook-stage=pre-commit
36 changes: 14 additions & 22 deletions scaffold/.python/.github/workflows/unit-test.yaml.tmplt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ on:
paths:
- 'src/**.py'
- 'tests/**'
- 'poetry.lock'
- 'pyproject.toml'
- 'uv.lock'

pull_request:
paths:
- 'src/**.py'
- 'tests/**'
- 'poetry.lock'
- 'pyproject.toml'
- 'uv.lock'

workflow_call:

Expand All @@ -29,30 +31,20 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Get poetry from cache
id: poetry-cache
uses: actions/cache@v4
- name: Set up Python
uses: actions/setup-python@v6
with:
path: ${{ github.workspace }}/pipx/venvs/poetry/**
key: default-branch-poetry-cache
python-version-file: "pyproject.toml"

- name: Install poetry if cache misses
if: ${{ steps.poetry-cache.outputs.cache-hit != 'true' }}
run: PIPX_HOME=$GITHUB_WORKSPACE/pipx pipx install poetry

- name: Add poetry executable to PATH
run: echo "$GITHUB_WORKSPACE/pipx/venvs/poetry/bin" >> $GITHUB_PATH

- name: Set up Python and cache poetry install
uses: actions/setup-python@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
python-version: '{% .PythonVersion %}'
cache: 'poetry'
enable-cache: true

- name: Install dependencies with poetry
run: poetry install
- name: Install the project
run: uv sync --locked --no-group docs

- name: Run unit test
run: poetry run pytest
run: uv run pytest
3 changes: 0 additions & 3 deletions scaffold/.python/.gitignore.tmplt
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
.DS_Store
.python-version
**/*.whl
**/*.tar.gz
/docs/node_modules
/docs/_build
/poetry.toml
src/*.egg-info
/adhoc*.py
__pycache__
/.coverage
/poetry.toml
14 changes: 6 additions & 8 deletions scaffold/.python/.pre-commit-config.yaml.tmplt
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,26 @@ repos:
rev: "{% .BlackVersion %}"
hooks:
- id: black
language_version: python{% .PythonVersion %}

- repo: https://github.com/PyCQA/flake8
rev: "{% .Flake8Version %}"
hooks:
- id: flake8

- repo: https://github.com/kxue43/shell-cmd-on-change
rev: "1.2.0"
rev: "2.0.0"
hooks:
- id: shell-cmd-on-change
name: poetry-install
name: uv-sync
args:
- "--paths"
- "poetry.lock"
- "--command"
- "poetry sync"
- "-Ppyproject.toml"
- "-Puv.lock"
- "uv sync"
stages: [post-merge]
always_run: true
verbose: true

- repo: https://github.com/godaddy/tartufo
rev: "{% .TartufoVersion %}"
rev: "{% .TartufoTag %}"
hooks:
- id: tartufo
2 changes: 0 additions & 2 deletions scaffold/.python/poetry.toml.tmplt

This file was deleted.

90 changes: 44 additions & 46 deletions scaffold/.python/pyproject.toml.tmplt
Original file line number Diff line number Diff line change
@@ -1,72 +1,70 @@
[project]
name = "{% .ProjectName %}"

version = "0.1.0"

authors = [
{ name = "Ke Xue", email = "xueke.kent@gmail.com" },
]

description = "{% .Description %}"

classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]
requires-python = "~{% .PythonVersion %}"

requires-python = "~={% .PythonVersion %}.0"

dependencies = []

[tool.uv]
default-groups = [
"linting",
"test",
"docs",
]

[dependency-groups]
linting = [
"black=={% .BlackVersion %}", # This version must be the same as in `./.pre-commit-config.yaml`.
"flake8=={% .Flake8Version %}", # This version must be the same as in `./.pre-commit-config.yaml`.
"mypy~={% .MypyVersion %}",
]

test = [
"pytest~={% .PytestVersion %}",
"pytest-mock~={% .PytestMockVersion %}",
"pytest-cov~={% .PytestCovVersion %}",
]

docs = [
"sphinx~={% .SphinxVersion %}",
"sphinx-rtd-theme",
"sphinx-autodoc-typehints",
"sphinx-copybutton",
]

[tool.black]
line-length = 88
target-version = ["py{% .PythonVersion.NumsOnly %}"]

[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "--cov=src --cov-report term-missing"

[build-system]
requires = ["setuptools>=67", "wheel"]

build-backend = "setuptools.build_meta"

[tool.setuptools]
zip-safe = false

include-package-data = true

[tool.setuptools.packages.find]
where = ["src"]

[tool.setuptools.package-data]
{% .ProjectName | DashLower %} = ["py.typed"]

[tool.poetry]
packages = [{ include = "**/*", from = "src" }]

[tool.poetry.dependencies]
python = "~{% .PythonVersion %}"

[tool.poetry.group.develop]
optional = false

[tool.poetry.group.develop.dependencies]
ipykernel = "^{% .IPyKernelVersion %}"

[tool.poetry.group.linting]
optional = false

[tool.poetry.group.linting.dependencies]
black = "{% .BlackVersion %}" # This version must be the same as in `./.pre-commit-config.yaml`.
flake8 = "{% .Flake8Version %}" # This version must be the same as in `./.pre-commit-config.yaml`.
mypy = "^{% .MypyVersion %}"

[tool.poetry.group.test]
optional = false

[tool.poetry.group.test.dependencies]
pytest = "^{% .PytestVersion %}"
pytest-mock = "^{% .PytestMockVersion %}"
pytest-cov = "^{% .PytestCovVersion %}"

[tool.poetry.group.docs]
optional = false

[tool.poetry.group.docs.dependencies]
sphinx = "^{% .SphinxVersion %}"
sphinx-rtd-theme = "*"
sphinx-autodoc-typehints = "*"
sphinx-copybutton = "*"

[tool.black]
line-length = 88
target-version = ["py{% .PythonVersion.NumsOnly %}"]

[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "--cov=src --cov-report term-missing"
2 changes: 1 addition & 1 deletion scaffold/.python/tartufo.toml.tmplt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ regex = true
entropy = true

exclude-path-patterns = [
{path-pattern = 'poetry\.lock$', reason = 'Lock file with lots of digests'},
{path-pattern = 'uv\.lock$', reason = 'Lock file with lots of digests'},
{path-pattern = 'pyproject\.toml$', reason = 'Standard Python project config file'},
{path-pattern = 'tartufo\.toml$', reason = 'Tartufo config file'},
]
Expand Down
Loading