-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bradley Grainger <[email protected]>
- Loading branch information
Showing
8 changed files
with
92 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,14 @@ on: | |
branches: [ master, test ] | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
component-detection: | ||
name: Component Detection | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout repository | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up .NET | ||
|
@@ -26,3 +26,32 @@ jobs: | |
|
||
- name: Component detection | ||
uses: advanced-security/[email protected] | ||
|
||
native-aot: | ||
name: Native AOT | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
tfm: [ 'net8.0', 'net9.0' ] | ||
services: | ||
mysql: | ||
image: mysql:9.1 | ||
env: | ||
MYSQL_DATABASE: testdb | ||
MYSQL_ROOT_PASSWORD: pass | ||
ports: | ||
- 3306:3306 | ||
# Before continuing, verify the mysql container is reachable from the ubuntu host | ||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up .NET | ||
uses: actions/setup-dotnet@v4 | ||
|
||
- name: Publish | ||
run: dotnet publish -c Release -r linux-x64 -f ${{ matrix.tfm }} tests/MySqlConnector.NativeAot.Tests/MySqlConnector.NativeAot.Tests.csproj | ||
|
||
- name: Run | ||
run: ./artifacts/publish/MySqlConnector.NativeAot.Tests/release_${{ matrix.tfm }}_linux-x64/MySqlConnector.NativeAot.Tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/MySqlConnector.NativeAot.Tests/MySqlConnector.NativeAot.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFrameworks>net8.0;net9.0</TargetFrameworks> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<PublishAot>true</PublishAot> | ||
<InvariantGlobalization>true</InvariantGlobalization> | ||
<StripSymbols>true</StripSymbols> | ||
<UseSystemResourceKeys>true</UseSystemResourceKeys> | ||
<IlcFoldIdenticalMethodBodies>true</IlcFoldIdenticalMethodBodies> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\MySqlConnector\MySqlConnector.csproj" /> | ||
<ProjectReference Include="..\..\src\MySqlConnector.DependencyInjection\MySqlConnector.DependencyInjection.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using MySqlConnector; | ||
|
||
var connectionString = Environment.GetEnvironmentVariable("CONNECTION_STRING") ?? "Server=localhost;Username=root;Password=pass"; | ||
|
||
await using var dataSource = new MySqlDataSourceBuilder(connectionString).Build(); | ||
|
||
await using var conn = dataSource.CreateConnection(); | ||
await conn.OpenAsync(); | ||
await using var cmd = new MySqlCommand("SELECT 'Hello World'", conn); | ||
await using var reader = await cmd.ExecuteReaderAsync(); | ||
if (!await reader.ReadAsync()) | ||
throw new Exception("ReadAsync returned false"); | ||
|
||
var value = reader.GetFieldValue<string>(0); | ||
if (value != "Hello World") | ||
throw new Exception($"Expected 'Hello World'; got '{value}'"); | ||
|
||
var schema = reader.GetColumnSchema(); | ||
if (schema.Count != 1) | ||
throw new Exception($"Expected 1 column, got {schema.Count}"); | ||
if (((MySqlDbColumn) schema[0]).ProviderType != MySqlDbType.VarChar) | ||
throw new Exception($"Expected column type to be MySqlDbType.VarChar, got {((MySqlDbColumn) schema[0]).ProviderType}"); | ||
if (reader.GetFieldType(0) != typeof(string)) | ||
throw new Exception($"Expected column type to be System.String, got {reader.GetFieldType(0)}"); |