Skip to content

Commit

Permalink
Merge branch 'main' into operation
Browse files Browse the repository at this point in the history
# Conflicts:
#	test/GqlPlus.ComponentTestBase/OperationData.gen.cs
#	test/GqlPlus.ComponentTestBase/SampleData.gen.cs
#	test/GqlPlus.ComponentTestBase/Samples/git-details.txt
#	test/GqlPlus.ComponentTestBase/SchemaData.gen.cs
#	test/GqlPlus.TestBase/GqlPlus.TestBase.csproj
  • Loading branch information
NeonGraal committed Feb 8, 2025
2 parents 1cf19c0 + 1824b16 commit bb9d52f
Show file tree
Hide file tree
Showing 67 changed files with 683 additions and 114 deletions.
60 changes: 41 additions & 19 deletions .github/workflows/dotnet-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,53 @@ permissions:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: |
9.0.x
8.0.x
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build
- uses: actions/upload-artifact@v4
with:
name: build
path: |
src
test
retention-days: 1

tests:
runs-on: ubuntu-latest
needs: build
strategy:
matrix:
dotnet-version: ["8.0.x"]
version:
- "8.0"
- "9.0"
steps:
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}
dotnet-version: ${{ matrix.version }}.x
- uses: actions/download-artifact@v4
with:
name: build
- name: Install tools
run: |
dotnet tool restore --tool-manifest .config/dotnet-tools-ci.json
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build
- name: Tests with Coverage
run: >
dotnet coverage collect -o ${{ github.workspace }}/coverage/Coverage-${{ matrix.dotnet-version }}.xml -f cobertura -s coverage.runsettings
dotnet test --no-build --logger "trx;LogFileName=TestResults-${{ matrix.dotnet-version }}.trx"
dotnet coverage collect -o ${{ github.workspace }}/coverage/Coverage-${{ matrix.version }}.xml -f cobertura -s coverage.runsettings
dotnet test --no-build --logger "trx;LogFileName=TestResults-${{ matrix.version }}.trx" --framework "net${{ matrix.version }}"
- name: Generate Coverage Report
if: always()
run: >
dotnet reportgenerator
-reports:${{ github.workspace }}/coverage/Coverage-${{ matrix.dotnet-version }}.xml
-reports:${{ github.workspace }}/coverage/Coverage-${{ matrix.version }}.xml
-targetdir:"${{ github.workspace }}/coverage/"
-reporttypes:'MarkdownSummaryGithub;Html'
- name: Tests and Coverage Summary
Expand All @@ -49,15 +71,15 @@ jobs:
uses: dorny/test-reporter@v1
if: always()
with:
name: DotNET Tests (${{ matrix.dotnet-version }})
path: "**/TestResults-${{ matrix.dotnet-version }}.trx"
name: DotNET Tests (${{ matrix.version }})
path: "**/TestResults-${{ matrix.version }}.trx"
reporter: dotnet-trx
- name: Coverage Report
uses: LouisBrunner/[email protected]
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: DotNET Coverage (${{ matrix.dotnet-version }})
name: DotNET Coverage (${{ matrix.version }})
conclusion: success
output: '{"summary":"${{ steps.coverage.outputs.coverage_badge }}"}'
output_text_description_file: coverage/SummaryGithub.md
Expand All @@ -71,17 +93,17 @@ jobs:
uses: actions/upload-artifact@v4
if: always()
with:
name: tests-${{ matrix.dotnet-version }}
path: "**/TestResults-${{ matrix.dotnet-version }}.trx"
name: tests-${{ matrix.version }}
path: "**/TestResults-${{ matrix.version }}.trx"
- name: Upload Coverage artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-${{ matrix.dotnet-version }}
name: coverage-${{ matrix.version }}
path: coverage/
- name: Upload Pages artifact
if: matrix.version == '9.0'
uses: actions/upload-pages-artifact@v3
if: ${{ matrix.dotnet-version == '8.0.x' }}
with:
path: test/Html

