From 1c104c803396c6b727dc918d1607a074aba3ea01 Mon Sep 17 00:00:00 2001 From: William Rezende | Stone Date: Wed, 15 Mar 2023 19:36:19 -0300 Subject: [PATCH] Add github action --- .github/workflows/build.yaml | 35 +++++++++++++ .github/workflows/publish.yaml | 49 ++++++++++++++++++ Readme.md | Bin 4800 -> 2338 bytes ...otNet.Core.Runtime.Faker.FakeItEasy.csproj | 14 +++++ .../DotNet.Core.Runtime.Faker.Moq.csproj | 16 +++++- .../RuntimeFakerUsingCustomFakerTests.cs | 5 +- .../RuntimeFakerUsingFakeItEasyTests.cs | 5 +- .../RuntimeFakerUsingMoqTests.cs | 5 +- .../Program.cs | 2 + .../Startup.cs | 28 ---------- 10 files changed, 121 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/publish.yaml delete mode 100644 test/DotNet.Core.Runtime.Faker.WebApi.Sample/Startup.cs diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..1bc6f35 --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,35 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build: + + env: + BUILD_CONFIG: 'Release' + SOLUTION: 'DotNet.Core.Runtime.Faker.sln' + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Install .NET 7 SDK + uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.x.x + + - name: Install dependencies + run: dotnet restore + + - name: Build + run: dotnet build $SOLUTION -c $BUILD_CONFIG --no-restore + + - name: Run tests + run: dotnet test --logger trx -c $BUILD_CONFIG --no-restore --no-build diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..299e2ea --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,49 @@ +name: Publish + +on: + release: + types: [created] + +jobs: + deploy: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + env: + BUILD_CONFIG: 'Release' + SOLUTION: 'DotNet.Core.Runtime.Faker.sln' + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-dotnet@v3 + with: + dotnet-version: 7.x.x + + - name: Install dependencies + run: dotnet restore + + - name: Build + run: dotnet build $SOLUTION -c $BUILD_CONFIG --no-restore + + - name: Tag name + id: tag-name + run: | + echo "SOURCE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + + - name: Create the package + run: dotnet pack -p:PackageVersion=$SOURCE_TAG -c $BUILD_CONFIG src/DotNet.Core.Runtime.Faker.Moq --no-build --no-restore + env: + SOURCE_TAG: ${{ steps.tag-name.outputs.SOURCE_TAG }} + + - name: Create the package + run: dotnet pack -p:PackageVersion=$SOURCE_TAG -c $BUILD_CONFIG src/DotNet.Core.Runtime.Faker.FakeItEasy --no-build --no-restore + env: + SOURCE_TAG: ${{ steps.tag-name.outputs.SOURCE_TAG }} + + - name: Publish the package to nuget.org + run: dotnet nuget push **/*.nupkg -k $NUGET_AUTH_TOKEN -s https://api.nuget.org/v3/index.json + env: + NUGET_AUTH_TOKEN: ${{ secrets.NUGET_TOKEN }} + diff --git a/Readme.md b/Readme.md index 79cb094ed6d64450433881eec672611333b7ab71..671e4a34451b32fe172710d27f701785098f0af3 100644 GIT binary patch literal 2338 zcmdUw&rjPh6vyxWE1uL#B5lcKC!m$O7B(b`rozSnO~OfDi-%(e+X+R}{u&O`cHdvn ze{9c5szPW7ns#7StEBd`-}n9a*gY6)cZ@C?X@k+UR8Hg=9q=nOj2(#t3T`+!qf>4` zmE+6r%U@_gs4wVv#w}EW!}t&|2Zwo~Aw$3grX?BPX;9kIxTP;GaX2?T)0VMb z4~EY0YWc%Lrs3SXJ#_or-hK`)oh$549M6TjER!hJdAy#!_ZqU-;B{^dqYkFo704E* zI2V?@8qhHFaRR%zxJY}fq9IdHqQUGFmnA|U6yCs?J3OVl1mP~L&1O7x+T6C&XP69& zLW-0-q18b%w|C;Wab+?dQ%5(I?s|WRt6Z-XgiT(Wy~bD}bp};jQ9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MSsph!&%+F=%Na)S>6TiV`LBOwe6nO;_GE-)68VGWd$nCg@%(TVi6PF%nv;6AwG&c^-MyYlGRQ5T;0*<-yn#K`VXxLZUII_F rSz%w`z1oE}P4*i9yC2mb^E_8y&u@`vNL)p)V>U2rJyPpEYCY^1^hGgF diff --git a/src/DotNet.Core.Runtime.Faker.FakeItEasy/DotNet.Core.Runtime.Faker.FakeItEasy.csproj b/src/DotNet.Core.Runtime.Faker.FakeItEasy/DotNet.Core.Runtime.Faker.FakeItEasy.csproj index 16546a6..d6c1222 100644 --- a/src/DotNet.Core.Runtime.Faker.FakeItEasy/DotNet.Core.Runtime.Faker.FakeItEasy.csproj +++ b/src/DotNet.Core.Runtime.Faker.FakeItEasy/DotNet.Core.Runtime.Faker.FakeItEasy.csproj @@ -2,8 +2,22 @@ net7.0 + Luna.DotNet.Core.Runtime.Faker.FakeItEasy + README.md + snupkg + true + William Espinosa de Rezende + Biblioteca para troca de dependências em tempo de execução dos testes com FakeItEasy + dotnet core; tests; fakeiteasy; + https://github.com/willsbctm/DotNet.Core.Runtime.Faker + main + MIT + + + + diff --git a/src/DotNet.Core.Runtime.Faker.Moq/DotNet.Core.Runtime.Faker.Moq.csproj b/src/DotNet.Core.Runtime.Faker.Moq/DotNet.Core.Runtime.Faker.Moq.csproj index 1fff3f2..1cf0870 100644 --- a/src/DotNet.Core.Runtime.Faker.Moq/DotNet.Core.Runtime.Faker.Moq.csproj +++ b/src/DotNet.Core.Runtime.Faker.Moq/DotNet.Core.Runtime.Faker.Moq.csproj @@ -1,9 +1,23 @@ - net7.0 + net7.0 + Luna.DotNet.Core.Runtime.Faker.Moq + README.md + snupkg + true + William Espinosa de Rezende + Biblioteca para troca de dependências em tempo de execução dos testes com Moq + dotnet core; tests; moq; + https://github.com/willsbctm/DotNet.Core.Runtime.Faker + main + MIT + + + + diff --git a/test/DotNet.Core.Runtime.Faker.Integration.Tests/RuntimeFakerUsingCustomFakerTests.cs b/test/DotNet.Core.Runtime.Faker.Integration.Tests/RuntimeFakerUsingCustomFakerTests.cs index 35ffcd8..4237224 100644 --- a/test/DotNet.Core.Runtime.Faker.Integration.Tests/RuntimeFakerUsingCustomFakerTests.cs +++ b/test/DotNet.Core.Runtime.Faker.Integration.Tests/RuntimeFakerUsingCustomFakerTests.cs @@ -1,4 +1,3 @@ -using DotNet.Core.Faker.Runtime.WebApi.Sample; using DotNet.Core.Runtime.Faker.WebApi.Sample; using FluentAssertions; using Microsoft.AspNetCore.Mvc.Testing; @@ -15,7 +14,7 @@ namespace DotNet.Core.Faker.Runtime.Integration.Tests public class RuntimeFakerUsingCustomFakerTests { protected static DateTime changedValue; - private WebApplicationFactory factory; + private WebApplicationFactory factory; private IServiceProvider serviceProvider; private HttpClient cliente; @@ -24,7 +23,7 @@ public void OneTimeSetUp() { changedValue = new Bogus.Faker().Date.Past(); - factory = new WebApplicationFactory().WithWebHostBuilder(builder => + factory = new WebApplicationFactory().WithWebHostBuilder(builder => builder.ConfigureTestServices(services => { services.AddServiceWithFaker(() => new Clock()); diff --git a/test/DotNet.Core.Runtime.Faker.Integration.Tests/RuntimeFakerUsingFakeItEasyTests.cs b/test/DotNet.Core.Runtime.Faker.Integration.Tests/RuntimeFakerUsingFakeItEasyTests.cs index 5b39947..168efa7 100644 --- a/test/DotNet.Core.Runtime.Faker.Integration.Tests/RuntimeFakerUsingFakeItEasyTests.cs +++ b/test/DotNet.Core.Runtime.Faker.Integration.Tests/RuntimeFakerUsingFakeItEasyTests.cs @@ -1,4 +1,3 @@ -using DotNet.Core.Faker.Runtime.WebApi.Sample; using DotNet.Core.Runtime.Faker.WebApi.Sample; using FluentAssertions; using Microsoft.AspNetCore.Mvc.Testing; @@ -17,7 +16,7 @@ namespace DotNet.Core.Faker.Runtime.Integration.Tests public class RuntimeFakerUsingFakeItEasyTests { private DateTime registeredValue; - private WebApplicationFactory factory; + private WebApplicationFactory factory; private IServiceProvider serviceProvider; private HttpClient cliente; @@ -26,7 +25,7 @@ public void OneTimeSetUp() { registeredValue = new Bogus.Faker().Date.Future(); - factory = new WebApplicationFactory().WithWebHostBuilder(builder => + factory = new WebApplicationFactory().WithWebHostBuilder(builder => builder.ConfigureTestServices(services => { services.AddServiceWithFaker(faker => A.CallTo(() => faker.Now()).Returns(registeredValue)); diff --git a/test/DotNet.Core.Runtime.Faker.Integration.Tests/RuntimeFakerUsingMoqTests.cs b/test/DotNet.Core.Runtime.Faker.Integration.Tests/RuntimeFakerUsingMoqTests.cs index dd2475c..d9f08df 100644 --- a/test/DotNet.Core.Runtime.Faker.Integration.Tests/RuntimeFakerUsingMoqTests.cs +++ b/test/DotNet.Core.Runtime.Faker.Integration.Tests/RuntimeFakerUsingMoqTests.cs @@ -1,4 +1,3 @@ -using DotNet.Core.Faker.Runtime.WebApi.Sample; using DotNet.Core.Runtime.Faker.WebApi.Sample; using FluentAssertions; using Microsoft.AspNetCore.Mvc.Testing; @@ -16,7 +15,7 @@ namespace DotNet.Core.Faker.Runtime.Integration.Tests public class RuntimeFakerUsingMoqTests { private DateTime registeredValue; - private static WebApplicationFactory factory; + private static WebApplicationFactory factory; private static IServiceProvider serviceProvider; private HttpClient cliente; @@ -25,7 +24,7 @@ public void OneTimeSetUp() { registeredValue = new Bogus.Faker().Date.Future(); - factory = new WebApplicationFactory().WithWebHostBuilder(builder => + factory = new WebApplicationFactory().WithWebHostBuilder(builder => builder.ConfigureTestServices(services => { services.AddServiceWithFaker(mock => mock.Setup(x => x.Now()).Returns(registeredValue)); diff --git a/test/DotNet.Core.Runtime.Faker.WebApi.Sample/Program.cs b/test/DotNet.Core.Runtime.Faker.WebApi.Sample/Program.cs index be74ace..228d166 100644 --- a/test/DotNet.Core.Runtime.Faker.WebApi.Sample/Program.cs +++ b/test/DotNet.Core.Runtime.Faker.WebApi.Sample/Program.cs @@ -18,3 +18,5 @@ app.MapControllers(); app.Run(); + +public partial class Program { } diff --git a/test/DotNet.Core.Runtime.Faker.WebApi.Sample/Startup.cs b/test/DotNet.Core.Runtime.Faker.WebApi.Sample/Startup.cs deleted file mode 100644 index 83c0b04..0000000 --- a/test/DotNet.Core.Runtime.Faker.WebApi.Sample/Startup.cs +++ /dev/null @@ -1,28 +0,0 @@ -using DotNet.Core.Runtime.Faker.WebApi.Sample; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; - -namespace DotNet.Core.Faker.Runtime.WebApi.Sample -{ - public class Startup - { - public void ConfigureServices(IServiceCollection services) - { - services.AddTransient(); - services.AddControllers(); - } - - public void Configure(IApplicationBuilder app, IWebHostEnvironment env) - { - app.UseHttpsRedirection(); - - app.UseRouting(); - - app.UseEndpoints(endpoints => - { - endpoints.MapControllers(); - }); - } - } -}