Skip to content

Commit 56008d3

Browse files
committed
feat: Update entire template setup
* Update python version * Use `poetry` as package manager * Use ruff as linter and formatter * Add more pre-commit hooks * Add semantic-release action * Add makefile BREAKING CHANGE: Re-write entire template repository.
1 parent aa5afb5 commit 56008d3

27 files changed

+669
-273
lines changed

.github/dependabot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
version: 2
6+
updates:
7+
- package-ecosystem: "pip" # See documentation for possible values
8+
directory: "/" # Location of package manifests
9+
schedule:
10+
interval: "weekly"
11+
- package-ecosystem: "docker" # See documentation for possible values
12+
directory: "/" # Location of package manifests
13+
schedule:
14+
interval: "weekly"

.github/pull_request_template.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ _<Problem this PR solves>_
55
# Validate
66

77
_<How can the changes be validated?>_
8-

.github/stale.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

.github/workflows/black.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/codeql-analysis.yml

Lines changed: 0 additions & 72 deletions
This file was deleted.

.github/workflows/pre-commit.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: pre-commit
2+
on:
3+
pull_request:
4+
push:
5+
branches: [main]
6+
jobs:
7+
pre-commit:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: actions/setup-python@v5
12+
with:
13+
python-version: 3.12
14+
- uses: pre-commit/[email protected]

.github/workflows/pytest.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: pytest
2+
on: [push]
3+
jobs:
4+
build:
5+
runs-on: ${{ matrix.os }}
6+
strategy:
7+
matrix:
8+
os: [ubuntu-latest]
9+
python-version: ["3.12"]
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up Python
13+
uses: actions/setup-python@v5
14+
with:
15+
python-version: ${{ matrix.python-version }}
16+
- name: Run image
17+
uses: abatilo/actions-poetry@v2
18+
- name: Install dependencies
19+
run: poetry install --with=dev
20+
- name: Run tests
21+
run: poetry run pytest

.github/workflows/release.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: release
2+
on:
3+
workflow_run:
4+
workflows: [pre-commit, pytest]
5+
types: [completed]
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v4
12+
- name: Semantic Release
13+
uses: cycjimmy/semantic-release-action@v4
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/stale.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: "Stale"
2+
on:
3+
schedule:
4+
- cron: "30 1 * * 0"
5+
jobs:
6+
stale:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/stale@v9
10+
with:
11+
stale-issue-message: >
12+
"This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs."
13+
14+
stale-pr-message: "This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 21 days."
15+
close-issue-message: "This issue was closed because it has been stalled for 14 days with no activity."
16+
close-pr-message: "This PR was closed because it has been stalled for 21 days with no activity."
17+
days-before-issue-stale: 60
18+
days-before-pr-stale: 45
19+
days-before-issue-close: 14
20+
days-before-pr-close: 21
21+
exempt-issue-labels: pinned, security
22+
exempt-pr-labels: pinned, security

.pre-commit-config.yaml

Lines changed: 65 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,67 @@
11
repos:
2-
- repo: https://github.com/psf/black
3-
rev: stable
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: "v4.6.0"
44
hooks:
5-
- id: black
6-
language_version: python3.8
7-
5+
- id: check-yaml
6+
- id: check-added-large-files
7+
- id: check-case-conflict
8+
- id: check-docstring-first
9+
- id: check-executables-have-shebangs
10+
- id: check-json
11+
- id: check-merge-conflict
12+
- id: check-toml
13+
- id: check-yaml
14+
- id: debug-statements
15+
- id: detect-private-key
16+
- id: double-quote-string-fixer
17+
- id: end-of-file-fixer
18+
- id: forbid-submodules
19+
- id: name-tests-test
20+
args: [--pytest-test-first]
21+
- id: pretty-format-json
22+
- id: trailing-whitespace
23+
- repo: https://github.com/astral-sh/ruff-pre-commit
24+
rev: "v0.4.2"
25+
hooks:
26+
- id: ruff
27+
args: [--fix]
28+
- id: ruff-format
29+
- repo: https://github.com/pre-commit/mirrors-mypy
30+
rev: "v1.10.0"
31+
hooks:
32+
- id: mypy
33+
- repo: https://github.com/detailyang/pre-commit-shell
34+
rev: "v1.0.6"
35+
hooks:
36+
- id: shell-lint
37+
args: [--format=json]
38+
- repo: https://github.com/compilerla/conventional-pre-commit
39+
rev: "v3.2.0"
40+
hooks:
41+
- id: conventional-pre-commit
42+
stages: [commit-msg]
43+
- repo: https://github.com/mrtazz/checkmake.git
44+
rev: "0.2.2"
45+
hooks:
46+
- id: checkmake
47+
- repo: https://github.com/gitleaks/gitleaks
48+
rev: "v8.18.2"
49+
hooks:
50+
- id: gitleaks
51+
- repo: https://github.com/google/yamlfmt
52+
rev: "v0.11.0"
53+
hooks:
54+
- id: yamlfmt
55+
- repo: https://github.com/rhysd/actionlint
56+
rev: "v1.6.27"
57+
hooks:
58+
- id: actionlint
59+
- repo: https://github.com/python-poetry/poetry
60+
rev: "1.8.2"
61+
hooks:
62+
- id: poetry-check
63+
- id: poetry-lock
64+
- repo: https://github.com/adrienverge/yamllint.git
65+
rev: v1.35.1
66+
hooks:
67+
- id: yamllint

