Skip to content

Commit

Permalink
chore: 🥇 set up Python project
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainBrault committed Sep 24, 2024
0 parents commit 33499ed
Show file tree
Hide file tree
Showing 13 changed files with 625 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Auto detect text files and perform LF normalization
* text=auto eol=lf

# Basic .gitattributes for a python repo.

# Source files
# ============
*.pxd text diff=python
*.py text diff=python
*.py3 text diff=python
*.pyw text diff=python
*.pyx text diff=python
*.pyz text diff=python
*.pyi text diff=python

# Binary files
# ============
*.db binary
*.p binary
*.pkl binary
*.pickle binary
*.pyc binary export-ignore
*.pyo binary export-ignore
*.pyd binary

# Jupyter notebook
*.ipynb text eol=lf

# Note: .db, .p, and .pkl files are associated
# with the python modules ``pickle``, ``dbm.*``,
# ``shelve``, ``marshal``, ``anydbm``, & ``bsddb``
# (among others).
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# All files are by default owned by this team,
# unless a more specific ownership rule is set below.
* @RomainBrault
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: daily
commit-message:
prefix: "build(dependency): ⬆️"
prefix-development: "build(ci-dependency): ⬆️"
labels:
- "ci"
- "github_actions"
- "dependencies"
83 changes: 83 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Tests
on:
workflow_dispatch:
push:
branches: ["main"]
tags-ignore: ["**"]
pull_request:
schedule:
- cron: "0 8 * * *"

concurrency:
group: check-${{ github.ref }}
cancel-in-progress: true

