Skip to content

Commit

Permalink
Add github action
Browse files Browse the repository at this point in the history
willsbctm committed Mar 16, 2023
1 parent 153542c commit 1c104c8
Showing 10 changed files with 121 additions and 38 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -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
49 changes: 49 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -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 }}

Binary file modified Readme.md
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -2,8 +2,22 @@

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<PackageId>Luna.DotNet.Core.Runtime.Faker.FakeItEasy</PackageId>
<PackageReadmeFile>README.md</PackageReadmeFile>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<IncludeSymbols>true</IncludeSymbols>
<Authors>William Espinosa de Rezende</Authors>
<PackageDescription>Biblioteca para troca de dependências em tempo de execução dos testes com FakeItEasy</PackageDescription>
<PackageTags>dotnet core; tests; fakeiteasy;</PackageTags>
<RepositoryUrl>https://github.com/willsbctm/DotNet.Core.Runtime.Faker</RepositoryUrl>
<RepositoryBranch>main</RepositoryBranch>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="FakeItEasy" Version="7.3.1" />
</ItemGroup>
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<PackageId>Luna.DotNet.Core.Runtime.Faker.Moq</PackageId>
<PackageReadmeFile>README.md</PackageReadmeFile>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<IncludeSymbols>true</IncludeSymbols>
<Authors>William Espinosa de Rezende</Authors>
<PackageDescription>Biblioteca para troca de dependências em tempo de execução dos testes com Moq</PackageDescription>
<PackageTags>dotnet core; tests; moq;</PackageTags>
<RepositoryUrl>https://github.com/willsbctm/DotNet.Core.Runtime.Faker</RepositoryUrl>
<RepositoryBranch>main</RepositoryBranch>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup>

<ItemGroup>
<None Include="..\..\README.md" Pack="true" PackagePath="\"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Moq" Version="4.18.4" />
</ItemGroup>
Original file line number Diff line number Diff line change
@@ -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<Startup> factory;
private WebApplicationFactory<Program> factory;
private IServiceProvider serviceProvider;
private HttpClient cliente;

@@ -24,7 +23,7 @@ public void OneTimeSetUp()
{
changedValue = new Bogus.Faker().Date.Past();

factory = new WebApplicationFactory<Startup>().WithWebHostBuilder(builder =>
factory = new WebApplicationFactory<Program>().WithWebHostBuilder(builder =>
builder.ConfigureTestServices(services =>
{
services.AddServiceWithFaker(() => new Clock());
Original file line number Diff line number Diff line change
@@ -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<Startup> factory;
private WebApplicationFactory<Program> factory;
private IServiceProvider serviceProvider;
private HttpClient cliente;

@@ -26,7 +25,7 @@ public void OneTimeSetUp()
{
registeredValue = new Bogus.Faker().Date.Future();

factory = new WebApplicationFactory<Startup>().WithWebHostBuilder(builder =>
factory = new WebApplicationFactory<Program>().WithWebHostBuilder(builder =>
builder.ConfigureTestServices(services =>
{
services.AddServiceWithFaker<Clock>(faker => A.CallTo(() => faker.Now()).Returns(registeredValue));
Original file line number Diff line number Diff line change
@@ -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<Startup> factory;
private static WebApplicationFactory<Program> factory;
private static IServiceProvider serviceProvider;
private HttpClient cliente;

@@ -25,7 +24,7 @@ public void OneTimeSetUp()
{
registeredValue = new Bogus.Faker().Date.Future();

factory = new WebApplicationFactory<Startup>().WithWebHostBuilder(builder =>
factory = new WebApplicationFactory<Program>().WithWebHostBuilder(builder =>
builder.ConfigureTestServices(services =>
{
services.AddServiceWithFaker<Clock>(mock => mock.Setup(x => x.Now()).Returns(registeredValue));
2 changes: 2 additions & 0 deletions test/DotNet.Core.Runtime.Faker.WebApi.Sample/Program.cs
Original file line number Diff line number Diff line change
@@ -18,3 +18,5 @@
app.MapControllers();

app.Run();

public partial class Program { }
28 changes: 0 additions & 28 deletions test/DotNet.Core.Runtime.Faker.WebApi.Sample/Startup.cs

This file was deleted.

0 comments on commit 1c104c8

Please sign in to comment.