Skip to content

chore: fix lint issues #1218

chore: fix lint issues

chore: fix lint issues #1218

Workflow file for this run

---
name: build
defaults:
run:
shell: bash
env:
POETRY_HOME: ~/.poetry
# renovate: datasource=github-tags depName=python-poetry/poetry
POETRY_VERSION: '1.8.2'
POETRY_VIRTUALENVS_IN_PROJECT: true
on: [push, pull_request]
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 2
- name: Identify Python version
run: echo "PYTHON_VERSION=$(python -V | cut -d' ' -f2)" >> "$GITHUB_ENV"
- name: Cache Poetry
id: cache-poetry
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: ${{ env.POETRY_HOME }}
key: poetry-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ env.POETRY_VERSION }}
- name: Install Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: curl -sSL https://install.python-poetry.org | python
- name: Prepend Poetry to PATH
run: echo ${{ env.POETRY_HOME }}/bin >> "$GITHUB_PATH"
- name: Cache venv
id: cache-venv
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('poetry.lock') }}
restore-keys: venv-${{ runner.os }}-${{ env.PYTHON_VERSION }}-
- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --sync -v
- name: Install root package
run: poetry install --no-interaction --only-root -v
- name: Cache pre-commit hooks
id: cache-pre-commit
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('.pre-commit-config.yaml') }}
restore-keys: |
pre-commit-${{ runner.os }}-${{ env.PYTHON_VERSION }}-
pre-commit-${{ runner.os }}-
- name: Prune pre-commit hooks
if: steps.cache-pre-commit.outputs.cache-hit != 'true'
run: poetry run pre-commit gc
- name: Cache mypy
id: cache-mypy
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: .mypy_cache
key: mypy-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('poetry.lock') }}-${{ github.sha }}
restore-keys: mypy-${{ runner.os }}-${{ env.PYTHON_VERSION }}-${{ hashFiles('poetry.lock') }}-
- name: Run gitlint
env:
VIRTUALENV_PIP: 23.2.1
run: poetry run pre-commit run --color=always --hook-stage manual gitlint-ci
- name: Run pre-commit
run: poetry run pre-commit run --all-files --color=always --show-diff-on-failure
pytest:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [macos-latest, ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- name: Set up Python
id: setup-python
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5
with:
python-version: ${{ matrix.python-version }}
- name: Cache Poetry
id: cache-poetry
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: ${{ env.POETRY_HOME }}
key: poetry-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ env.POETRY_VERSION }}
- name: Install Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: curl -sSL https://install.python-poetry.org | python
- name: Prepend Poetry to PATH
run: echo ${{ env.POETRY_HOME }}/bin >> "$GITHUB_PATH"
- name: Cache venv
id: cache-venv
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
restore-keys: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-
- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --sync -v
- name: Install root package
run: poetry install --no-interaction --only-root -v
- name: Run pytest
run: poetry run pytest --color=yes --cov-config=pyproject.toml --numprocesses=8 --with-functional
- name: Upload coverage report
uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- name: Run SonarCloud scanner
uses: SonarSource/sonarcloud-github-action@e44258b109568baa0df60ed515909fc6c72cba92 # v2.3.0
if: matrix.os == 'ubuntu-latest'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
release:
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
needs: [pre-commit, pytest]
runs-on: ubuntu-latest
concurrency: release
permissions:
contents: write
id-token: write
steps:
- name: Check out repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 0
- name: Set up Python
id: setup-python
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5
- name: Cache Poetry
id: cache-poetry
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: ${{ env.POETRY_HOME }}
key: poetry-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ env.POETRY_VERSION }}
- name: Install Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: curl -sSL https://install.python-poetry.org | python
- name: Prepend Poetry to PATH
run: echo ${{ env.POETRY_HOME }}/bin >> "$GITHUB_PATH"
- name: Cache venv
id: cache-venv
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('poetry.lock') }}
restore-keys: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-
- name: Install dependencies
if: steps.cache-venv.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root --sync -v
- name: Set up Git signing
uses: crazy-max/ghaction-import-gpg@01dd5d3ca463c7f10f7f4f7b4f177225ac661ee4 # v6.1.0
with:
gpg_private_key: ${{ secrets.GPG_SIGN_KEY }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
- name: Bump version
id: bump-version
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: poetry run semantic-release version
- name: Publish package distributions to GitHub Releases
if: steps.bump-version.outputs.released == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: poetry run semantic-release publish
- name: Publish package distributions to PyPI
if: steps.bump-version.outputs.released == 'true'
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0 # v1.9.0