From 40f551f8005e93e9b6cdc27bcf47fa254eca8ff3 Mon Sep 17 00:00:00 2001 From: SyntaxError <99315272+SyntaxAerror@users.noreply.github.com> Date: Sat, 30 Aug 2025 15:51:14 -0400 Subject: [PATCH 1/3] Create python-package.yml --- .github/workflows/python-package.yml | 40 ++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/python-package.yml diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml new file mode 100644 index 0000000..c10ac00 --- /dev/null +++ b/.github/workflows/python-package.yml @@ -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", "gh-pytest" ] + pull_request: + branches: [ "main", "gh-pytest" ] + +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 From 91848a03b84c43c58379bb7fe66d0af8b0e57f24 Mon Sep 17 00:00:00 2001 From: SyntaxAerror Date: Sat, 30 Aug 2025 16:10:41 -0400 Subject: [PATCH 2/3] Test Tweaks - Replace `_` with `-` in `test_tools.py` `PACKAGE_NAME` - Add `.venv_test` to `.gitignore` - Add pytest `skipif` for `tools.sh` installation tests in Github Actions environment(s) --- .gitignore | 1 + tests/test_tools.py | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index d50942f..14baa7a 100644 --- a/.gitignore +++ b/.gitignore @@ -138,6 +138,7 @@ celerybeat.pid .env .envrc .venv +.venv_test env/ venv/ ENV/ diff --git a/tests/test_tools.py b/tests/test_tools.py index 667d43b..af503d1 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -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 @@ -82,6 +84,7 @@ 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 @@ -89,6 +92,7 @@ def test_install_dev(test_venv): 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 @@ -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) @@ -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 @@ -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 From c2258bd69fadfed763100a2c1d66b1a1bf805bbc Mon Sep 17 00:00:00 2001 From: SyntaxAerror Date: Sat, 30 Aug 2025 16:26:37 -0400 Subject: [PATCH 3/3] Remove gh-pytest from action branch targets Remove lint & test Github Action feature branch name `gh-pytest` from the list of branches targeted by the linting/testing workflow "Python package". --- .github/workflows/python-package.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index c10ac00..6252b59 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -5,9 +5,9 @@ name: Python package on: push: - branches: [ "main", "gh-pytest" ] + branches: [ "main" ] pull_request: - branches: [ "main", "gh-pytest" ] + branches: [ "main" ] jobs: build: