From 551cd829634d2ef44b74b5a56374292b02f06546 Mon Sep 17 00:00:00 2001 From: Byron Mayne Date: Sat, 27 Jul 2024 20:36:18 -0400 Subject: [PATCH 1/5] Switch CI to use matrix and build and publish two nuget packages --- .github/workflows/ci.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a82ef38..4febf68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,15 @@ jobs: publish: name: build, bundle & publish runs-on: windows-latest + strategy: + matrix: + nuget_project: + - name: SourceGenerator.Foundations + csproj: src\SourceGenerator.Foundations\SourceGenerator.Foundations.csproj + dir: src\SourceGenerator.Foundations\ + - name: SourceGenerator.Foundations.Contracts + csproj: src\SourceGenerator.Foundations.Contracts\SourceGenerator.Foundations.Contracts.csproj + dir: src\SourceGenerator.Foundations.Contracts\ steps: - uses: actions/checkout@v3 with: @@ -36,9 +45,10 @@ jobs: run: dotnet build src\SourceGenerator.Foundations\SourceGenerator.Foundations.csproj -p:Version=${{env.GitVersion_AssemblySemVer}} -p:PackageVersion=${{env.GitVersion_SemVer}} - name: Test | Solution run: dotnet test ${{env.SolutionPath}} - - name: Pack | SourceGenerator.Foundations\SourceGenerator.Foundations - run: dotnet pack src\SourceGenerator.Foundations\SourceGenerator.Foundations.csproj -p:Version=${{env.GitVersion_AssemblySemVer}} -p:PackageVersion=${{env.GitVersion_FullSemVer}} + #Pack + - name: Pack | ${{ matrix.project.name }} + run: dotnet pack ${{ matrix.project.csproj }} -p:Version=${{env.GitVersion_AssemblySemVer}} -p:PackageVersion=${{env.GitVersion_FullSemVer}} # -- Release Only -- - - name: Push NuGet + - name: Push | ${{ matrix.project.name }} if: github.event_name == 'release' run: dotnet nuget push ${{env.ProjectDir}}bin\${{env.Configuration}}\*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json From d26d489a53ac331182992bda81a2dcfb27b501a2 Mon Sep 17 00:00:00 2001 From: Byron Mayne Date: Sat, 27 Jul 2024 20:44:24 -0400 Subject: [PATCH 2/5] Updated the build steps --- .github/workflows/ci.yml | 43 +++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4febf68..5591575 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,18 +12,34 @@ env: SolutionPath: src\SourceGenerator.Foundations.sln MSBUILDDISABLENODEREUSE: '1' # Stops MSBuild from locking MSBuild nuget package jobs: + test: + name: Test + runs-on: windows-latest + strategy: + matrix: + project: + - name: SourceGenerator.Foundations.Tests + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + - name: Test | ${{ matrix.project.name }} + run: dotnet test ${{ matrix.project.name }} + publish: name: build, bundle & publish runs-on: windows-latest + needs: + - test strategy: matrix: - nuget_project: + project: - name: SourceGenerator.Foundations - csproj: src\SourceGenerator.Foundations\SourceGenerator.Foundations.csproj - dir: src\SourceGenerator.Foundations\ - name: SourceGenerator.Foundations.Contracts - csproj: src\SourceGenerator.Foundations.Contracts\SourceGenerator.Foundations.Contracts.csproj - dir: src\SourceGenerator.Foundations.Contracts\ steps: - uses: actions/checkout@v3 with: @@ -37,18 +53,13 @@ jobs: run: dotnet tool restore - name: GitVersion run: dotnet gitversion /output buildserver - # Build Dependencies - - name: Build | SourceGenerator.Foundations.MSBuild - run: dotnet build src\SourceGenerator.Foundations.MSBuild\SourceGenerator.Foundations.MSBuild.csproj -p:Version=${{env.GitVersion_AssemblySemVer}} - # Build Main - - name: Build | SourceGenerator.Foundations\SourceGenerator.Foundations + # Build + - name: Build | ${{ matrix.project.name }} run: dotnet build src\SourceGenerator.Foundations\SourceGenerator.Foundations.csproj -p:Version=${{env.GitVersion_AssemblySemVer}} -p:PackageVersion=${{env.GitVersion_SemVer}} - - name: Test | Solution - run: dotnet test ${{env.SolutionPath}} - #Pack + # Pack - name: Pack | ${{ matrix.project.name }} - run: dotnet pack ${{ matrix.project.csproj }} -p:Version=${{env.GitVersion_AssemblySemVer}} -p:PackageVersion=${{env.GitVersion_FullSemVer}} - # -- Release Only -- + run: dotnet pack src\${{ matrix.project.name }}\${{ matrix.project.name }}.csproj -p:Version=${{env.GitVersion_AssemblySemVer}} -p:PackageVersion=${{env.GitVersion_FullSemVer}} + # Release - name: Push | ${{ matrix.project.name }} if: github.event_name == 'release' - run: dotnet nuget push ${{env.ProjectDir}}bin\${{env.Configuration}}\*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json + run: dotnet nuget push src\${{ matrix.project.name }}\bin\${{env.Configuration}}\*.nupkg --skip-duplicate --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json From 00c1cdf8bcf4663c8b34bcfdaf3f2b5de52f06ed Mon Sep 17 00:00:00 2001 From: Byron Mayne Date: Sat, 27 Jul 2024 20:46:30 -0400 Subject: [PATCH 3/5] Added more steps --- .github/workflows/ci.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5591575..7a6546a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,9 +12,24 @@ env: SolutionPath: src\SourceGenerator.Foundations.sln MSBUILDDISABLENODEREUSE: '1' # Stops MSBuild from locking MSBuild nuget package jobs: + build: + name: Build + runs-on: windows-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.head_ref }} + - name: Setup .NET + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 6.0.x + - name: Build Solution + run: dotnet test src\SourceGenerator.Foundations.sln + test: name: Test runs-on: windows-latest + needs: build strategy: matrix: project: @@ -28,7 +43,7 @@ jobs: with: dotnet-version: 6.0.x - name: Test | ${{ matrix.project.name }} - run: dotnet test ${{ matrix.project.name }} + run: dotnet test src\${{ matrix.project.name }}\${{ matrix.project.name }}.csproj publish: name: build, bundle & publish From 2d00822749683bf5e849ca71fd0cc0e61b6b28b4 Mon Sep 17 00:00:00 2001 From: Byron Mayne Date: Sun, 28 Jul 2024 18:52:13 -0400 Subject: [PATCH 4/5] Fixed the unit tests not running --- .github/workflows/ci.yml | 6 ++-- .../ScriptInjectorGeneratorTests.cs | 30 ------------------- .../SourceGenerator.Foundations.Tests.csproj | 1 + src/SourceGenerator.Foundations.sln | 10 +++++++ 4 files changed, 15 insertions(+), 32 deletions(-) delete mode 100644 src/SourceGenerator.Foundations.Tests/ScriptInjectorGeneratorTests.cs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7a6546a..92e4953 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,6 +34,8 @@ jobs: matrix: project: - name: SourceGenerator.Foundations.Tests + - name: ConsoleApp.SourceGenerator.Tests + path: Sandbox/ steps: - uses: actions/checkout@v3 with: @@ -43,10 +45,10 @@ jobs: with: dotnet-version: 6.0.x - name: Test | ${{ matrix.project.name }} - run: dotnet test src\${{ matrix.project.name }}\${{ matrix.project.name }}.csproj + run: dotnet test src\${{ matrix.project.path }}${{ matrix.project.name }}\${{ matrix.project.name }}.csproj publish: - name: build, bundle & publish + name: Publish runs-on: windows-latest needs: - test diff --git a/src/SourceGenerator.Foundations.Tests/ScriptInjectorGeneratorTests.cs b/src/SourceGenerator.Foundations.Tests/ScriptInjectorGeneratorTests.cs deleted file mode 100644 index 207c3a9..0000000 --- a/src/SourceGenerator.Foundations.Tests/ScriptInjectorGeneratorTests.cs +++ /dev/null @@ -1,30 +0,0 @@ -using SGF.Generators; -using Xunit.Abstractions; - -namespace SourceGenerator.Foundations.Tests -{ - public class ScriptInjectorGeneratorTests : GeneratorTest - { - public ScriptInjectorGeneratorTests(ITestOutputHelper outputHelper) : base(outputHelper) - {} - - [Fact] - public void AssemblyResolver_AddedToProject() - => Compose("", - a => a.AnyTreeNamed("AssemblyResolver.generated.cs")); - [Fact] - public void ResourceConfiguration_AddedToProject() - => Compose("", - a => a.AnyTreeNamed("ResourceConfiguration.generated.cs")); - - [Fact] - public void ModuleInitializerAttribute_AddedToProject() - => Compose("", - a => a.AnyTreeNamed("ModuleInitializerAttribute.generated.cs")); - - [Fact] - public void IncrementalGenerator_AddedToProject() - => Compose("", - a => a.AnyTreeNamed("IncrementalGenerator.generated.cs")); - } -} diff --git a/src/SourceGenerator.Foundations.Tests/SourceGenerator.Foundations.Tests.csproj b/src/SourceGenerator.Foundations.Tests/SourceGenerator.Foundations.Tests.csproj index e62892b..d4f83a1 100644 --- a/src/SourceGenerator.Foundations.Tests/SourceGenerator.Foundations.Tests.csproj +++ b/src/SourceGenerator.Foundations.Tests/SourceGenerator.Foundations.Tests.csproj @@ -23,6 +23,7 @@ + diff --git a/src/SourceGenerator.Foundations.sln b/src/SourceGenerator.Foundations.sln index a13833d..6847b50 100644 --- a/src/SourceGenerator.Foundations.sln +++ b/src/SourceGenerator.Foundations.sln @@ -31,6 +31,8 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SourceGenerator.Foundations EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp.SourceGenerator.Tests", "Sandbox\ConsoleApp.SourceGenerator.Tests\ConsoleApp.SourceGenerator.Tests.csproj", "{560C8028-2831-4697-9571-A9920FB972E7}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceGenerator.Foundations.Tests", "SourceGenerator.Foundations.Tests\SourceGenerator.Foundations.Tests.csproj", "{7D1F6C4F-2A50-4706-8ECF-BA8BCE3E1C81}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -87,6 +89,14 @@ Global {560C8028-2831-4697-9571-A9920FB972E7}.Release|Any CPU.Build.0 = Release|Any CPU {560C8028-2831-4697-9571-A9920FB972E7}.Release|x64.ActiveCfg = Release|Any CPU {560C8028-2831-4697-9571-A9920FB972E7}.Release|x64.Build.0 = Release|Any CPU + {7D1F6C4F-2A50-4706-8ECF-BA8BCE3E1C81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7D1F6C4F-2A50-4706-8ECF-BA8BCE3E1C81}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7D1F6C4F-2A50-4706-8ECF-BA8BCE3E1C81}.Debug|x64.ActiveCfg = Debug|Any CPU + {7D1F6C4F-2A50-4706-8ECF-BA8BCE3E1C81}.Debug|x64.Build.0 = Debug|Any CPU + {7D1F6C4F-2A50-4706-8ECF-BA8BCE3E1C81}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7D1F6C4F-2A50-4706-8ECF-BA8BCE3E1C81}.Release|Any CPU.Build.0 = Release|Any CPU + {7D1F6C4F-2A50-4706-8ECF-BA8BCE3E1C81}.Release|x64.ActiveCfg = Release|Any CPU + {7D1F6C4F-2A50-4706-8ECF-BA8BCE3E1C81}.Release|x64.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From fd22f727edc5e5f10b97dc3c111bff561fe11080 Mon Sep 17 00:00:00 2001 From: Byron Mayne Date: Sun, 28 Jul 2024 18:53:56 -0400 Subject: [PATCH 5/5] Gave better labels to the tests --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92e4953..4b032a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ env: MSBUILDDISABLENODEREUSE: '1' # Stops MSBuild from locking MSBuild nuget package jobs: build: - name: Build + name: Build | All runs-on: windows-latest steps: - uses: actions/checkout@v3 @@ -27,7 +27,7 @@ jobs: run: dotnet test src\SourceGenerator.Foundations.sln test: - name: Test + name: Test | ${{ matrix.project.name }} runs-on: windows-latest needs: build strategy: @@ -48,7 +48,7 @@ jobs: run: dotnet test src\${{ matrix.project.path }}${{ matrix.project.name }}\${{ matrix.project.name }}.csproj publish: - name: Publish + name: Publish | ${{ matrix.project.name }} runs-on: windows-latest needs: - test