Skip to content

[pre-commit.ci] pre-commit autoupdate #298

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #298

Workflow file for this run

name: ci
on:
push:
branches: ["**"]
tags: ["*.*.*"]
pull_request:
branches: ["**"]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests:
name: ${{ matrix.os }} / ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', 'pypy-3.9', 'pypy-3.10', 'pypy-3.11']
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Cache Pipenv virtualenv
id: cache-pipenv
uses: actions/cache@v4
with:
path: |
.venv
~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}-pipenv-${{ hashFiles('Pipfile.lock') }}
- name: Install pipenv
run: python -m pip install --upgrade pip pipenv
- name: Install dependencies
shell: bash
env:
PIPENV_NOSPIN: "1"
PIPENV_VENV_IN_PROJECT: "1"
run: |
if [ "${{ runner.os }}" = "Windows" ]; then
export PIPENV_PYTHON="${pythonLocation}\\python.exe"
else
export PIPENV_PYTHON="${pythonLocation}/bin/python"
fi
pipenv install --dev
- name: Display Python version
env:
PIPENV_NOSPIN: "1"
PIPENV_VENV_IN_PROJECT: "1"
run: pipenv run python -V
- name: Run tests (with coverage on Linux CPython 3.12)
if: ${{ runner.os == 'Linux' && matrix.python-version == '3.12' }}
env:
PIPENV_NOSPIN: "1"
PIPENV_VENV_IN_PROJECT: "1"
run: pipenv run pytest -ra --cov=persiantools --cov-report xml:coverage.xml tests/
- name: Run tests (no coverage)
if: ${{ !(runner.os == 'Linux' && matrix.python-version == '3.12') }}
env:
PIPENV_NOSPIN: "1"
PIPENV_VENV_IN_PROJECT: "1"
run: pipenv run pytest -ra tests/
- name: Upload coverage to Codecov
if: ${{ runner.os == 'Linux' && matrix.python-version == '3.12' }}
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install pre-commit
run: pip install pre-commit
- name: Cache pre-commit
uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit
run: pre-commit run --all-files
build-and-publish:
if: github.repository == 'majiidd/persiantools' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Build sdist and wheel
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade build
python -m build --sdist --wheel --outdir dist/ .
- name: Publish to Test PyPI
if: always()
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
verbose: true
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true