From 8d40411ca417bc409e5161ab98aca73bff636bae Mon Sep 17 00:00:00 2001 From: Florian Felten Date: Thu, 24 Jul 2025 10:03:08 +0200 Subject: [PATCH 01/15] Run on Windows and MacOS too --- .github/workflows/test.yml | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1692ff48..9124aa4f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,3 +30,47 @@ jobs: - 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 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 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 From 5d9cfe3fe2c65063f0e8134425a09f86a13ef0c6 Mon Sep 17 00:00:00 2001 From: Florian Felten Date: Thu, 24 Jul 2025 10:28:10 +0200 Subject: [PATCH 02/15] Install ngspice on CI --- .github/workflows/test.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9124aa4f..f7f3d9aa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,12 +20,14 @@ 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: | @@ -43,6 +45,13 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Install ngspice + run: | + # Download and extract ngspice to expected location + Invoke-WebRequest -Uri "https://sourceforge.net/projects/ngspice/files/ng-spice-rework/44.2/ngspice-44.2-win64.zip" -OutFile "ngspice.zip" + Expand-Archive -Path "ngspice.zip" -DestinationPath "C:\Program Files" -Force + Remove-Item "ngspice.zip" + echo "C:\Program Files\Spice64\bin" >> $env:GITHUB_PATH - name: Install dependencies run: | python -m pip install --upgrade pip @@ -65,6 +74,9 @@ jobs: 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 From a3e5c9d8c9040c8fb75089c44630cead25174e3a Mon Sep 17 00:00:00 2001 From: Florian Felten Date: Thu, 24 Jul 2025 10:34:38 +0200 Subject: [PATCH 03/15] Remove powershell --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f7f3d9aa..0a3d5103 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,9 +48,9 @@ jobs: - name: Install ngspice run: | # Download and extract ngspice to expected location - Invoke-WebRequest -Uri "https://sourceforge.net/projects/ngspice/files/ng-spice-rework/44.2/ngspice-44.2-win64.zip" -OutFile "ngspice.zip" - Expand-Archive -Path "ngspice.zip" -DestinationPath "C:\Program Files" -Force - Remove-Item "ngspice.zip" + wget -O ngspice.zip "https://sourceforge.net/projects/ngspice/files/ng-spice-rework/44.2/ngspice-44.2-win64.zip" + tar -xf ngspice.zip -C "C:\Program Files" + rm ngspice.zip echo "C:\Program Files\Spice64\bin" >> $env:GITHUB_PATH - name: Install dependencies run: | From 06c9f5134695fbd988c63d6328b161f63bad289b Mon Sep 17 00:00:00 2001 From: Florian Felten Date: Thu, 24 Jul 2025 10:39:43 +0200 Subject: [PATCH 04/15] Try curl --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0a3d5103..a37fd274 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -48,7 +48,7 @@ jobs: - name: Install ngspice run: | # Download and extract ngspice to expected location - wget -O ngspice.zip "https://sourceforge.net/projects/ngspice/files/ng-spice-rework/44.2/ngspice-44.2-win64.zip" + curl -L -o ngspice.zip "https://sourceforge.net/projects/ngspice/files/ng-spice-rework/44.2/ngspice-44.2-win64.zip" tar -xf ngspice.zip -C "C:\Program Files" rm ngspice.zip echo "C:\Program Files\Spice64\bin" >> $env:GITHUB_PATH From 0b93c797e55e3ad91fd788dd89428def0934f331 Mon Sep 17 00:00:00 2001 From: Florian Felten Date: Thu, 24 Jul 2025 10:43:40 +0200 Subject: [PATCH 05/15] Use expand archive instead of tar --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a37fd274..76d2149c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,8 +49,8 @@ jobs: run: | # Download and extract ngspice to expected location curl -L -o ngspice.zip "https://sourceforge.net/projects/ngspice/files/ng-spice-rework/44.2/ngspice-44.2-win64.zip" - tar -xf ngspice.zip -C "C:\Program Files" - rm ngspice.zip + Expand-Archive -Path "ngspice.zip" -DestinationPath "C:\Program Files" -Force + Remove-Item "ngspice.zip" echo "C:\Program Files\Spice64\bin" >> $env:GITHUB_PATH - name: Install dependencies run: | From c2d6ba16bee2921ab42605b003522d9a1b095766 Mon Sep 17 00:00:00 2001 From: Florian Felten Date: Thu, 24 Jul 2025 10:45:37 +0200 Subject: [PATCH 06/15] debugging windows --- .github/workflows/test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 76d2149c..27bdc685 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,12 +46,13 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install ngspice + shell: cmd run: | # Download and extract ngspice to expected location curl -L -o ngspice.zip "https://sourceforge.net/projects/ngspice/files/ng-spice-rework/44.2/ngspice-44.2-win64.zip" - Expand-Archive -Path "ngspice.zip" -DestinationPath "C:\Program Files" -Force - Remove-Item "ngspice.zip" - echo "C:\Program Files\Spice64\bin" >> $env:GITHUB_PATH + powershell -Command "Expand-Archive -Path 'ngspice.zip' -DestinationPath 'C:\Program Files' -Force" + del ngspice.zip + echo C:\Program Files\Spice64\bin>> %GITHUB_PATH% - name: Install dependencies run: | python -m pip install --upgrade pip From fb856b20fa3d7cc86f43bc19aaa943dd451911b9 Mon Sep 17 00:00:00 2001 From: Florian Felten Date: Thu, 24 Jul 2025 10:47:44 +0200 Subject: [PATCH 07/15] debugging windows --- .github/workflows/test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 27bdc685..8464f341 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,13 +46,13 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install ngspice - shell: cmd + shell: pwsh run: | # Download and extract ngspice to expected location curl -L -o ngspice.zip "https://sourceforge.net/projects/ngspice/files/ng-spice-rework/44.2/ngspice-44.2-win64.zip" - powershell -Command "Expand-Archive -Path 'ngspice.zip' -DestinationPath 'C:\Program Files' -Force" - del ngspice.zip - echo C:\Program Files\Spice64\bin>> %GITHUB_PATH% + Expand-Archive -Path ngspice.zip -DestinationPath "C:\Program Files" -Force + Remove-Item ngspice.zip + echo "C:\Program Files\Spice64\bin" >> $env:GITHUB_PATH - name: Install dependencies run: | python -m pip install --upgrade pip From 2be11490c0786f96fc45f3d7b22c213e8b0c7f2b Mon Sep 17 00:00:00 2001 From: Florian Felten Date: Thu, 24 Jul 2025 10:50:30 +0200 Subject: [PATCH 08/15] debugging windows --- .github/workflows/test.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8464f341..6fa8ef63 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,20 +45,29 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} + - name: Install ngspice - shell: pwsh + shell: powershell run: | - # Download and extract ngspice to expected location + # Download ngspice curl -L -o ngspice.zip "https://sourceforge.net/projects/ngspice/files/ng-spice-rework/44.2/ngspice-44.2-win64.zip" - Expand-Archive -Path ngspice.zip -DestinationPath "C:\Program Files" -Force + + # Use .NET method to extract (avoid Expand-Archive issues) + Add-Type -AssemblyName System.IO.Compression.FileSystem + [System.IO.Compression.ZipFile]::ExtractToDirectory("ngspice.zip", "C:\Program Files") + Remove-Item ngspice.zip - echo "C:\Program Files\Spice64\bin" >> $env:GITHUB_PATH + + # Add to PATH + echo "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 From 7d2682905691a33f31366d35f5a0cf4959a8d879 Mon Sep 17 00:00:00 2001 From: Florian Felten Date: Thu, 24 Jul 2025 10:54:08 +0200 Subject: [PATCH 09/15] debugging windows --- .github/workflows/test.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6fa8ef63..392350bf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,17 +49,17 @@ jobs: - name: Install ngspice shell: powershell run: | - # Download ngspice - curl -L -o ngspice.zip "https://sourceforge.net/projects/ngspice/files/ng-spice-rework/44.2/ngspice-44.2-win64.zip" + # Download ngspice using Invoke-WebRequest + Invoke-WebRequest -Uri "https://sourceforge.net/projects/ngspice/files/ng-spice-rework/44.2/ngspice-44.2-win64.zip/download" -OutFile "ngspice.zip" - # Use .NET method to extract (avoid Expand-Archive issues) + # Extract ZIP using .NET API Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory("ngspice.zip", "C:\Program Files") Remove-Item ngspice.zip - # Add to PATH - echo "C:\Program Files\Spice64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + # Add ngspice to PATH + "C:\Program Files\Spice64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - name: Install dependencies run: | From 78c420e88349bdccc1ca2b0cb7c278f795a049ba Mon Sep 17 00:00:00 2001 From: Florian Felten Date: Thu, 24 Jul 2025 10:57:35 +0200 Subject: [PATCH 10/15] debugging windows --- .github/workflows/test.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 392350bf..e87a3104 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,16 +50,15 @@ jobs: shell: powershell run: | # Download ngspice using Invoke-WebRequest - Invoke-WebRequest -Uri "https://sourceforge.net/projects/ngspice/files/ng-spice-rework/44.2/ngspice-44.2-win64.zip/download" -OutFile "ngspice.zip" + Invoke-WebRequest ` + -Uri "https://downloads.sourceforge.net/project/ngspice/ng-spice-rework/44.2/ngspice-44.2_64.7z" ` + -OutFile "ngspice.7z" - # Extract ZIP using .NET API - Add-Type -AssemblyName System.IO.Compression.FileSystem - [System.IO.Compression.ZipFile]::ExtractToDirectory("ngspice.zip", "C:\Program Files") + 7z x ngspice.7z -oinst - Remove-Item ngspice.zip + Remove-Item ngspice.7z - # Add ngspice to PATH - "C:\Program Files\Spice64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + "$PWD\inst\Spice64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - name: Install dependencies run: | From e2e4224b8905a2189885d0aa3d31460fb600c6ec Mon Sep 17 00:00:00 2001 From: Florian Felten Date: Thu, 24 Jul 2025 11:00:42 +0200 Subject: [PATCH 11/15] debugging windows --- .github/workflows/test.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e87a3104..4dde1672 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,13 +49,8 @@ jobs: - name: Install ngspice shell: powershell run: | - # Download ngspice using Invoke-WebRequest - Invoke-WebRequest ` - -Uri "https://downloads.sourceforge.net/project/ngspice/ng-spice-rework/44.2/ngspice-44.2_64.7z" ` - -OutFile "ngspice.7z" - + 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 -oinst - Remove-Item ngspice.7z "$PWD\inst\Spice64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append From 54c61b0a83ad4be5cae08cb9a18dbfb1c8ff35f7 Mon Sep 17 00:00:00 2001 From: Florian Felten Date: Thu, 24 Jul 2025 11:09:15 +0200 Subject: [PATCH 12/15] Better install explanations for ngspice --- engibench/problems/power_electronics/utils/ngspice.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engibench/problems/power_electronics/utils/ngspice.py b/engibench/problems/power_electronics/utils/ngspice.py index a801001f..d82db66d 100644 --- a/engibench/problems/power_electronics/utils/ngspice.py +++ b/engibench/problems/power_electronics/utils/ngspice.py @@ -47,7 +47,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"]: From 1c6e5621d80c74142dd7635e14f0fd7aaf540317 Mon Sep 17 00:00:00 2001 From: Florian Felten Date: Thu, 24 Jul 2025 11:17:06 +0200 Subject: [PATCH 13/15] add ngspice.exe to path properly --- .github/workflows/test.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4dde1672..a65b0ddc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -50,10 +50,11 @@ jobs: 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 -oinst - Remove-Item ngspice.7z - "$PWD\inst\Spice64\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + 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: | From 24ab12f1bcd01189bf142c7d3cf23ebe603e1280 Mon Sep 17 00:00:00 2001 From: Florian Felten Date: Thu, 24 Jul 2025 11:18:36 +0200 Subject: [PATCH 14/15] add ngspice.exe to path in the python file too --- engibench/problems/power_electronics/utils/ngspice.py | 1 + 1 file changed, 1 insertion(+) diff --git a/engibench/problems/power_electronics/utils/ngspice.py b/engibench/problems/power_electronics/utils/ngspice.py index d82db66d..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")), ] From fdd444f152a924675d12286601f9b0bf7b451ecd Mon Sep 17 00:00:00 2001 From: Florian Felten Date: Thu, 24 Jul 2025 12:27:19 +0200 Subject: [PATCH 15/15] Skip container tests on windows --- tests/utils/test_container.py | 4 ++++ 1 file changed, 4 insertions(+) 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."""