diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5f8f040 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,48 @@ +name: Tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8, 3.9] + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install Poetry + uses: snok/install-poetry@v1.1.1 + with: + version: 1.1.4 + virtualenvs-create: true + virtualenvs-in-project: true + - name: Load cached venv + id: cached-poetry-dependencies + uses: actions/cache@v2 + with: + path: .venv + key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} + - 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: Linting + run: | + poetry run tox -e isort-check + poetry run tox -e black-check + - name: Run tests + env: + TOX_ENV: py${{ matrix.python-version }} + run: | + poetry run tox -e $TOX_ENV diff --git a/tox.ini b/tox.ini index dc5fd27..3253907 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] isolated_build = True skipsdist = True -envlist = py39,py38 +envlist = py3.9,py3.8 requires = tox-poetry-dev-dependencies @@ -9,7 +9,9 @@ requires = # note tox will use the same python version as under what tox is installed to package # so unless this is python 3 you can require a given python version for the packaging # environment via the basepython key -basepython = python3 +basepython = + py3.9: python3.9 + py3.8: python3.8 [testenv:isort-check] commands = isort -c --diff clerk/ tests/ @@ -18,7 +20,7 @@ commands = isort -c --diff clerk/ tests/ commands = black --check clerk/ tests/ [testenv] -env = +setenv = PYTHONHASHSEED = 1 deps = . commands = pytest {posargs}