jobs:
check:
name: tox env ${{ matrix.tox_env }} under python ${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
python:
- "3.13"
tox_env:
- pre-commit
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Pick environment to run
run: |
import os;
env = "TOXENV=${{ matrix.tox_env }}\n"
with open(os.environ["GITHUB_ENV"], mode="a", encoding="utf-8") as file_handler:
file_handler.write(env)
shell: python
- name: Run the test suite
run: |
uvx --no-progress --quiet --with tox-uv tox run
test:
name: Run ${{ matrix.session }} tests under python ${{ matrix.python }} on ${{ matrix.os }}
needs: check
runs-on: ${{ matrix.os }}
timeout-minutes: 10
environment: test
strategy:
fail-fast: true
matrix:
python:
- "3.13"
- "3.12"
- "3.11"
- "3.10"
- "3.9"
os:
- ubuntu-latest
- macos-latest
- windows-latest
session:
- open-source
- proprietary
steps:
- name: Check out the repository
uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Pick environment to run
run: |
import os;
toxenv = "TOXENV=py{}{}-test-${{ matrix.session }}\n".format(*"${{ matrix.python }}".split("."))
os_name = "OS_NAME=${{ matrix.os }}\n"
env = toxenv + os_name
with open(os.environ["GITHUB_ENV"], mode="a", encoding="utf-8") as file_handler:
file_handler.write(env)
shell: python
- name: Github Login
run: |
echo "${{ secrets.GH_TOKEN }}" | gh auth login --with-token
- name: Run the test suite
run: |
git config --global init.defaultBranch main
uvx --no-progress --quiet --with tox-uv tox run
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# General
.secrets.*

## Integration
.nox
.tox
.venv

## Generated files
scripts/licenses.txt
scripts/code_licenses.txt
scripts/resource_licenses.txt
BOM/
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# template-github

Protect a GitHub repository (branch and tags)
97 changes: 97 additions & 0 deletions REUSE.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
version = 1
SPDX-PackageName = "whiteprint"
SPDX-PackageSupplier = "Romain Brault <mail@romainbrault.com>"
SPDX-PackageDownloadLocation = "https://github.com/whiteprints/whiteprint"

# Project root

[[annotations]]
path = "REUSE.toml"
SPDX-FileCopyrightText = "© 2024 Romain Brault <mail@romainbrault.com>"
SPDX-License-Identifier = "MIT-0"

[[annotations]]
path = "README.md"
SPDX-FileCopyrightText = "© 2024 Romain Brault <mail@romainbrault.com>"
SPDX-License-Identifier = "CC0-1.0"

[[annotations]]
path = "MAINTAINERS.md"
SPDX-FileCopyrightText = "© 2024 Romain Brault <mail@romainbrault.com>"
SPDX-License-Identifier = "CC0-1.0"

## Jinja includes

[[annotations]]
path = "includes/*.jinja"
precedence = "override"
SPDX-FileCopyrightText = "© 2024 Romain Brault <mail@romainbrault.com>"
SPDX-License-Identifier = "MIT-0"

## scripts

[[annotations]]
path = "scripts/*.sh"
precedence = "override"
SPDX-FileCopyrightText = "© 2024 Romain Brault <mail@romainbrault.com>"
SPDX-License-Identifier = "MIT-0"

## Project configuration

[[annotations]]
path = "tox.ini"
SPDX-FileCopyrightText = "© 2024 Romain Brault <mail@romainbrault.com>"
SPDX-License-Identifier = "MIT-0"

[[annotations]]
path = "copier.yml"
precedence = "override"
SPDX-FileCopyrightText = "© 2024 Romain Brault <mail@romainbrault.com>"
SPDX-License-Identifier = "MIT-0"

## Tools configuration

[[annotations]]
path = ".gitignore"
SPDX-FileCopyrightText = "© 2024 Romain Brault <mail@romainbrault.com>"
SPDX-License-Identifier = "MIT-0"

[[annotations]]
path = ".gitattributes"
SPDX-FileCopyrightText = "© 2024 Romain Brault <mail@romainbrault.com>"
SPDX-License-Identifier = "MIT-0"

## Project configuration

[[annotations]]
path = ".pre-commit-config.yaml"
SPDX-FileCopyrightText = "© 2024 Romain Brault <mail@romainbrault.com>"
SPDX-License-Identifier = "MIT-0"

## Continuous Integration

[[annotations]]
path = ".github/**/*.yml"
SPDX-FileCopyrightText = "© 2024 Romain Brault <mail@romainbrault.com>"
SPDX-License-Identifier = "MIT-0"

[[annotations]]
path = ".github/CODEOWNERS"
SPDX-FileCopyrightText = "© 2024 Romain Brault <mail@romainbrault.com>"
SPDX-License-Identifier = "CC0-1.0"

## Template

[[annotations]]
path = "template/**"
precedence = "override"
SPDX-FileCopyrightText = "© 2024 Romain Brault <mail@romainbrault.com>"
SPDX-License-Identifier = "MIT-0"

[[annotations]]
path = "template/CODE_OF_CONDUCT.md.jinja"
SPDX-FileCopyrightText = [
"© 2014 Coraline Ada Ehmeke",
"© 2024 Romain Brault <mail@romainbrault.com>",
]
SPDX-License-Identifier = "CC-BY-4.0"
4 changes: 4 additions & 0 deletions copier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_subdirectory: "template"
_tasks:
- ["uv", "run", "injectors/call_gh.py"]
- ["rm", "-r", "injectors", "github_protection_ruleset"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "Pull Requests and Commits Protection",
"target": "branch",
"source_type": "Repository",
"enforcement": "active",
"conditions": {
"ref_name": {
"exclude": [],
"include": [
"~DEFAULT_BRANCH",
"refs/heads/v*.*.*"
]
}
},
"rules": [
{
"type": "deletion"
},
{
"type": "non_fast_forward"
},
{
"type": "required_signatures"
},
{
"type": "required_linear_history"
},
{
"type": "pull_request",
"parameters": {
"require_code_owner_review": true,
"require_last_push_approval": true,
"dismiss_stale_reviews_on_push": true,
"required_approving_review_count": 0,
"required_review_thread_resolution": true
}
},
{
"type": "required_status_checks",
"parameters": {
"required_status_checks": [
{
"context": "Coverage",
"integration_id": 15368
},
{
"context": "Validate PR title",
"integration_id": 15368
}
],
"strict_required_status_checks_policy": false
}
}
]
}
58 changes: 58 additions & 0 deletions template/github_protection_ruleset/tag_ruleset/protect_tags.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "Tags Protection",
"target": "tag",
"source_type": "Repository",
"enforcement": "active",
"conditions": {
"ref_name": {
"exclude": [],
"include": [
"~ALL"
]
}
},
"rules": [
{
"type": "creation"
},
{
"type": "update"
},
{
"type": "deletion"
},
{
"type": "non_fast_forward"
},
{
"type": "required_signatures"
},
{
"type": "required_linear_history"
},
{
"type": "required_status_checks",
"parameters": {
"required_status_checks": [
{
"context": "Coverage",
"integration_id": 15368
}
],
"strict_required_status_checks_policy": false
}
}
],
"bypass_actors": [
{
"actor_id": 5,
"actor_type": "RepositoryRole",
"bypass_mode": "always"
},
{
"actor_id": 1,
"actor_type": "OrganizationAdmin",
"bypass_mode": "always"
}
]
}
Loading

0 comments on commit 33499ed

Please sign in to comment.