Give credits to stack overflow answers #49
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: "test" | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python_version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
defaults: | |
run: | |
shell: bash | |
steps: | |
# check-out repo and install python | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python_version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python_version }} | |
# try to load cached venv | |
- name: Load cached venv | |
id: cached-venv | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ matrix.python_version }}-${{ hashFiles('poetry.lock') }} | |
# install poetry if venv not in cache | |
- name: Install Poetry | |
if: steps.cached-venv.outputs.cache-hit != 'true' | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.7.0 | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
installer-parallel: true | |
- name: Install dependencies | |
if: steps.cached-venv.outputs.cache-hit != 'true' | |
run: poetry install --with=dev | |
# run test suite | |
- name: Run pytests | |
run: | | |
source .venv/bin/activate | |
pytest --verbose tests |