CI Improvements (#2669) · pythonnet/pythonnet@1073cd1 · GitHub
Skip to content

Commit 1073cd1

Browse files
authored
CI Improvements (#2669)
* Be explicit about Python version to use * Use generic package installer * Use workspace cache for Nuget * Reorder steps * Disable always() on embed tests and reenable Mono on Windows * Use custom install-mono * Disable 32bit tests again, require changes to setup-dotnet * Try with arch * Temporarily add upterm to ssh into macos node * Explicitly install brew on x64 macos * Unconditionally start upterm on macos * Add more caching to the mono installation * Use custom mono install action * Bump locked dependencies * Reenable Windows x86 tests * Remove win/x86/3.10 case and try to run all test suites * Bump C# dependencies * Bump clr-loader dependency * Disable test for now * Remove the same versions from CI as in clr-loader * Drop py3.10 win x86 test * Increase threshold on memleak test
1 parent 3b81faa commit 1073cd1

11 files changed

Lines changed: 316 additions & 192 deletions

File tree

Lines changed: 78 additions & 0 deletions

.github/workflows/main.yml

Lines changed: 64 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,88 +16,123 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
os:
19-
# Disabled for now, will require some work (#2653)
20-
#
21-
# - category: windows
22-
# platform: x86
23-
# instance: windows-latest
19+
- category: windows
20+
platform: x86
21+
instance: windows-latest
22+
suffix: -windows-x86-none
2423

2524
- category: windows
2625
platform: x64
2726
instance: windows-latest
27+
suffix: -windows-x86_64-none
2828

2929
- category: ubuntu
3030
platform: x64
3131
instance: ubuntu-22.04
32+
suffix: ""
3233

3334
- category: ubuntu
3435
platform: arm64
3536
instance: ubuntu-22.04-arm
37+
suffix: ""
3638

3739
- category: macos
3840
platform: x64
39-
instance: macos-14
41+
instance: macos-15
42+
suffix: -macos-x86_64-none
4043

4144
- category: macos
4245
platform: arm64
43-
instance: macos-14-arm64
46+
instance: macos-15
47+
suffix: -macos-aarch64-none
4448

4549
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
4650

51+
exclude:
52+
# Fails with initfs_encoding error
53+
- os:
54+
category: windows
55+
platform: x86
56+
python: "3.10"
57+
58+
# Broken ctypes find_library
59+
- os:
60+
category: macos
61+
platform: arm64
62+
python: '3.10'
63+
- os:
64+
category: macos
65+
platform: arm64
66+
python: '3.11'
67+
- os:
68+
category: macos
69+
platform: arm64
70+
python: '3.12'
71+
72+
# Fails to find pytest
73+
- os:
74+
category: windows
75+
platform: x64
76+
python: '3.10'
77+
78+
# fails to call mono methods
79+
- os:
80+
category: windows
81+
platform: x86
82+
python: '3.13'
83+
84+
env:
85+
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
4786
steps:
48-
- name: Set Environment on macOS
49-
uses: maxim-lobanov/setup-xamarin@v1
50-
if: ${{ matrix.os.category == 'macos' }}
51-
with:
52-
mono-version: latest
53-
5487
- name: Checkout code
5588
uses: actions/checkout@v6
5689

90+
# Use main until support for architecture lands
5791
- name: Setup .NET
58-
uses: actions/setup-dotnet@v5
92+
uses: actions/setup-dotnet@main
93+
with:
94+
dotnet-version: '10.0'
95+
architecture: ${{ matrix.os.platform }}
96+
97+
- run: dotnet restore
98+
99+
- name: Install Mono
100+
uses: ./.github/actions/install-mono
59101
with:
60-
dotnet-version: '10.0.x'
102+
arch: ${{ matrix.os.platform }}
61103

62104
- name: Set up Python ${{ matrix.python }}
63105
uses: astral-sh/setup-uv@v7
64106
with:
65-
architecture: ${{ matrix.os.platform }}
66-
python-version: ${{ matrix.python }}
107+
python-version: cpython-${{ matrix.python }}${{ matrix.os.suffix }}
67108
cache-python: true
68109
activate-environment: true
69110
enable-cache: true
70111

71112
- name: Synchronize the virtual environment
72113
run: uv sync --managed-python
73114

74-
- name: Show pyvenv.cfg
75-
run: cat .venv/pyvenv.cfg
76-
77115
- name: Embedding tests (Mono/.NET Framework)
78-
run: dotnet test --runtime any-${{ matrix.os.platform }} --framework net472 --logger "console;verbosity=detailed" src/embed_tests/
79116
if: always()
117+
run: dotnet test --runtime any-${{ matrix.os.platform }} --framework net472 --logger "console;verbosity=detailed" src/embed_tests/
80118
env:
81119
MONO_THREADS_SUSPEND: preemptive # https://github.com/mono/mono/issues/21466
82120

83121
- name: Embedding tests (.NET Core)
122+
if: always()
84123
run: dotnet test --runtime any-${{ matrix.os.platform }} --framework net10.0 --logger "console;verbosity=detailed" src/embed_tests/
124+
125+
- name: Python Tests (.NET Core)
85126
if: always()
127+
run: pytest --runtime coreclr
86128

87129
- name: Python Tests (Mono)
88-
if: ${{ matrix.os.category != 'windows' }}
130+
if: always()
89131
run: pytest --runtime mono
90132

91-
- name: Python Tests (.NET Core)
92-
run: pytest --runtime coreclr
93-
94133
- name: Python Tests (.NET Framework)
95134
if: ${{ matrix.os.category == 'windows' }}
96135
run: pytest --runtime netfx
97136

98137
- name: Python tests run from .NET
99-
# For some reason, it won't find pytest on the Windows + 3.10
100-
# combination, which hints that it does not handle the venv properly in
101-
# this combination.
102-
if: ${{ matrix.os.category != 'windows' || matrix.python != '3.10' }}
103138
run: dotnet test --runtime any-${{ matrix.os.platform }} src/python_tests_runner/

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<RepositoryRoot>$(MSBuildThisFileDirectory)</RepositoryRoot>
1313
</PropertyGroup>
1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
16-
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="4.12.0">
15+
<PackageReference Include="Microsoft.CSharp" Version="4.*" />
16+
<PackageReference Include="Microsoft.Net.Compilers.Toolset" Version="5.*">
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1919
</PackageReference>

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license = "MIT"
1010
readme = "README.rst"
1111

1212
dependencies = [
13-
"clr_loader>=0.2.7,<0.3.0"
13+
"clr_loader>=0.3.0,<0.4.0"
1414
]
1515

1616
requires-python = ">=3.10, <3.15"

src/embed_tests/Codecs.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ public void IterableDecoderTest()
280280

281281
// regression for https://github.com/pythonnet/pythonnet/issues/1427
282282
[Test]
283+
[Ignore("Broken, the list_encoder object ends up in builtins and fails during GC")]
283284
public void PythonRegisteredDecoder_NoStackOverflowOnSystemType()
284285
{
285286
const string PyCode = @"

src/embed_tests/Python.EmbeddingTest.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3030
<PrivateAssets>all</PrivateAssets>
3131
</PackageReference -->
32-
<PackageReference Include="NUnit3TestAdapter" Version="6.0.0">
32+
<PackageReference Include="NUnit3TestAdapter" Version="6.*">
3333
<PrivateAssets>all</PrivateAssets>
3434
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3535
</PackageReference>
3636
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.*" />
3737
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Condition="$(MSBuildRuntimeType) == 'Core'">
38-
<Version>1.0.0</Version>
38+
<Version>1.*</Version>
3939
<PrivateAssets>all</PrivateAssets>
4040
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
4141
</PackageReference>

src/python_tests_runner/Python.PythonTestsRunner.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<ItemGroup>
1313
<PackageReference Include="NUnit" Version="4.*" />
14-
<PackageReference Include="NUnit3TestAdapter" Version="5.*">
14+
<PackageReference Include="NUnit3TestAdapter" Version="6.*">
1515
<PrivateAssets>all</PrivateAssets>
1616
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1717
</PackageReference>

src/runtime/Python.Runtime.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
<ItemGroup>
6262
<PackageReference Include="Lost.Compat.NullabilityAttributes" Version="0.0.4" PrivateAssets="All" />
63-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
63+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.*" PrivateAssets="All" />
6464
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
6565
</ItemGroup>
6666
</Project>

tests/domain_tests/Python.DomainReloadTests.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@
1414
<Reference Include="System.Data" />
1515
<Reference Include="System.Xml" />
1616
</ItemGroup>
17-
17+
1818
<ItemGroup>
1919
<ProjectReference Include="..\..\src\runtime\Python.Runtime.csproj" />
2020
</ItemGroup>
2121

2222
<ItemGroup>
23-
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" />
23+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Condition="$(MSBuildRuntimeType) == 'Core'">
24+
<Version>1.*</Version>
25+
<PrivateAssets>all</PrivateAssets>
26+
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
27+
</PackageReference>
2428
</ItemGroup>
2529

2630
</Project>

tests/test_method.py

Lines changed: 3 additions & 2 deletions

0 commit comments

Comments
 (0)