Skip to content

WIP #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[run]
omit = *-test.py

[xml]
output = .coverage.xml
26 changes: 26 additions & 0 deletions .github/actions/set-up-poetry/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Set up poetry'
description: 'Set up poetry'
inputs:
python-version:
description: 'The Python version to use'
required: true
runs:
using: "composite"
steps:
- name: Set up Python ${{ inputs.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ inputs.python-version }}
cache: pip

- name: Upgrade pip
shell: bash
run: python -m pip install --upgrade pip

- name: Install poetry
shell: bash
run: pip install poetry

- name: Install dev dependencies
shell: bash
run: poetry install --only dev
270 changes: 270 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,270 @@
name: ci

on:
workflow_call:
push:
branches:
- main
pull_request:
merge_group:

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
TESTED_PYTHON_VERSIONS: ${{ contains(fromJSON('["pull_request"]'), github.event_name) && '["3.10", "3.12"]' || '["3.10", "3.11", "3.12"]' }}
TYPE_CHECKED_PYTHON_VERSIONS: ${{ contains(fromJSON('["pull_request"]'), github.event_name) && '["3.10"]' || '["3.10", "3.11", "3.12"]' }}

jobs:

python-versions:
runs-on: ubuntu-latest
outputs:
tested: ${{ env.TESTED_PYTHON_VERSIONS }}
type-checked: ${{ env.TYPE_CHECKED_PYTHON_VERSIONS }}
steps:
- run: true


lock-file:

strategy:
matrix:
platform:
- ubuntu-latest
python-version:
- '3.12'

runs-on: ${{ matrix.platform }}

steps:

- uses: actions/checkout@v4

- uses: ./.github/actions/set-up-poetry
with:
python-version: ${{ matrix.python-version }}

- name: Validate lock file
run: poetry check


unit:

needs: python-versions

strategy:
fail-fast: false
matrix:
platform:
- ubuntu-latest
- windows-latest
- macos-latest
python-version: ${{ fromJSON(needs.python-versions.outputs.tested) }}
include:
- tox-env: 'unit'
- python-version: ${{ fromJSON(needs.python-versions.outputs.tested)[0] }}
tox-env: ${{ github.actor != 'dependabot[bot]' && 'unit-cover' || 'unit' }}

runs-on: ${{ matrix.platform }}

steps:

- uses: actions/checkout@v4

- uses: ./.github/actions/set-up-poetry
with:
python-version: ${{ matrix.python-version }}

- name: Run unit tests with tox${{ matrix.tox-env == 'unit-cover' && ' (with coverage)' || '' }}
shell: bash
run: poetry run tox -e ${{ matrix.tox-env }}

- uses: codecov/codecov-action@v3
if: matrix.tox-env == 'unit-cover'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
fail_ci_if_error: false
flags: unit,${{ matrix.platform }},python-${{ matrix.python-version }}
files: ./.coverage.xml


doctest:

needs: python-versions

strategy:
fail-fast: false
matrix:
platform:
- ubuntu-latest
- windows-latest
- macos-latest
python-version: ${{ fromJSON(needs.python-versions.outputs.tested) }}
include:
- tox-env: 'doctest'
- python-version: ${{ fromJSON(needs.python-versions.outputs.tested)[0] }}
tox-env: ${{ github.actor != 'dependabot[bot]' && 'doctest-cover' || 'doctest' }}

runs-on: ${{ matrix.platform }}

steps:

- uses: actions/checkout@v4

- uses: ./.github/actions/set-up-poetry
with:
python-version: ${{ matrix.python-version }}

- name: Run doctest tests with tox
shell: bash
run: poetry run tox -e ${{ matrix.tox-env }}

- uses: codecov/codecov-action@v3
if: matrix.tox-env == 'doctest-cover'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
fail_ci_if_error: false
flags: doctest,${{ matrix.platform }},python-${{ matrix.python-version }}
files: ./.coverage.xml


pre-commit:

strategy:
matrix:
platform:
- ubuntu-latest
python-version:
- '3.12'

