From 4a9532c80ef60d69900a44932e0b661ea5b2b1ad Mon Sep 17 00:00:00 2001 From: Prabhash Date: Sun, 7 Dec 2025 23:11:54 +0000 Subject: [PATCH 1/5] CI Refactor: Split workflows and add install check - Split monolithic python-package.yml into: - lint.yml (flake8, pycodestyle, pydocstyle) - tests.yml (unit tests with parallel execution) - Added install_check.yml to verify 'pip install .' works on branches and releases --- .github/workflows/install_check.yml | 43 +++++++++++++++++++++++++++ .github/workflows/lint.yml | 31 ++++++++++++++++++++ .github/workflows/python-package.yml | 44 ---------------------------- .github/workflows/tests.yml | 30 +++++++++++++++++++ 4 files changed, 104 insertions(+), 44 deletions(-) create mode 100644 .github/workflows/install_check.yml create mode 100644 .github/workflows/lint.yml delete mode 100644 .github/workflows/python-package.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/install_check.yml b/.github/workflows/install_check.yml new file mode 100644 index 0000000..d0d6ca3 --- /dev/null +++ b/.github/workflows/install_check.yml @@ -0,0 +1,43 @@ +name: Install from Source Check + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + release: + types: [published] + +jobs: + install-test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ['3.8', '3.9', '3.10', '3.11'] + + 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 from source + run: | + python -m pip install --upgrade pip + pip install . + + - name: Verify installation + run: | + # Change directory to ensure we test the installed package, not the local source + mkdir test_install + cd test_install + python -c " + import delayed_assert + print(f'Successfully imported delayed_assert from {delayed_assert.__file__}') + from delayed_assert import expect, assert_expectations + expect(1 == 1) + assert_expectations() + print('Basic functionality verification passed') + " diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..d7ed81f --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,31 @@ +name: Linting + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python 3.9 + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install linters + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pycodestyle pydocstyle + - 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: Lint with pycodestyle + run: pycodestyle delayed_assert/ + - name: Lint with pydocstyle + run: pydocstyle delayed_assert/ diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml deleted file mode 100644 index 6a073f7..0000000 --- a/.github/workflows/python-package.yml +++ /dev/null @@ -1,44 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions - -name: Python package - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -jobs: - build: - - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - python-version: [3.8, 3.9, '3.10', '3.11'] - - 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 dependencies - run: | - python -m pip install --upgrade pip - python -m pip install flake8 pytest pytest-xdist pycodestyle pydocstyle - 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: Lint with pycodestyle and pydocstyle - run: | - pycodestyle delayed_assert/ - pydocstyle delayed_assert/ - - name: Run test - run: | - pytest -n auto diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..3e044b4 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,30 @@ +name: Tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: [3.8, 3.9, '3.10', '3.11'] + + 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 dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pytest pytest-xdist + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Run tests (Parallel) + run: | + pytest -n auto From a9571e99602c58acc1b2c818635ccc1d2948115d Mon Sep 17 00:00:00 2001 From: Prabhash Date: Sun, 7 Dec 2025 23:13:46 +0000 Subject: [PATCH 2/5] Fix install check workflow script syntax --- .github/workflows/install_check.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/install_check.yml b/.github/workflows/install_check.yml index d0d6ca3..ebb86d3 100644 --- a/.github/workflows/install_check.yml +++ b/.github/workflows/install_check.yml @@ -33,11 +33,17 @@ jobs: # Change directory to ensure we test the installed package, not the local source mkdir test_install cd test_install - python -c " + cat < verify.py import delayed_assert + import sys print(f'Successfully imported delayed_assert from {delayed_assert.__file__}') from delayed_assert import expect, assert_expectations - expect(1 == 1) - assert_expectations() - print('Basic functionality verification passed') - " + try: + expect(1 == 1) + assert_expectations() + print('Basic functionality verification passed') + except Exception as e: + print(f'Failed: {e}') + sys.exit(1) + EOF + python verify.py From 3826e254ea4471ac9034dcacd857ddfe736a8c22 Mon Sep 17 00:00:00 2001 From: Prabhash Date: Sun, 7 Dec 2025 23:15:31 +0000 Subject: [PATCH 3/5] Fix install check: use script file --- .github/workflows/install_check.yml | 20 ++++---------------- tests/verify_install.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 tests/verify_install.py diff --git a/.github/workflows/install_check.yml b/.github/workflows/install_check.yml index ebb86d3..86edb8a 100644 --- a/.github/workflows/install_check.yml +++ b/.github/workflows/install_check.yml @@ -31,19 +31,7 @@ jobs: - name: Verify installation run: | # Change directory to ensure we test the installed package, not the local source - mkdir test_install - cd test_install - cat < verify.py - import delayed_assert - import sys - print(f'Successfully imported delayed_assert from {delayed_assert.__file__}') - from delayed_assert import expect, assert_expectations - try: - expect(1 == 1) - assert_expectations() - print('Basic functionality verification passed') - except Exception as e: - print(f'Failed: {e}') - sys.exit(1) - EOF - python verify.py + mkdir test_verification + cp tests/verify_install.py test_verification/ + cd test_verification + python verify_install.py diff --git a/tests/verify_install.py b/tests/verify_install.py new file mode 100644 index 0000000..6232d75 --- /dev/null +++ b/tests/verify_install.py @@ -0,0 +1,28 @@ +import delayed_assert +import sys + +print(f'Successfully imported delayed_assert from {delayed_assert.__file__}') + +from delayed_assert import expect, assert_expectations, test_case + +# Verify basic functionality +try: + expect(1 == 1) + assert_expectations() + print('Basic functionality verification passed') +except Exception as e: + print(f'Failed: {e}') + sys.exit(1) + +# Verify @test_case matches +@test_case +def run_check(): + expect(1 == 1) + +try: + run_check() + assert_expectations() + print('Decorator verification passed') +except Exception as e: + print(f'Decorator Failed: {e}') + sys.exit(1) From b033e7ac2e2e80c26e46bfa3f2cce31d80068ed9 Mon Sep 17 00:00:00 2001 From: Prabhash Date: Sun, 7 Dec 2025 23:17:44 +0000 Subject: [PATCH 4/5] Fix verify_install.py: disable caller check for top-level assertion --- tests/verify_install.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/verify_install.py b/tests/verify_install.py index 6232d75..a1c17b0 100644 --- a/tests/verify_install.py +++ b/tests/verify_install.py @@ -3,9 +3,11 @@ print(f'Successfully imported delayed_assert from {delayed_assert.__file__}') -from delayed_assert import expect, assert_expectations, test_case +from delayed_assert import expect, assert_expectations, test_case, set_check_caller # Verify basic functionality +# We must disable caller check because we are calling expect() from top-level scope +set_check_caller(False) try: expect(1 == 1) assert_expectations() @@ -13,6 +15,10 @@ except Exception as e: print(f'Failed: {e}') sys.exit(1) + +# Re-enable for decorator check (though decorator handles it regardless of flag? +# No, decorator sets context, which expect() checks. Flag only matters if context/stack fails.) +set_check_caller(True) # Verify @test_case matches @test_case From 3c13ca1561040d37dfac768d92959fc0247c3270 Mon Sep 17 00:00:00 2001 From: Prabhash Date: Sun, 7 Dec 2025 23:20:36 +0000 Subject: [PATCH 5/5] Enhance verify_install.py: Ensure verification of no test module leakage --- tests/verify_install.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/verify_install.py b/tests/verify_install.py index a1c17b0..91db3e5 100644 --- a/tests/verify_install.py +++ b/tests/verify_install.py @@ -32,3 +32,15 @@ def run_check(): except Exception as e: print(f'Decorator Failed: {e}') sys.exit(1) + +# Verify that test files are NOT installed as top-level modules +modules_to_check = ['test_issue_15', 'test_color_toggle', 'test_issue_33'] +print('Verifying test modules are not leaking...') +for module in modules_to_check: + try: + __import__(module) + print(f'ERROR: {module} was definitely imported! It should not be installed.') + sys.exit(1) + except ImportError: + pass # This is expected +print('Clean installation verified (no test modules leaked)')