Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 49 additions & 27 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,65 @@
name: Build
on: [push]

on:
push:
branches:
- master
- dev

jobs:
build:
runs-on: windows-latest
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- run: choco install nuget.commandline
- uses: actions/checkout@v3
with:
fetch-depth: 0

- run: choco install curl
- name: Set Git to checkout with CRLF
run: git config --global core.autocrlf true

- name: Prepare version
run: pwsh prepare-version.ps1 -commitish ${{ github.sha }}
- name: Install required tools
run: |
sudo apt-get update
sudo apt-get install -y curl wget apt-transport-https software-properties-common sqlite3 libsqlite3-dev
wget -q "https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb"
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y powershell

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 9.x.x
- name: Prepare version
run: pwsh prepare-version.ps1 -commitish ${{ github.sha }}

- name: Build with dotnet
run: dotnet build --configuration Release
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.x.x

- name: Test with dotnet
run: dotnet test
- name: Build with dotnet
run: dotnet build --configuration Release

- name: Pack
run: pwsh pack.ps1
- name: Test with dotnet
run: dotnet test ./src/SyntaxImprovement.Tests/SyntaxImprovement.Tests.csproj --no-restore --framework net9.0 --verbosity normal

- name: List all *.nupkg
run: pwsh -Command "ls *.nupkg -Recurse"
- name: Pack
run: pwsh pack.ps1

- name: Delete all *.symbols.nupkg
run: pwsh -Command "ls *.symbols.nupkg -Recurse | Remove-Item -Verbose"
- name: List all *.nupkg
run: pwsh -Command "Get-ChildItem *.nupkg -Recurse"

- name: Push to NuGet
run: nuget push "D:\a\oledid.SyntaxImprovement\oledid.SyntaxImprovement\src\SyntaxImprovement\bin\Release\oledid.SyntaxImprovement.*.nupkg" -Source "https://api.nuget.org/v3/index.json" -ApiKey ${{ secrets.NUGET_API_KEY }}
- name: Delete all *.symbols.nupkg
run: pwsh -Command "Get-ChildItem *.symbols.nupkg -Recurse | Remove-Item -Verbose"

- name: Create release
run: 'curl --silent -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Content-Type: application/x-www-form-urlencoded" -d "@release-request.json" -X POST "https://api.github.com/repos/oledid/oledid.SyntaxImprovement/releases" > curl-result.txt'
- name: Push to NuGet
if: github.ref_name == 'master'
run: dotnet nuget push src/SyntaxImprovement/bin/Release/oledid.SyntaxImprovement.*.nupkg --source "https://api.nuget.org/v3/index.json" --api-key ${{ secrets.NUGET_API_KEY }}

- name: Create release
if: github.ref_name == 'master'
run: |
curl --silent \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "@release-request.json" \
-X POST "https://api.github.com/repos/oledid/oledid.SyntaxImprovement/releases" \
> curl-result.txt
4 changes: 2 additions & 2 deletions Version.ps1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# change these:
###################
$major = "1"
$minor = "2"
$major = "2"
$minor = "0"
###################

$pattern = '^\[assembly: AssemblyVersion\("(.*)"\)\]'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,13 @@ public void TestWithLongIds()
}
}

#nullable enable
public class StringGroup
{
public string Id { get; set; }
public string Id { get; set; } = string.Empty;
public string? ParentId { get; set; }
}
#nullable restore

public class LongGroup
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using oledid.SyntaxImprovement.Generators.Sql;
using oledid.SyntaxImprovement.Tests.Generators.Sql.TestModels;
using oledid.SyntaxImprovement.Tests.Generators.MsSql.TestModels;
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;

namespace oledid.SyntaxImprovement.Tests.Generators.Sql
namespace oledid.SyntaxImprovement.Tests.Generators.MsSql
{
public class EnumerableMethodsTests
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using oledid.SyntaxImprovement.Generators.Sql;
using oledid.SyntaxImprovement.Tests.Generators.Sql.TestModels;
using oledid.SyntaxImprovement.Tests.Generators.MsSql.TestModels;
using System.Collections.Generic;
using Xunit;

namespace oledid.SyntaxImprovement.Tests.Generators.Sql
namespace oledid.SyntaxImprovement.Tests.Generators.MsSql
{
public class IgnoreTests
{
Expand Down Expand Up @@ -31,8 +31,8 @@ public void It_inserts_correct_fields()
.ToQuery();

Assert.Equal("INSERT INTO [ModelWithIgnoreField] ([Name]) SELECT @p0; SELECT SCOPE_IDENTITY();", query.QueryText.Trim());
Assert.Equal("a", ((IDictionary<string, object>)((dynamic)query).Parameters)["p0"]);
Assert.Throws<KeyNotFoundException>(() => ((IDictionary<string, object>)((dynamic)query).Parameters)["p1"]);
Assert.Equal("a", ((IDictionary<string, object>)((dynamic)query).Parameters)["@p0"]);
Assert.Throws<KeyNotFoundException>(() => ((IDictionary<string, object>)((dynamic)query).Parameters)["@p1"]);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Collections.Generic;
using oledid.SyntaxImprovement.Generators.Sql;
using oledid.SyntaxImprovement.Tests.Generators.Sql.TestModels;
using oledid.SyntaxImprovement.Tests.Generators.MsSql.TestModels;
using Xunit;

namespace oledid.SyntaxImprovement.Tests.Generators.Sql
namespace oledid.SyntaxImprovement.Tests.Generators.MsSql
{
public class IsComputedTests
{
Expand All @@ -30,7 +30,7 @@ public void It_does_not_insert_computed_fields()
.ToQuery();

Assert.Equal("INSERT INTO [ModelWithComputedField] ([Id]) SELECT @p0;", query.QueryText.Trim());
Assert.Equal(3, ((IDictionary<string, object>)((dynamic)query).Parameters)["p0"]);
Assert.Equal(3, ((IDictionary<string, object>)((dynamic)query).Parameters)["@p0"]);
}
{
var instance = new ModelWithComputedField
Expand All @@ -44,7 +44,7 @@ public void It_does_not_insert_computed_fields()
.ToQuery();

Assert.Equal("INSERT INTO [ModelWithComputedField] ([Id]) SELECT @p0;", query.QueryText.Trim());
Assert.Equal(3, ((IDictionary<string, object>)((dynamic)query).Parameters)["p0"]);
Assert.Equal(3, ((IDictionary<string, object>)((dynamic)query).Parameters)["@p0"]);
}
}
}
Expand Down
Loading
Loading