Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
florianvazelle committed Dec 9, 2023
0 parents commit f4ec797
Show file tree
Hide file tree
Showing 20 changed files with 768 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
POETRY_VERSION=1.7.1
30 changes: 30 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
version: 2
updates:

- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
time: '00:00'
timezone: UTC
open-pull-requests-limit: 10
commit-message:
prefix: "chore"
include: "scope"
labels:
- "dependabot"
- "dependencies"

- package-ecosystem: pip
directory: "/"
schedule:
interval: daily
time: '00:00'
timezone: UTC
open-pull-requests-limit: 10
commit-message:
prefix: "chore"
include: "scope"
labels:
- "dependabot"
- "dependencies"
15 changes: 15 additions & 0 deletions .github/workflows/changelog_verifier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Changelog Verifier

on:
pull_request:
types: [opened, edited, review_requested, synchronize, reopened, ready_for_review, labeled, unlabeled]

jobs:
# Enforces the update of a changelog file on every pull request
verify-changelog:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dangoslen/changelog-enforcer@v3
with:
skipLabels: "autocut, skip-changelog"
38 changes: 38 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Checks

on:
push:
workflow_dispatch:

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-latest, macos-latest]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: extractions/setup-just@v1

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Run tests
run: just test

lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- uses: extractions/setup-just@v1

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Run lint
run: just lint
30 changes: 30 additions & 0 deletions .github/workflows/dependabot_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Dependabot PR actions

on:
pull_request:
types: [opened, synchronize, reopened, labeled, unlabeled]

jobs:
dependabot:
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write

if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Check out code
uses: actions/checkout@v4

- name: Update the changelog
uses: dangoslen/dependabot-changelog-helper@v3
with:
version: 'Unreleased'

- name: Commit the changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore(changelog): automatic update to add dependabot deps bump"
branch: ${{ github.head_ref }}
commit_user_name: dependabot[bot]
commit_user_email: [email protected]
20 changes: 20 additions & 0 deletions .github/workflows/links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Link Checker

on:
push:

jobs:
linkchecker:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: lychee Link Checker
id: lychee
uses: lycheeverse/lychee-action@v1
with:
args: --accept=200,403,429 "**/*.html" "**/*.md" "**/*.txt" "**/*.json" --exclude "file:///github/workspace/*" --exclude-path "tests/" --exclude-mail
fail: true
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
34 changes: 34 additions & 0 deletions .github/workflows/lint_pr_title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Lint PR Title

on:
pull_request_target:
types:
- opened
- edited
- synchronize

permissions:
pull-requests: read

jobs:
main:
name: Validate PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
scopes: |
playbook
scripts
tasks
dependabot
workflows
publish
readme
changelog
deps
requireScope: false
validateSingleCommit: true
validateSingleCommitMatchesPrTitle: true
87 changes: 87 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Publish

on: push

jobs:
build:
name: Build distribution 📦
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/magic_combo
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release create
'${{ github.ref_name }}' dist/**
--title 'v${{ github.ref_name }}'
--generate-notes
--repo '${{ github.repository }}'
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

# User-specific stuff
.idea/
.vscode/

# Python-specific ignores
venv/
*.pyc
65 changes: 65 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: fix-byte-order-marker # Prevents weird UTF-8 encoding edge cases
- id: check-case-conflict # Check if case-insensitive filesystems would bork
- id: check-docstring-first # Check for if docstring was misplaced
- id: check-executables-have-shebangs
- id: check-json # Checks for valid json
- id: check-merge-conflict # Checks strings that look like a committed merge conflict
- id: check-xml # Checks for valid xml
- id: check-yaml # Checks for valid yaml
- id: end-of-file-fixer # Checks for ending with a newline
- id: mixed-line-ending # Consistent LF or CRLF
- id: trailing-whitespace # No trailing whitespace
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
- id: codespell
args: ["--toml", "pyproject.toml"]
additional_dependencies:
- tomli
- repo: https://github.com/psf/black
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
args: ["--configfile", "pyproject.toml"]
additional_dependencies:
- bandit[toml]
#- repo: https://github.com/astral-sh/ruff-pre-commit
# rev: v0.0.282
# hooks:
# - id: ruff
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.4.1
hooks:
- id: mypy
args: ["--config-file", "pyproject.toml"]
additional_dependencies:
- tomli
exclude: tests
- repo: local
hooks:
- id: lower-case-only
name: lower case only
entry: filenames must be lower-case or lower_case only
language: fail
files: '[^a-z0-9._/-]'
exclude: |
(?x)^(
CHANGELOG.md|
CONTRIBUTING.md|
CREDITS.md|
LICENSE.md|
README.md|
Justfile
)
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# CHANGELOG
Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]
### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security
### Dependencies
33 changes: 33 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env -S just --justfile

set dotenv-load := true

export PIP_REQUIRE_VIRTUALENV := "true"

# === Variables ===

# Poetry variables
poetry_version := env_var('POETRY_VERSION')

# === Commands ===

# Display all commands
@default:
echo "OS: {{ os() }} - ARCH: {{ arch() }}\n"
just --list

# Install poetry
@install-poetry:
if [ -z $(command -v poetry) ]; then curl -sSL https://install.python-poetry.org | python3 - --version {{ poetry_version }}; fi

# Install the package
install: install-poetry
poetry install

# Run formatters
fmt: install
poetry run pre-commit run -a

# Run tests
test *FILES: install
poetry run pytest {{ FILES }}
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright © 2023-present Florian Vazelle

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.
Loading

0 comments on commit f4ec797

Please sign in to comment.