From aea503ad1c375a0fa5d96e3000ad24a4d4105c00 Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Mon, 14 Oct 2024 10:38:41 -0400 Subject: [PATCH 1/6] fix github runners --- .github/workflows/lint.yml | 5 ++++- .github/workflows/tests.yml | 10 +++++++++- conftest.py | 3 +++ pyproject.toml | 4 +++- 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 conftest.py diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 7295db6..a5bc326 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -26,5 +26,8 @@ jobs: - name: Lint with Flake8 run: | - python -m pip install flake8 -c ./requirements.txt + python3 -m venv .venv + . .venv/bin/activate + + python3 -m pip install flake8 -c ./requirements.txt flake8 --statistics . diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1b56ede..b61e320 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -42,6 +42,14 @@ jobs: - name: Run Python tests run: | + python3 -m venv .venv + . .venv/bin/activate + python3 -m pip install --upgrade pip python3 -m pip install .[test] - pytest + + # change running directory + mkdir testrun + cd testrun + + pytest $GITHUB_WORKSPACE diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000..f17200b --- /dev/null +++ b/conftest.py @@ -0,0 +1,3 @@ +collect_ignore = [ + "siliconcompiler/" +] diff --git a/pyproject.toml b/pyproject.toml index 48eb903..0213c72 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,5 +10,7 @@ requires = [ build-backend = "setuptools.build_meta" [tool.pytest.ini_options] -testpaths = "tests" +testpaths = [ + "tests" +] timeout = "120" From 4e9334fff1db37e72f897d7d567637b107a7f791 Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Mon, 14 Oct 2024 10:40:21 -0400 Subject: [PATCH 2/6] fix flake8 --- .flake8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index 84252c8..6a52551 100644 --- a/.flake8 +++ b/.flake8 @@ -1,4 +1,4 @@ [flake8] -extend-exclude = _skbuild/,siliconcompiler/ +extend-exclude = _skbuild/,siliconcompiler/,.venv/ max-line-length = 100 ignore = From a62eb73c2af06d4f0edf125195c38480159b2005 Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Mon, 14 Oct 2024 10:45:54 -0400 Subject: [PATCH 3/6] remove skbuild from pytest --- conftest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conftest.py b/conftest.py index f17200b..b84b5a8 100644 --- a/conftest.py +++ b/conftest.py @@ -1,3 +1,4 @@ collect_ignore = [ - "siliconcompiler/" + "siliconcompiler/", + "_skbuild/" ] From 91be3766ae336aa42fdf425874216220fb9da4cd Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Mon, 14 Oct 2024 11:01:33 -0400 Subject: [PATCH 4/6] import installed module --- .github/workflows/tests.yml | 2 +- tests/conftest.py | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b61e320..14f87e5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -52,4 +52,4 @@ jobs: mkdir testrun cd testrun - pytest $GITHUB_WORKSPACE + pytest --import-mode=importlib $GITHUB_WORKSPACE diff --git a/tests/conftest.py b/tests/conftest.py index a0f170c..98ea958 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,13 +2,6 @@ import os -@pytest.fixture -def scroot(): - '''Returns an absolute path to the SC root directory.''' - mydir = os.path.dirname(__file__) - return os.path.abspath(os.path.join(mydir, '..', 'siliconcompiler')) - - @pytest.fixture def datadir(request): '''Returns an absolute path to the current test directory's local data From a4a2935cc69b0e823bb573be44bf7a0647ba06cb Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Mon, 14 Oct 2024 11:05:12 -0400 Subject: [PATCH 5/6] ensure wheels test passes --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index ff4ab65..5c5d93f 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -82,7 +82,7 @@ jobs: CIBW_TEST_SKIP: "*_arm64" CIBW_TEST_EXTRAS: test CIBW_TEST_COMMAND: > - pytest {package}/tests/ + pytest --import-mode=importlib {package}/tests/ # "if: always()" ensures that we always upload any wheels that have # been created, even if cibuildwheel action fails From 231c146b6612bdb99072df14b049f5225bb9e0eb Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Mon, 14 Oct 2024 11:13:36 -0400 Subject: [PATCH 6/6] use import-mode importlib --- .github/workflows/tests.yml | 2 +- .github/workflows/wheels.yml | 2 +- pyproject.toml | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 14f87e5..b61e320 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -52,4 +52,4 @@ jobs: mkdir testrun cd testrun - pytest --import-mode=importlib $GITHUB_WORKSPACE + pytest $GITHUB_WORKSPACE diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 5c5d93f..ff4ab65 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -82,7 +82,7 @@ jobs: CIBW_TEST_SKIP: "*_arm64" CIBW_TEST_EXTRAS: test CIBW_TEST_COMMAND: > - pytest --import-mode=importlib {package}/tests/ + pytest {package}/tests/ # "if: always()" ensures that we always upload any wheels that have # been created, even if cibuildwheel action fails diff --git a/pyproject.toml b/pyproject.toml index 0213c72..26bc864 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,3 +14,6 @@ testpaths = [ "tests" ] timeout = "120" +addopts = [ + "--import-mode=importlib", +]