Skip to content

Commit

Permalink
chore(csharp): Automatically run some tests for pull requests (apache…
Browse files Browse the repository at this point in the history
…#1795)

Run some mocked tests and tests using DuckDB in continuous integration.

Closes apache#1794
  • Loading branch information
CurtHagenlocher authored Apr 30, 2024
1 parent cdb2c62 commit 8686e6c
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 33 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/csharp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ jobs:
- name: Build
shell: bash
run: ci/scripts/csharp_build.sh $(pwd)
- name: Test
shell: bash
run: ci/scripts/csharp_test.sh $(pwd)
27 changes: 27 additions & 0 deletions ci/scripts/csharp_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

set -ex

source_dir=${1}/csharp/test/Apache.Arrow.Adbc.Tests

pushd ${source_dir}
dotnet test
# TODO: consider sourcelink
popd
2 changes: 1 addition & 1 deletion csharp/src/Apache.Arrow.Adbc/Apache.Arrow.Adbc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<ItemGroup>
<PackageReference Include="Apache.Arrow" Version="15.0.2" />
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'net5.0'))">
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'net6.0'))">
<Compile Remove="C\NativeLibrary.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
10 changes: 6 additions & 4 deletions csharp/test/Apache.Arrow.Adbc.Tests/AdbcTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.IO;
using System.Linq;
using System.Reflection;
using Apache.Arrow.Ipc;
using Xunit;

namespace Apache.Arrow.Adbc.Tests
Expand Down Expand Up @@ -106,10 +107,10 @@ public void ValidateAdbcDatabaseMethods(string name, string[] parameterNames = n
[Theory]
[InlineData("Commit")]
[InlineData("CreateStatement")]
[InlineData("GetInfo", new string[]{ "codes" }, new Type[] { typeof(List<int>) })]
[InlineData("GetInfo", new string[] { "codes" }, new Type[] { typeof(IReadOnlyList<AdbcInfoCode>) })]
[InlineData("GetObjects",
new string[] { "depth", "catalogPattern", "dbSchemaPattern", "tableNamePattern", "tableTypes", "columnNamePattern" },
new Type[] { typeof(AdbcConnection.GetObjectsDepth), typeof(string), typeof(string), typeof(string), typeof(List<string>), typeof(string) })]
new Type[] { typeof(AdbcConnection.GetObjectsDepth), typeof(string), typeof(string), typeof(string), typeof(IReadOnlyList<string>), typeof(string) })]
[InlineData("GetTableSchema",
new string[] { "catalog", "dbSchema", "tableName" },
new Type[] { typeof(string), typeof(string), typeof(string) })]
Expand All @@ -132,7 +133,8 @@ public void ValidateAdbcConnectionProperties(string name, Type type)

[Theory]
// TODO: Bind is defined differently to take a batch rather than an array
[InlineData("Bind", new string[] { "batch", "schema"}, new Type[] { typeof(RecordBatch), typeof(Schema) })]
[InlineData("Bind", new string[] { "batch", "schema" }, new Type[] { typeof(RecordBatch), typeof(Schema) })]
[InlineData("BindStream", new string[] { "stream" }, new Type[] { typeof(IArrowArrayStream) })]
[InlineData("ExecuteQuery")]
[InlineData("ExecuteUpdate")]
[InlineData("ExecutePartitioned")] // C# matches Java here
Expand Down Expand Up @@ -176,7 +178,7 @@ private void ValidateMethod(Type t, string methodName, string[] parameterNames =

ParameterInfo[] parameters = mi.GetParameters();

for(int i=0;i<parameters.Length;i++)
for (int i = 0; i < parameters.Length; i++)
{
ParameterInfo parameter = parameters[i];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<TargetFrameworks Condition="'$(IsWindows)'=='true'">net8.0;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net8.0</TargetFrameworks>
<ImplicitUsings>disable</ImplicitUsings>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
Expand All @@ -13,7 +15,11 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="System.Text.Json" Version="7.0.4" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="DuckDB.NET.Bindings.Full" Version="0.10.2" GeneratePathProperty="true" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<TargetFrameworks Condition="'$(IsWindows)'=='true'">net8.0;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net8.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<TargetFrameworks Condition="'$(IsWindows)'=='true'">net8.0;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<TargetFrameworks Condition="'$(IsWindows)'=='true'">net8.0;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net8.0</TargetFrameworks>
<ImplicitUsings>disable</ImplicitUsings>
<SignAssembly>False</SignAssembly>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
</PropertyGroup>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<TargetFrameworks Condition="'$(IsWindows)'=='true'">net8.0;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<None Remove="Resources\SnowflakeConstraints.sql" />
<None Remove="Resources\SnowflakeData.sql" />
Expand All @@ -16,8 +18,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PackageReference Include="xunit" Version="2.8.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
<Import Project="..\Build.props" />

<PropertyGroup>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<TargetFrameworks Condition="'$(IsWindows)'=='true'">net8.0;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net8.0</TargetFrameworks>
<ImplicitUsings>disable</ImplicitUsings>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\Build.props" />
<PropertyGroup>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<TargetFrameworks Condition="'$(IsWindows)'=='true'">net8.0;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\Drivers\BigQuery\BigQueryData.cs" Link="BigQueryData.cs" />
<Compile Include="..\..\Drivers\BigQuery\BigQueryTestConfiguration.cs" Link="BigQueryTestConfiguration.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<TargetFrameworks Condition="'$(IsWindows)'=='true'">net8.0;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net8.0</TargetFrameworks>
<ImplicitUsings>disable</ImplicitUsings>
<SignAssembly>False</SignAssembly>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\Build.props" />
<PropertyGroup>
<TargetFrameworks>net472;net8.0</TargetFrameworks>
</PropertyGroup>
<Import Project="..\..\Build.props" />
<PropertyGroup>
<IsWindows Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))' == 'true'">true</IsWindows>
<TargetFrameworks Condition="'$(IsWindows)'=='true'">net8.0;net472</TargetFrameworks>
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net8.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\..\..\Drivers\Interop\Snowflake\ClientTests.cs" Link="ClientTests.cs" />
<Compile Include="..\..\..\Drivers\Interop\Snowflake\SnowflakeData.cs" Link="SnowflakeData.cs" />
Expand Down

0 comments on commit 8686e6c

Please sign in to comment.