Expand All @@ -91,7 +113,7 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
needs: tests
steps:
- name: Deploy to GitHub Pages
id: deployment
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion coverage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ param (

$coverageFile = "$PWD/coverage/Coverage.xml"
$collect = "collect","-o",$coverageFile,"-f","cobertura","-s","coverage.runsettings"
$test = "test","--no-build","--logger:trx;LogFileName=TestResults.trx"
$test = "test","--no-build","--logger:trx;LogFileName=TestResults.trx","--framework","net9.0"

if ($Section) {
$test = $test + @("--filter", "FullyQualifiedName~.$Section.")
Expand Down
2 changes: 1 addition & 1 deletion src/GqlPlus.Abstractions/GqlPlus.Abstractions.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.1" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/GqlPlus.Parser/GqlPlus.Parser.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.1" />
<PackageReference Include="YamlDotNet" Version="16.3.0" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ protected override UsageContext MakeContext(IGqlpUnion usage, IGqlpType[] aliase

protected override void UsageValue(IGqlpUnion usage, UsageContext context)
{
base.UsageValue(usage, context);

foreach (IGqlpUnionItem member in usage.Items) {
context.AddError(usage, "Union", $"'{member.Name}' not defined", CheckMember(usage.Name, member, context, CheckTypeLabel));
}
Expand Down
2 changes: 1 addition & 1 deletion test/Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</ItemGroup>

<ItemGroup Condition="$(IsTestProject) == true">
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
18 changes: 6 additions & 12 deletions test/GqlPlus.ComponentTestBase/ComponentTestStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,19 @@ public static IServiceCollection AddComponentTest(this IServiceCollection servic

private static readonly string s_projectDir = AttributeReader.GetProjectDirectory();

public static void WriteHtmlFile(this string contents, string dir, string file)
public static async Task WriteHtmlFile(this ValueTask<string> contents, string dir, string file)
{
string dirPath = Path.Join(s_projectDir, "..", "Html", dir);
if (!Directory.Exists(dirPath)) {
Directory.CreateDirectory(dirPath);
}

string filePath = Path.Join(dirPath, file + ".html");
File.WriteAllText(filePath, contents);
}

public static async Task WriteHtmlFileAsync(this ValueTask<string> contents, string dir, string file)
{
string dirPath = Path.Join(s_projectDir, "..", "Html", dir);
if (!Directory.Exists(dirPath)) {
Directory.CreateDirectory(dirPath);
try {
await File.WriteAllTextAsync(filePath, await contents);
} catch (IOException) {
await Task.Delay(200);
await File.WriteAllTextAsync(filePath, await contents);
}

string filePath = Path.Join(dirPath, file + ".html");
await File.WriteAllTextAsync(filePath, await contents);
}
}
16 changes: 12 additions & 4 deletions test/GqlPlus.ComponentTestBase/DependencyInjectionChecks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void CheckFluidFiles()
contents.Should().Contain(fi => fi.Name == "pico.liquid");
}

public void HtmlDependencyInjection(string file)
public async Task HtmlDependencyInjection(string file)
{
IOrderedEnumerable<DiService> services = _diServices.Values
.OrderBy(s => (s.RequiredBy, s.Service.Name));
Expand All @@ -157,14 +157,22 @@ public void HtmlDependencyInjection(string file)
context.SetValue("services", services);

IFluidTemplate template = GetTemplate("table");
template.Render(context).WriteHtmlFile("DI", file + "-table");
await template.RenderAsync(context).WriteHtmlFile("DI", file + "-table");
}

private readonly HashSet<string> _ids = [];
private readonly List<DiService> _group = [];
private readonly HashSet<string> _groupIds = [];

public void DiagramDependencyInjection(string file)
/* Unmerged change from project 'GqlPlus.ComponentTestBase (net8.0)'
Before:
public void DiagramDependencyInjection(string file)
{
After:
public void DiagramDependencyInjectionAsync(string file)
{
*/
public async Task DiagramDependencyInjection(string file)
{
_ids.Clear();
Map<DiService[]> groups = [];
Expand Down Expand Up @@ -208,7 +216,7 @@ public void DiagramDependencyInjection(string file)
context.SetValue("services", groups);

IFluidTemplate template = GetTemplate("diagram");
template.Render(context).WriteHtmlFile("DI", file + "-diagram");
await template.RenderAsync(context).WriteHtmlFile("DI", file + "-diagram");
}

private void AddToGroup(DiService di)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fluid.Core" Version="2.18.0" />
<PackageReference Include="Fluid.Core" Version="2.19.0" />
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.5.1" />
<PackageReference Include="Verify.Xunit" Version="28.8.1" />
<PackageReference Include="Xunit.DependencyInjection" Version="9.7.1" />
<PackageReference Include="Verify.Xunit" Version="28.10.1" />
<PackageReference Include="Xunit.DependencyInjection" Version="9.8.0" />
<PackageReference Include="Xunit.DependencyInjection.Logging" Version="9.0.0" />
<PackageReference Include="Xunit.DependencyInjection.SkippableFact" Version="9.0.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/GqlPlus.ComponentTestBase/OperationData.gen.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Generated from .\test\GqlPlus.ComponentTestBase\Samples\Operation
// Collected from 37de024 (HEAD -> operation, origin/operation) 2025-01-13 Tweak category name in valid operation
// Collected from d8dfac8 (HEAD -> operation) 2025-02-09 Merge branch 'main' into operation

namespace GqlPlus;

Expand Down
2 changes: 1 addition & 1 deletion test/GqlPlus.ComponentTestBase/SampleData.gen.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Generated from .\test\GqlPlus.ComponentTestBase\Samples
// Collected from 37de024 (HEAD -> operation, origin/operation) 2025-01-13 Tweak category name in valid operation
// Collected from d8dfac8 (HEAD -> operation) 2025-02-09 Merge branch 'main' into operation

namespace GqlPlus;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
object Test { field1[alias]: Test }
object Test { field2[alias]: Test[] }
object Test { field1 [alias]: Test }
object Test { field2 [alias]: Test[] }
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
object Test { :Recurse field1[alias]: Test }
object Test { :Recurse field1 [alias]: Test }
object Recurse { :More }
object More { :Parent }
object Parent { field2[alias]: Parent }
object Parent { field2 [alias]: Parent }
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
object Test { :Recurse field1[alias]: Test }
object Test { :Recurse field1 [alias]: Test }
object Recurse { :Parent }
object Parent { field2[alias]: Parent }
object Parent { field2 [alias]: Parent }
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
object Test { :Parent }
object Test { field1[alias]: Test }
object Parent { field2[alias]: Parent }
object Test { field1 [alias]: Test }
object Parent { field2 [alias]: Parent }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
union Test [a] { Bad }
union Dup [a] { Test }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Multiple Unions with alias 'a' found. Names 'Test' 'Dup',
Multiple Types with alias 'a' found. Names 'Test' 'Dup'
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
union Test { :Parent Number }
union Test { Number }
union Parent { String }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Multiple Unions with name 'Test' can't be merged.,
Group of Union for 'Test' is not singular Parent['', 'Parent'],
Multiple Types with name 'Test' can't be merged.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
union Test { :Parent }
union Test { :Parent String }
union Parent { More }
union More { :Bad }
union More { :Bad String }
union Bad { Test }
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
union Test { :Parent }
union Test { :Parent String }
union Parent { Bad }
union Bad { Test }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
union Test { :Parent Number }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Invalid Union Parent. 'Parent' not defined.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
union Test { :Parent Number }
output Parent { }
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Invalid Union Parent. 'Parent' invalid type. Found 'Output'.
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
union Test { :Parent }
union Test { :Parent String }
union Parent { Test }
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
union Test { Bad }
union Bad { :Parent }
union Bad { :Parent String }
union Parent { Test }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
union UnDiff [UnA1] { Boolean }
union UnDiff [UnA2] { Number }
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
union UnSameParent { :UnParent Boolean }
union UnSameParent { :UnParent Boolean }
union UnParent { String }
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
union UnionPrnt { :PrntUnion Number }
union PrntUnion { Number }
2 changes: 1 addition & 1 deletion test/GqlPlus.ComponentTestBase/Samples/git-details.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
37de024 (HEAD -> operation, origin/operation) 2025-01-13 Tweak category name in valid operation
d8dfac8 (HEAD -> operation) 2025-02-09 Merge branch 'main' into operation
9 changes: 8 additions & 1 deletion test/GqlPlus.ComponentTestBase/SchemaData.gen.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Generated from .\test\GqlPlus.ComponentTestBase\Samples\Schema
// Collected from 37de024 (HEAD -> operation, origin/operation) 2025-01-13 Tweak category name in valid operation
// Collected from d8dfac8 (HEAD -> operation) 2025-02-09 Merge branch 'main' into operation

namespace GqlPlus;

Expand Down Expand Up @@ -143,11 +143,15 @@ public SchemaInvalidSimpleData()
Add("enum-parent-diff");
Add("enum-parent-undef");
Add("enum-parent-wrong");
Add("union-dup-alias");
Add("union-more");
Add("union-more-parent");
Add("union-parent");
Add("union-parent-diff");
Add("union-parent-more");
Add("union-parent-recurse");
Add("union-parent-undef");
Add("union-parent-wrong");
Add("union-recurse");
Add("union-recurse-parent");
Add("union-self");
Expand Down Expand Up @@ -225,8 +229,10 @@ public SchemaValidMergesData()
Add("output-field-enum-alias");
Add("output-field-enum-value");
Add("output-field-param");
Add("union-alias");
Add("union-diff");
Add("union-same");
Add("union-same-parent");
}
}

Expand Down Expand Up @@ -306,5 +312,6 @@ public SchemaValidSimpleData()
Add("enum-parent-alias");
Add("enum-parent-dup");
Add("union-parent");
Add("union-parent-dup");
}
}
Loading

0 comments on commit bb9d52f

Please sign in to comment.