Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

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

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ celerybeat.pid
.env
.envrc
.venv
.venv_test
env/
venv/
ENV/
Expand Down
9 changes: 8 additions & 1 deletion tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
ROOT = Path(__file__).resolve().parent.parent
SCRIPT = ROOT / 'tools.sh'
VENV_TEST = ROOT / '.venv_test'
PACKAGE_NAME = 'stat_log_db'
PACKAGE_NAME = 'stat-log-db'

GITHUB_ACTIONS = os.getenv("GITHUB_ACTIONS") == "true"

#endregion

Expand Down Expand Up @@ -82,13 +84,15 @@ def test_help():
except AssertionError:
assert out.strip() == readme_content.strip(), "Help output does not match README content (leading & trailing whitespace stripped)"

@pytest.mark.skipif(GITHUB_ACTIONS, reason="Skipping test on GitHub Actions")
def test_install_dev(test_venv):
code, out = run_tools(['-id'], use_test_venv=True)
assert code == 0
assert 'Installing' in out
assert 'dev' in out
assert is_installed(PACKAGE_NAME), 'Package should be installed after dev install'

@pytest.mark.skipif(GITHUB_ACTIONS, reason="Skipping test on GitHub Actions")
def test_install_normal(test_venv):
code, out = run_tools(['-in'], use_test_venv=True)
assert code == 0
Expand All @@ -102,6 +106,7 @@ def test_install_invalid_arg(test_venv):
assert ('Unsupported argument' in out) or ('Invalid install mode' in out)
assert not is_installed(PACKAGE_NAME), 'Package should not be installed after invalid install argument'

@pytest.mark.skipif(GITHUB_ACTIONS, reason="Skipping test on GitHub Actions")
def test_uninstall(test_venv):
# Ensure something installed first (dev mode)
icode, iout = run_tools(['-id'], use_test_venv=True)
Expand All @@ -113,6 +118,7 @@ def test_uninstall(test_venv):
assert 'Uninstall complete' in uout
assert not is_installed(PACKAGE_NAME), 'Package should not be installed after uninstall'

@pytest.mark.skipif(GITHUB_ACTIONS, reason="Skipping test on GitHub Actions")
def test_install_and_clean_multi_flag(test_venv):
code, out = run_tools(['-id', '-c'], use_test_venv=True)
assert code == 0
Expand All @@ -135,6 +141,7 @@ def test_test_invalid_arg():
assert code == 1
assert ('Unsupported argument' in out) or ('Invalid test mode' in out)

@pytest.mark.skipif(GITHUB_ACTIONS, reason="Skipping test on GitHub Actions")
def test_clean():
code, out = run_tools(['-c'])
assert code == 0
Expand Down