Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
armand-sauzay committed May 28, 2024
0 parents commit 399b003
Show file tree
Hide file tree
Showing 20 changed files with 531 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .commitlintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
extends:
- "@commitlint/config-conventional"
1 change: 1 addition & 0 deletions .copier/.copier-answers.yaml.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{ _copier_answers|to_nice_yaml -}}
26 changes: 26 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: armand-sauzay/actions-python/lint@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: armand-sauzay/actions-python/test@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
test-flags: --version
22 changes: 22 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release

on:
workflow_run:
workflows: ["CI", "Test"]
branches: [main]
types:
- completed
workflow_dispatch:

jobs:
release:
name: Release
runs-on: ubuntu-latest
outputs:
new-release-published: ${{ steps.release.outputs.new-release-published }}
new-release-version: ${{ steps.release.outputs.new-release-version }}
steps:
- uses: armand-sauzay/actions-python/release@v1
id: release
with:
github-token: ${{ secrets.ADMIN_TOKEN || secrets.GITHUB_TOKEN }}
19 changes: 19 additions & 0 deletions .github/workflows/update-dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Renovate
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:

jobs:
renovate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4.1.1
- name: Self-hosted Renovate
uses: renovatebot/github-action@v40.1.0
env:
RENOVATE_REPOSITORIES: ${{ github.repository }}
RENOVATE_ONBOARDING: false
with:
token: ${{ secrets.RENOVATE_TOKEN }}
156 changes: 156 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

#idea
.idea/

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/
35 changes: 35 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
rev: v9.16.0
hooks:
- id: commitlint
stages: [commit-msg]
additional_dependencies: ["@commitlint/config-conventional"]
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.4
hooks:
- id: ruff
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
stages: [commit]
- repo: https://github.com/rhysd/actionlint
rev: v1.7.0
hooks:
- id: actionlint-docker
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 3.0.0
hooks:
- id: shellcheck
- repo: https://github.com/scop/pre-commit-shfmt
rev: v3.6.0-2
hooks:
- id: shfmt-docker
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12.3
8 changes: 8 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/github"
]
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Armand Sauzay

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# python-template

This is a template for Python-based repositories.

## Usage

The recommended way to use this repo is to

1. **Use this project as template**: and then run copier locally. Simply click on the "Use this template" button on the GitHub page to create a new repository based on this template.

2. **Run copier**: you can download [Copier](https://github.com/copier-org/copier) and then run the following command:

```bash
copier copy "https://github.com/armand-sauzay/python-template.git" <your_folder>
```

If you want to target a specific branch, you can use:

```bash
copier copy --vcs-ref "<python-template-branch>" "https://github.com/armand-sauzay/python-template.git" <target-folder>
```

## Project files

### .commitlintrc.json and .releaserc.json

These files are used by `semantic-release` to determine the type of the next release. The `.commitlintrc.json` file is used to lint the commit messages. The `.releaserc.json` file is used to determine the version of the next release based on the commit messages. To lint commit messages, this project uses the default configuration of `@commitlint/config-conventional`.

### .python-version file

The `.python-version` file contains the python version used in this project. This project has been built with using `pyenv` as python version manager.

### .pre-commit-config.yaml

This file is used by `pre-commit` to determine the hooks that will be run before each commit. The hooks are defined in the `hooks` section of the file. The hooks are run in the order they are defined in the file.

### .github/workflows

This repository uses Github Actions for CI/CD. CI is composed of `Lint` with pre-commit and `Test` with pytest. Release is composed of `Lint`, `Test`, `Release` with semantic-release.

- Lint is done with [pre-commit](https://pre-commit.com/). To run lint locally, run `pre-commit run --all-files`.
- Test is done with [pytest](https://docs.pytest.org/en/8.0.x/). To run test locally, run `pytest`. Or poetry run `pytest` if you use poetry as package manager.
- Release is done with [semantic-release](https://github.com/semantic-release/semantic-release)
22 changes: 22 additions & 0 deletions README.md.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# {{ project_name }}

## Project files

### `.commitlintrc.json` and `.releaserc.json`

These files are used by `semantic-release` to determine the type of the next release. The `.commitlintrc.json` file is used to lint the commit messages. The `.releaserc.json` file is used to determine the version of the next release based on the commit messages. To lint commit messages, this project uses the default configuration of `@commitlint/config-conventional`.

### `.python-version` file

The `.python-version` file contains the python version used in this project. This project has been built with using `pyenv` as python version manager.

### `.pre-commit-config.yaml` file

This file is used by `pre-commit` to determine the hooks that will be run before each commit. The hooks are defined in the `hooks` section of the file. The hooks are run in the order they are defined in the file.

### `.github/workflows` folder

This repository uses Github Actions for CI/CD. CI is composed of `Lint` with pre-commit and `Test` with pytest. Release is composed of `Lint`, `Test`, `Release` with semantic-release.
- Lint is done with [pre-commit](https://pre-commit.com/). To run lint locally, run `pre-commit run --all-files`.
- Test is done with [pytest](https://docs.pytest.org/en/8.0.x/). To run test locally, run `pytest`. Or poetry run `pytest` if you use poetry as package manager.
- Release is done with [semantic-release](https://github.com/semantic-release/semantic-release)
29 changes: 29 additions & 0 deletions copier.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
project_name:
type: str
help: What is your project name? (kebab-case, like hello-world)

module_name:
type: str
help: What is the name of your Python module? (snake_case, like hello_world)
default: "{{ project_name | replace('-', '_') }}"

module_version:
type: str
help: What is the first version of your project?
default: 1.0.0

_answers_file: .copier/.copier-answers.yml

_exclude:
- "__pycache__"
- ".DS_Store"
- ".git"
- ".svn"
- "*.py[co]"
- "~*"
- "copier.yaml"
- "LICENSE"

_tasks:
- "find . -type d -name '{?*' -exec rm -rf {} +"
- "find . -type f -name '*.jinja' -exec rm -f {} +"
Loading

0 comments on commit 399b003

Please sign in to comment.