[pre-commit.ci] auto fixes from pre-commit.com hooks #104
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: 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.7', '3.8', '3.9', '3.10', pypy-3.8] | |
include: | |
- python-version: '3.6' | |
os: ubuntu-latest | |
- python-version: pypy-3.9 | |
os: ubuntu-latest | |
- python-version: pypy-3.9 | |
os: windows-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Display Python version | |
run: python --version | |
- name: Get python path | |
id: python-path | |
run: | | |
echo ::set-output name=path::$(python -c "import sys; print(sys.executable)") | |
- 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=${{ steps.python-path.outputs.path }} | |
- name: Install extra dependency (pytest on python <= 3.7) | |
if: ${{ matrix.python-version == '3.6' || matrix.python-version == '3.7' }} | |
run: | | |
pipenv install --dev importlib_metadata | |
- name: Install extra dependency (pytest on windows) | |
if: ${{ matrix.os == 'windows-latest' }} | |
run: | | |
pipenv install --dev atomicwrites | |
- 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 --full-trace --cov=persiantools --cov-report xml:coverage.xml tests/ | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v2 | |
with: | |
fail_ci_if_error: true | |
files: coverage.xml | |
verbose: true | |
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@master | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.9 | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- 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@master | |
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@master | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} | |
verbose: true |