This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
feat: python package #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "✨ Python" | |
on: | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- "**.py" | |
- "requirements.txt" | |
- "dev-requirements.txt" | |
- ".github/workflows/python.yml" | |
push: | |
paths: | |
- "**.py" | |
permissions: | |
contents: read | |
pull-requests: read | |
jobs: | |
analyse-supported: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
supported-python-version: ["3.9", "3.10", "3.11", "3.12"] | |
name: Testing on Python ${{ matrix.supported-python-version }} | |
continue-on-error: true | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.supported-python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.supported-python-version }} | |
allow-prereleases: true | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip3 install poetry | |
poetry install | |
- name: Lint check with Ruff | |
run: | | |
if [ ${{ matrix.supported-python-version }} == 3.7 ]; then | |
poetry run ruff check $(git ls-files '*.py') --target-version=py37 | |
fi | |
if [ ${{ matrix.supported-python-version }} == 3.8 ]; then | |
poetry run ruff check $(git ls-files '*.py') --target-version=py38 | |
fi | |
if [ ${{ matrix.supported-python-version }} == 3.9 ]; then | |
poetry run ruff check $(git ls-files '*.py') --target-version=py39 | |
fi | |
if [ ${{ matrix.supported-python-version }} == 3.10 ]; then | |
poetry run ruff check $(git ls-files '*.py') --target-version=py310 | |
fi | |
if [ ${{ matrix.supported-python-version }} == 3.11 ]; then | |
poetry run ruff check $(git ls-files '*.py') --target-version=py311 | |
fi | |
if [ ${{ matrix.supported-python-version }} == 3.12 ]; then | |
poetry run ruff check $(git ls-files '*.py') --target-version=py312 | |
fi | |
- name: Static analysis with MyPy | |
run: | | |
poetry run mypy $(git ls-files '*.py') --python-version ${{ matrix.supported-python-version }} | |
- name: Testing with Pytest | |
run: | | |
poetry run pytest | |
analyse-best_effort: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
base-python-version: ["3.11"] | |
best_effort-python-version: ["3.8"] | |
name: Static analysis on Python ${{ matrix.best_effort-python-version }} | |
continue-on-error: true | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.base-python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.base-python-version }} | |
allow-prereleases: true | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install poetry | |
poetry install | |
- name: Static analysis with MyPy | |
run: | | |
poetry run mypy $(git ls-files '*.py') --python-version ${{ matrix.best_effort-python-version }} |