Skip to content

2

2 #194

Workflow file for this run

name: ci
on: [push]
jobs:
tests:
name: ${{matrix.os}} / ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
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']
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 }}
- name: Cache Dependencies
uses: actions/cache@v3
id: cache-dependencies
with:
path: ./.venv
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('Pipfile') }}
- name: Display Python version
run: python --version
- name: Get python path
id: python-path
run: |
echo "P_PATH=$(python -c 'import sys; print(sys.executable)')" >> $GITHUB_ENV
- name: Install pipenv
run: |
python -m pip install pipenv
- name: Install dependencies
env:
PIPENV_DEFAULT_PYTHON_VERSION: ${{ matrix.python-version }}
PIPENV_VENV_IN_PROJECT: "enabled"
PYTHONIOENCODING: "utf-8"
GIT_ASK_YESNO: "false"
if: steps.cache-dependencies.outputs.cache-hit != 'true'
run: |
pipenv install --dev --python=${{ env.P_PATH }}
- name: Run tests
env:
PIPENV_DEFAULT_PYTHON_VERSION: ${{ matrix.python-version }}
PIPENV_NOSPIN: "1"
GIT_ASK_YESNO: "false"
PYTHONIOENCODING: "utf-8"
run: |
pipenv run pytest -ra --cov=persiantools --cov-report xml:coverage.xml tests/
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
files: coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
build-and-publish:
if: github.repository == 'majiidd/persiantools' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: 3.13
- name: Install pypa/build
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade build setuptools
python -m build --sdist --wheel --outdir dist/ .
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
verbose: true
- name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: true