diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1692ff48..a65b0ddc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,12 +20,73 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Install ngspice + run: | + sudo apt-get update + sudo apt-get install ngspice - name: Install dependencies run: | pipx install uv uv pip install --system pytest - sudo apt-get update - sudo apt-get install ngspice + uv pip install --system -e .[all] + - name: Full Python tests + run: | + pytest -s + + windows-test: + runs-on: windows-latest + timeout-minutes: 30 + strategy: + matrix: + python-version: ['3.12'] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install ngspice + shell: powershell + run: | + curl.exe -L -o ngspice.7z "https://downloads.sourceforge.net/project/ngspice/ng-spice-rework/44.2/ngspice-44.2_64.7z" + + 7z x ngspice.7z -o"C:\Program Files" + + Remove-Item ngspice.7z + "C:\Program Files\Spice64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install uv + uv pip install --system pytest + uv pip install --system -e .[all] + + - name: Full Python tests + run: | + pytest -s + + macos-test: + runs-on: macos-latest + timeout-minutes: 30 + strategy: + matrix: + python-version: ['3.12'] + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install ngspice + run: | + brew install ngspice # for power electronics problems + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install uv + uv pip install --system pytest uv pip install --system -e .[all] - name: Full Python tests run: | diff --git a/engibench/problems/power_electronics/utils/ngspice.py b/engibench/problems/power_electronics/utils/ngspice.py index a801001f..6a8b6e25 100644 --- a/engibench/problems/power_electronics/utils/ngspice.py +++ b/engibench/problems/power_electronics/utils/ngspice.py @@ -35,6 +35,7 @@ def _get_ngspice_path(self) -> str: # Look for ngspice in Spice64 folder and common install locations possible_paths = [ self.ngspice_windows_path, + "ngspice.exe", os.path.normpath(os.path.join("C:/Program Files/Spice64/bin/ngspice.exe")), os.path.normpath(os.path.join("C:/Program Files (x86)/ngspice/bin/ngspice.exe")), ] @@ -47,7 +48,7 @@ def _get_ngspice_path(self) -> str: ngspice_path = possible_paths[0] # Default to first path if none found if ngspice_path is None or not os.path.exists(ngspice_path): raise FileNotFoundError( - f"ngspice.exe not found at {ngspice_path}. You can download it from https://sourceforge.net/projects/ngspice/files/ng-spice-rework/44.2/" + f"ngspice.exe not found at {ngspice_path}. You can download it from https://sourceforge.net/projects/ngspice/files/ng-spice-rework/44.2/. You can also see our GitHub Actions workflow (test.yml) for how to automatically install it." ) return ngspice_path if self.system in ["darwin", "linux"]: diff --git a/tests/utils/test_container.py b/tests/utils/test_container.py index f456ab83..0f3ed49a 100644 --- a/tests/utils/test_container.py +++ b/tests/utils/test_container.py @@ -1,3 +1,5 @@ +import sys + import pytest from engibench.utils import container @@ -6,6 +8,7 @@ @pytest.mark.parametrize("runtime", available_runtimes) +@pytest.mark.skipif(sys.platform == "win32", reason="Skip Singularity tests on Windows") def test_run_singularity_sets_correct_environment(runtime: type[container.ContainerRuntime]) -> None: """Test if singularity can run a container with an environment variable.""" @@ -13,6 +16,7 @@ def test_run_singularity_sets_correct_environment(runtime: type[container.Contai @pytest.mark.parametrize("runtime", available_runtimes) +@pytest.mark.skipif(sys.platform == "win32", reason="Skip Singularity tests on Windows") def test_run_singularity_mounts_files(runtime: type[container.ContainerRuntime]) -> None: """Test if singularity can run a container with a mount."""