Skip to content

Commit

Permalink
enable pytest in github actions (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwoac committed Nov 4, 2023
1 parent b83f58b commit ec95d49
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Run tests

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
# python-version: [3.7, 3.8, 3.9]
python-version: [3.9]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install 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: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
# if cache doesn't exist then install deps
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install library
run: poetry install --no-interaction
- name: Test with pytest
run: |
source .venv/bin/activate
pytest
3 changes: 3 additions & 0 deletions tests/test_doenut.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import pandas as pd
import doenut
import pytest
import os

# since pytest runs from an arbitrary location, fix that.
os.chdir(os.path.dirname(__file__))
df = pd.read_csv("solar_cells_1.csv")
inputs = pd.DataFrame(
{
Expand Down

0 comments on commit ec95d49

Please sign in to comment.