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
File renamed without changes.
7 changes: 0 additions & 7 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
<!---
Please write your PR name in the present imperative tense. Examples of that tense are:
"Fix issue in the dispatcher where…", "Improve our handling of…", etc.

For more information on Pull Requests, you can reference here:
https://success.vanillaforums.com/kb/articles/228-using-pull-requests-to-contribute
-->
## Describe your changes


Expand Down
100 changes: 100 additions & 0 deletions .github/workflows/check-pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Check-PR-Title

on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened

jobs:
title-check:
runs-on: ubuntu-latest
steps:
- name: Enforce imperative subject (heuristic)
uses: actions/github-script@v7
with:
script: |
const title = context.payload.pull_request.title;

// -----------------------------
// 1) Imperative heuristic
// -----------------------------
const bannedStarts = new Set([
"Added", "Adding", "Adds",
"Fixed", "Fixes", "Fixing",
"Updated", "Updating", "Updates",
"Changed", "Changing", "Changes",
"Removed", "Removing", "Removes",
"Refactored", "Refactoring",
"Improved", "Improving",
"Implemented", "Implementing", "Implements",
"Created", "Creating", "Creates",
"Renamed", "Renaming", "Renames",
"Moved", "Moving", "Moves",
"Deleted", "Deleting", "Deletes",
"Reverted", "Reverting", "Reverts",
"Bumped", "Bumping", "Bumps",
"Upgraded", "Upgrading", "Upgrades",
"Downgraded", "Downgrading", "Downgrades",
"Pinned", "Pinning", "Pins",
"Resolved", "Resolving", "Resolves",
"Corrected", "Correcting", "Corrects",
"Addressed", "Addressing", "Addresses",
"Patched", "Patching", "Patches",
"Cleaned", "Cleaning", "Cleans",
"Formatted", "Formatting", "Formats",
"Linted", "Linting", "Lints",
"Sorted", "Sorting", "Sorts",
"Documented", "Documenting", "Documents",
"Tested", "Testing", "Tests",
"Optimized", "Optimizing", "Optimizes",
"Enhanced", "Enhancing", "Enhances",
"Simplified", "Simplifying", "Simplifies",
"Adjusted", "Adjusting", "Adjusts",
"Modified", "Modifying", "Modifies",
]);

const firstWord = title.split(/\s+/)[0];
if (bannedStarts.has(firstWord)) {
core.setFailed(
`PR title subject should be present imperative. ` +
`Avoid "${firstWord} …". Example: "Add …", "Fix …", "Update …".`
);
}

// -----------------------------
// 2) Allow leading emojis, but:
// - Reject WIP prefixes
// - Require first "real" word to start uppercase
// -----------------------------
const trimmed = title.trim();

// Reject WIP at the start (optionally wrapped in [] or () and optionally followed by ":" or "-")
if (/^\s*[\[(]?\s*wip\s*[\])]?(\s*[:\-–—])?/i.test(trimmed)) {
core.setFailed(`PR title must not be WIP.`);
}

