Skip to content

Run Nempy Tests

Run Nempy Tests #107

Workflow file for this run

name: Run Nempy Tests
on:
push:
branches:
- master
pull_request:
branches:
- master
release:
types: [ created ]
workflow_dispatch: # manual trigger
jobs:
test:
# Matrix testing to test across OSs and Python versions
# Fail-fast: fail the entire job as soon as anything fails
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
# Necessary for poetry & Windows
defaults:
run:
shell: bash
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: ~/.cache
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install poetry env with dev group
run: poetry install --with=dev
- name: Run tests with pytest
run: |
source $VENV
python -m pytest
publish:
if: github.event_name == 'release' && github.event.action == 'created'
needs: test
runs-on: ubuntu-latest
steps:
# Checkout the repo so the workflow can access it
- name: Checkout
uses: actions/checkout@v3
# Set up Python
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
# Install the specified version of poetry
- name: Get poetry
uses: snok/install-poetry@v1
with:
version: 1.4.0
virtualenvs-create: true
virtualenvs-in-project: true
# Load cached poetry env if it exists
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
# Build and publish to PyPI
- name: Build and publish # publish tsgen to PyPI
env:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: poetry publish -u $PYPI_USERNAME -p $PYPI_PASSWORD --build