.releaserc.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"branches": [
3+
"main"
4+
],
5+
"plugins": [
6+
"@semantic-release/commit-analyzer",
7+
"@semantic-release/release-notes-generator",
8+
"@semantic-release/github",
9+
"@semantic-release/git",
10+
"@semantic-release/changelog"
11+
]
12+
}

.yamllint.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
extends: default
2+
rules:
3+
line-length:
4+
max: 180
5+
document-end:
6+
present: false
7+
document-start:
8+
present: false

COPYING

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,4 +672,3 @@ may consider it more useful to permit linking proprietary applications with
672672
the library. If this is what you want to do, use the GNU Lesser General
673673
Public License instead of this License. But first, please read
674674
<https://www.gnu.org/licenses/why-not-lgpl.html>.
675-

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.PHONY: all clean test
2+
3+
.PHONY: install
4+
install:
5+
echo "Installing dependencies"
6+
brew install shellcheck checkmake gitleaks yamllint
7+
go install github.com/rhysd/actionlint/cmd/actionlint@latest
8+
go install github.com/google/yamlfmt/cmd/yamlfmt@latest
9+
10+
.PHONY: lint
11+
lint:
12+
pre-commit run --all-files

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
***THIS IS A TEMPLATE***
1+
# Python Template
22

3-
# <PROJECTNAME>
4-
<DESCRIPTION>
3+
This template comes with:
54

5+
- pre-commit hook configuration
6+
- a base pyproject.toml
7+
- dependabot configuration
8+
- a set of github actions
9+
- pre-commit
10+
- pytest
11+
- semantic-release
12+
- stale
613

7-
[![test-action](https://github.com/JimFawkes/<PROJECTNAME>/workflows/run_tests/badge.svg)](https://github.com/JimFawkes/<PROJECTNAME>/actions)
8-
[![codecov](https://codecov.io/gh/JimFawkes/<PROJECTNAME>/branch/master/graph/badge.svg)](https://codecov.io/gh/JimFawkes/<PROJECTNAME>)
9-
![python](https://img.shields.io/badge/python-3.8-blue)
10-
[![black](https://github.com/JimFawkes/<PROJECTNAME>/workflows/Lint/badge.svg)](https://github.com/JimFawkes/<PROJECTNAME>/actions)
11-
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](COPYING)
12-
[![Latest Tag](https://img.shields.io/github/v/tag/jimfawkes/<PROJECTNAME>)](https://github.com/JimFawkes/<PROJECTNAME>/releases)
13-
[![CodeFactor](https://www.codefactor.io/repository/github/jimfawkes/<PROJECTNAME>/badge)](https://www.codefactor.io/repository/github/jimfawkes/<PROJECTNAME>)
14-
[![CodeQL](https://github.com/JimFawkes/<PROJECTNAME>/workflows/CodeQL/badge.svg)](https://github.com/JimFawkes/<PROJECTNAME>/actions)
14+
In order for semantic release to work properly, two steps are necessary:
1515

16+
1. All commits need to honor [conventional-commits](https://www.conventionalcommits.org/en/v1.0.0/)
17+
2. The GitHub Actions need read & write permissions (Settings > Actions > Permissions)

0 commit comments

Comments
 (0)