Skip to content

test

test #131

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.8', '3.9', '3.10', '3.11', '3.12', '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: 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 }}
PYTHONIOENCODING: "utf-8"
GIT_ASK_YESNO: "false"
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
verbose: true
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.12
uses: actions/setup-python@v5
with:
python-version: 3.12
- 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