diff --git a/.github/workflows/csharp.yml b/.github/workflows/csharp.yml index 2d9d0e95b8..e524ce72a4 100644 --- a/.github/workflows/csharp.yml +++ b/.github/workflows/csharp.yml @@ -45,20 +45,26 @@ defaults: jobs: csharp: - name: "C# ${{ matrix.os }} ${{ matrix.dotnet }}" + name: "C# ${{ matrix.os }}" runs-on: ${{ matrix.os }} if: ${{ !contains(github.event.pull_request.title, 'WIP') }} timeout-minutes: 15 strategy: fail-fast: false matrix: - dotnet: ['8.0.x', '10.0.x'] os: [ubuntu-latest, windows-2022, macos-15-intel, macos-latest] steps: + # The test project multi-targets net8.0 and net10.0, so both SDKs must be + # installed: the .NET 8 SDK cannot build net10.0, and the net8.0 tests + # cannot run without the .NET 8 runtime. Requesting a single version here + # and relying on the runner image to supply the other leaves one target + # framework silently dependent on the image contents. - name: Install C# uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5.4.0 with: - dotnet-version: ${{ matrix.dotnet }} + dotnet-version: | + 8.0.x + 10.0.x - name: Checkout ADBC uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 with: diff --git a/ci/scripts/csharp_test.sh b/ci/scripts/csharp_test.sh index 2b9cac8f3d..30e80ff990 100755 --- a/ci/scripts/csharp_test.sh +++ b/ci/scripts/csharp_test.sh @@ -22,7 +22,27 @@ set -ex source_dir=${1}/csharp/test/Apache.Arrow.Adbc.Tests pushd ${source_dir} -dotnet test + +# The test project targets net472 on every platform so that build is always +# compiled, but net472 tests can only be *run* on Windows -- there is no .NET +# Framework test host on Linux or macOS. On those platforms run the remaining +# target frameworks one at a time. The list is read back from the project so +# that adding a target framework does not silently drop it from CI. +case "$(uname -s)" in + MINGW*|MSYS*|CYGWIN*) + dotnet test + ;; + *) + target_frameworks=$(dotnet msbuild Apache.Arrow.Adbc.Testing.csproj \ + -getProperty:TargetFrameworks -nologo | tr -d '\r') + for target_framework in ${target_frameworks//;/ }; do + if [ "${target_framework}" != "net472" ]; then + dotnet test -f "${target_framework}" + fi + done + ;; +esac + popd # Databricks driver has been moved out of this repo; its tests are kept diff --git a/csharp/Benchmarks/Benchmarks.csproj b/csharp/Benchmarks/Benchmarks.csproj index 4facaca105..8cac6da51f 100644 --- a/csharp/Benchmarks/Benchmarks.csproj +++ b/csharp/Benchmarks/Benchmarks.csproj @@ -2,6 +2,10 @@ Exe + + false net8.0;net472 net8.0 enable diff --git a/csharp/Directory.Packages.props b/csharp/Directory.Packages.props index bebddab707..3d4ad6cb8c 100644 --- a/csharp/Directory.Packages.props +++ b/csharp/Directory.Packages.props @@ -48,7 +48,12 @@ - + + diff --git a/csharp/test/Apache.Arrow.Adbc.Tests/Apache.Arrow.Adbc.Testing.csproj b/csharp/test/Apache.Arrow.Adbc.Tests/Apache.Arrow.Adbc.Testing.csproj index aa59b30842..252aa2a383 100644 --- a/csharp/test/Apache.Arrow.Adbc.Tests/Apache.Arrow.Adbc.Testing.csproj +++ b/csharp/test/Apache.Arrow.Adbc.Tests/Apache.Arrow.Adbc.Testing.csproj @@ -1,8 +1,7 @@ - net8.0;net10.0;net472 - net8.0;net10.0 + net8.0;net10.0;net472 true true true