runs-on: ${{ matrix.platform }}

steps:

- uses: actions/checkout@v4

- uses: ./.github/actions/set-up-poetry
with:
python-version: ${{ matrix.python-version }}

- name: Pre-commit hooks
env:
SKIP: lint-check,type-check,licenses
run: poetry run pre-commit run -a


lint-check:
strategy:
matrix:
platform:
- ubuntu-latest
python-version:
- '3.10'

runs-on: ${{ matrix.platform }}

steps:

- uses: actions/checkout@v4

- uses: ./.github/actions/set-up-poetry
with:
python-version: ${{ matrix.python-version }}

- name: Lint sources and tests
run: poetry run tox -e lint-check


type-check:

needs: python-versions

strategy:
matrix:
platform:
- ubuntu-latest
python-version: ${{ fromJSON(needs.python-versions.outputs.type-checked) }}

runs-on: ${{ matrix.platform }}

steps:

- uses: actions/checkout@v4

- uses: ./.github/actions/set-up-poetry
with:
python-version: ${{ matrix.python-version }}

- name: Type checking
run: poetry run tox -e type-check


licenses:
strategy:
matrix:
platform:
- ubuntu-latest
python-version:
- '3.12'

runs-on: ${{ matrix.platform }}

steps:

- uses: actions/checkout@v4

- uses: ./.github/actions/set-up-poetry
with:
python-version: ${{ matrix.python-version }}

- name: Check dependencies' licenses
run: poetry run tox -e licenses


docs:
strategy:
matrix:
platform:
- ubuntu-latest
python-version:
- '3.12'

runs-on: ${{ matrix.platform }}

steps:

- uses: actions/checkout@v4

- uses: ./.github/actions/set-up-poetry
with:
python-version: ${{ matrix.python-version }}

- name: Build documentation
run: |
poetry run tox -e docs-build


build:
strategy:
matrix:
platform:
- ubuntu-latest
python-version:
- '3.12'

runs-on: ${{ matrix.platform }}

steps:

- uses: actions/checkout@v4

- uses: ./.github/actions/set-up-poetry
with:
python-version: ${{ matrix.python-version }}

- name: Build package
run: poetry build
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
__pycache__/
src/__pycache__/

.venv/
.tox/
Expand Down
46 changes: 46 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: fix-byte-order-marker
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-case-conflict
- id: check-added-large-files
- id: check-symlinks
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: check-vcs-permalinks
- id: check-toml
- id: check-xml
- id: check-yaml
- id: pretty-format-json
- id: debug-statements
- id: detect-private-key

- repo: local
hooks:
- id: lint-check
name: lint-check
types: [python]
language: system
entry: poetry run tox -e lint-check -- --
require_serial: true

- id: type-check
name: type-check
language: system
types: [python]
entry: poetry run tox -e type-check -- --
require_serial: true

- id: licenses
name: licenses
files: '^poetry.lock$'
language: system
pass_filenames: false
entry: poetry run tox -e licenses -- --

- repo: meta
hooks:
- id: check-useless-excludes
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ _this doc file is under construction 👷‍♀️_

## Installation

Depending on your workflow, you can either
Depending on your workflow, you can either

- Install it using [pipx](https://pipx.pypa.io/latest/installation/) with

Expand Down
20 changes: 20 additions & 0 deletions docs/_templates/page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% extends "!page.html" %}
{% block body %}
{% if current_version and latest_version and current_version != latest_version and current_version.name != "latest" %}
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">
<strong>
{% if current_version.is_released %}
You are reading the documentation for {{current_version.name}}.
The latest version is <a href="{{ vpathto(latest_version.name) }}">{{latest_version.name}}</a>.
{% else %}
You are reading the documentation for a development version.
The latest release is <a href="{{ vpathto(latest_version.name) }}">{{latest_version.name}}</a>.
{% endif %}
</strong>
</p>
</div>
{% endif %}
{{ super() }}
{% endblock %}%
Loading
Loading