Skip to content

Commit

Permalink
Make unit tests run for PRs
Browse files Browse the repository at this point in the history
Among other improvements
  • Loading branch information
Gobot1234 committed Jul 20, 2023
1 parent 8976936 commit f13fa0f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ jobs:
repository: ${{ env.TARGET }}
path: steam-py.github.io

- name: Install
uses: snok/install-poetry@v1
with:
version: "latest"
- name: Install poetry
run: pipx install poetry && pipx install poethepoet

- name: Set up Python
uses: actions/setup-python@v4
Expand Down
23 changes: 11 additions & 12 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
name: Run tests.

on:
push:
branches:
- main
on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- uses: snok/install-poetry@v1
with:
version: "latest"
virtualenvs-create: true
virtualenvs-in-project: true
- name: Install poetry
run: pipx install poetry && pipx install poethepoet

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand All @@ -32,11 +26,16 @@ jobs:
- name: Install dependencies
run: poetry install --with dev

- name: Run tests for CPython ${{ matrix.python-version }}
- name: Run full tests for CPython ${{ matrix.python-version }}
if: ${{ github.ref_name == 'main' && github.repository == 'Gobot1234/steam.py'}}
env:
USERNAME: ${{ secrets.STEAM_USERNAME }}
PASSWORD: ${{ secrets.STEAM_PASSWORD }}
SHARED_SECRET: ${{ secrets.STEAM_SHARED_SECRET }}
IDENTITY_SECRET: ${{ secrets.STEAM_IDENTITY_SECRET }}
run: poetry run pytest .
run: poe test full
timeout-minutes: 30

- name: Run unit tests for CPython ${{ matrix.python-version }}
if: ${{ github.ref_name != 'main' || github.repository != 'Gobot1234/steam.py'}}
run: poe test unit
22 changes: 20 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,33 @@ tomli = {version = "~2", python = "<3.11"}
hypothesis = "^6.82.0"

[tool.poe.tasks]
test = {cmd = "pytest tests", help = "Run the tests"}
fmt = {sequence = [
{script = "scripts.blacken_docs_correctly:main"},
{cmd = "black ."},
{cmd = "isort ."}
], help = "Format the code"}
], ignore_fail = true, help = "Format the code"}
doc = {cmd = "sphinx-build -b html -T -W --keep-going docs/ docs/_build", help = "Build the documentation"} # TODO -n
add-cms = {script = "scripts.add_cms:main", help = "Add a default list of CMs for when the API is down"}

[tool.poe.tasks.test]
help = "Run the tests"
control.expr = "type"
[tool.poe.tasks.test.args.type]
required = true
positional = true
help = "Which types of tests to run can be one of 'full', 'unit' or 'integration'"
[[tool.poe.tasks.test.switch]]
case = "full"
cmd = "pytest tests"

[[tool.poe.tasks.test.switch]]
case = "unit"
cmd = "pytest tests/unit"

[[tool.poe.tasks.test.switch]]
case = "integration"
cmd = "pytests tests/integration"

[tool.poe.tasks.decode]
script = "scripts.decode:main"
help = "Decode a recieved message from the Steam WS"
Expand Down

0 comments on commit f13fa0f

Please sign in to comment.