// Find the first letter-starting word, allowing leading non-letters (e.g., emojis, punctuation)
const match = trimmed.match(/[A-Za-z][A-Za-z0-9'’]*/);

if (!match) {
core.setFailed(`PR title must contain a word.`);
} else {
const firstRealWord = match[0];
const firstChar = firstRealWord[0];

if (firstChar !== firstChar.toUpperCase()) {
const suggested =
trimmed.replace(
firstRealWord,
firstChar.toUpperCase() + firstRealWord.slice(1)
);

core.setFailed(
`PR title must start with a capitalized word (emojis are fine). ` +
`Example: "${suggested}"`
);
}
}
2 changes: 1 addition & 1 deletion .github/workflows/format-and-fail.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"
python-version: "3.12"
- uses: pre-commit/action@v3.0.0
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.11', '3.12', '3.13' ]
python-version: [ '3.12', '3.13' ]
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: 0.5.7
version: 0.9.26

- name: Set up Python
run: uv python install ${{ matrix.python-version }}
Expand Down
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ repos:
- id: python-no-log-warn

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.11
rev: v0.14.14
hooks:
- id: ruff-check
types_or: [python,pyi]
args:
- --fix
- --target-version=py311
- --select=B,C,E,F,W,B9,I
- --target-version=py312
- --select=B,C,E,F,W,I,ERA,N,RUF
- --line-length=80
- --ignore=E203,E402,E501,E261
- --ignore=E261,E501
- id: ruff-format
types_or: [ python,pyi]
args:
- --target-version=py311
- --target-version=py312
- --line-length=80
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Here is some general information on Makefile's so that you can grow this out:
# https://www.gnu.org/software/make/manual/html_node/Introduction.html
.DEFAULT_GOAL := lint
.DEFAULT_GOAL := format

.PHONY: env
env:
uv venv

.PHONY: install
install:
uv pip install -r pyproject.toml
uv sync

.PHONY: create-requirements
create-requirements:
uv pip compile --generate-hashes pyproject.toml > requirements.txt

.PHONY: lint
lint: create-requirements
.PHONY: format
format: create-requirements
pre-commit run --all-files

.PHONY: test
Expand Down
33 changes: 24 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,47 @@
This repository is a template for a python 🐍 project using the `uv` container. The intent is to do all the basic
lifting for a python project so that people can hit the ground running with their ideas.

### To make this project your own
## Required Post-templating Changes
1. Create a new repository, [using this one as a template](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template).
2. Change the `project` folder name to the kebab-case name of your project.
3. Update the information in the `pyproject.toml` file with your project's and your personal information.
4. Update the information in the `CODEOWNERS` file so that it uses your GitHub ID and the kebab-case name of your project folder.

### 🐍 by Default (Feel free to delete this after creating your project)
## Default 🐍 Packages
- [pre-commit](https://pre-commit.com/): This serves as the codebase formatter and linter.
- [requests](https://requests.readthedocs.io/en/latest/): This is the project's means of communicating with external APIs.
- [responses](https://github.com/getsentry/responses): This is used in conjunction with Pytest and Requests to mock API calls in the test module.

### Project Requirements
- `uv` version: `0.5.7`
## Pull Request Requirements

If any of the following conditions are not met the respective GitHub Action will
fail, and you will not be able to merge. Please do not mark your PR as `Open` for
review until all GitHub Actions are passing.

- All PR titles must be in the present imperative tense.
- **Examples:** "Fix issue in the dispatcher where…", "Improve our handling of…",
- For more information on Pull Requests, you can reference here: [PRs to Contribute](https://success.vanillaforums.com/kb/articles/228-using-pull-requests-to-contribute).
- Code in PRs must be properly formatted.

If your PR is not ready for review for whatever reason, please mark it as a
draft: [PR Draft](https://github.blog/news-insights/product-news/introducing-draft-pull-requests/).

## Project Requirements
- `uv` version: `0.9.26`
- Download at: [link](https://docs.astral.sh/uv/).

### Instructions to Run the Project
1. Go into the base directory of the repository and type `make env` or `uv env` into the terminal.
2. Use the `make run` command.
## Instructions to Run the Project
1. Go into the base directory of the repository and type `make env` into the terminal.
2. Enter `source .venv/bin/activate` to access the environment.
3. Use the `make run` command.

### Technical Notes
## Technical Notes
- Any modules should be added via the `uv add [module]` command.
- Example: `uv add pre-commit`

## Standard Commands
- `make create-requirements`: Creates and/or updates the `requirements.txt` file.
- `make env`: Creates a `uv` virtual environment.
- `make lint`: Runs `pre-commit`.
- `make format`: Runs `pre-commit`.
- `make run`: Runs the `main` function in the `project` folder.
- `make test`: Runs test cases in the `tests` directory.
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ filelock==3.20.3 \
--hash=sha256:18c57ee915c7ec61cff0ecf7f0f869936c7c30191bb0cf406f1341778d0834e1 \
--hash=sha256:4b0dda527ee31078689fc205ec4f1c1bf7d56cf88b6dc9426c4f230e46c2dce1
# via virtualenv
identify==2.6.15 \
--hash=sha256:1181ef7608e00704db228516541eb83a88a9f94433a8c80bb9b5bd54b1d81757 \
--hash=sha256:e4f4864b96c6557ef2a1e1c951771838f4edc9df3a72ec7118b338801b11c7bf
identify==2.6.16 \
--hash=sha256:391ee4d77741d994189522896270b787aed8670389bfd60f326d677d64a6dfb0 \
--hash=sha256:846857203b5511bbe94d5a352a48ef2359532bc8f6727b5544077a0dcfb24980
# via pre-commit
idna==3.11 \
--hash=sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea \
Expand All @@ -147,9 +147,9 @@ nodeenv==1.10.0 \
--hash=sha256:5bb13e3eed2923615535339b3c620e76779af4cb4c6a90deccc9e36b274d3827 \
--hash=sha256:996c191ad80897d076bdfba80a41994c2b47c68e224c542b48feba42ba00f8bb
# via pre-commit
packaging==25.0 \
--hash=sha256:29572ef2b1f17581046b3a2227d5c611fb25ec70ca1ba8554b24b0e69331a484 \
--hash=sha256:d443872c98d677bf60f6a1f2f8c1cb748e8fe762d2bf9d3148b5599295b0fc4f
packaging==26.0 \
--hash=sha256:00243ae351a257117b6a241061796684b084ed1c516a08c48a3f7e147a9d80b4 \
--hash=sha256:b36f1fef9334a5588b4166f8bcd26a14e521f2b55e6b9de3aaa80d3ff7a37529
# via pytest
platformdirs==4.5.1 \
--hash=sha256:61d5cdcc6065745cdd94f0f878977f8de9437be93de97c1c12f853c9c0cdcbda \
Expand Down