Skip to content

Commit

Permalink
Tox for pytest within GitHub Actions (GHA) (dbt-labs#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbeatty10 authored Nov 4, 2022
1 parent e60b493 commit 8fc2282
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,33 @@ jobs:
python -m pip install -r requirements-dev.txt
- name: Run pre-commit hooks
run: pre-commit run --all-files --show-diff-on-failure

unit:
name: unit test / python ${{ matrix.python-version }} / ${{ matrix.os }}

runs-on: ${{ matrix.os }}
timeout-minutes: 10

strategy:
fail-fast: false
matrix:
python-version: ["3.9"]
os: [ubuntu-latest]

steps:
- name: Check out the repository
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: ${{ matrix.python-version }}

- name: Install python tools
run: |
python -m pip install --user --upgrade pip
python -m pip --version
python -m pip install tox
tox --version
- name: Run tests
run: tox
20 changes: 19 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,25 @@ python3 hubcap/hubcap.py
## Testing locally

```shell
PYTHONPATH=hubcap python -m pytest
python -m pytest
```

Or just:
```shell
tox
```

## GitHub Actions (GHA) locally

Download and install [`act`](https://github.com/nektos/act) then:

```shell
act
```

For Apple M1 Mac users, might need to do this:
```shell
act --container-architecture linux/amd64
```

## Generate requirements.txt
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ black==22.6.0
pip-tools
pre-commit
pytest
tox
12 changes: 12 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[tox]
skipsdist = True
envlist = unit

[testenv:{unit,py39,py}]
description = unit testing
download = true
skip_install = true
commands =
{envpython} -m pytest
deps =
-rrequirements-dev.txt

0 comments on commit 8fc2282

Please sign in to comment.