Skip to content

Commit

Permalink
add github actions config
Browse files Browse the repository at this point in the history
  • Loading branch information
JP Dillingham authored and jpdillingham committed Oct 10, 2021
1 parent 355acb0 commit f0a2b22
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]
workflow_dispatch:

jobs:
build:
name: Build and Test API
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Restore
working-directory: ./api
run: dotnet restore
- name: Build
working-directory: ./api
run: dotnet build --no-restore --no-incremental
- name: Test
working-directory: ./api
run: dotnet test QCVOC.Api.Tests.Unit/QCVOC.Api.Tests.Unit.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>QCVOC.Api.Tests.Integration</RootNamespace>

<IsPackable>false</IsPackable>
Expand Down
2 changes: 1 addition & 1 deletion api/QCVOC.Api.Tests.Unit/QCVOC.Api.Tests.Unit.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>QCVOC.Api.Tests.Unit</RootNamespace>

<IsPackable>false</IsPackable>
Expand Down
3 changes: 1 addition & 2 deletions api/QCVOC.Api/QCVOC.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>QCVOC.Api</RootNamespace>
<AssemblyName>QCVOC.Api</AssemblyName>
<LangVersion>7.1</LangVersion>
Expand Down Expand Up @@ -31,7 +31,6 @@
<PackageReference Include="Amazon.Lambda.AspNetCoreServer" Version="2.0.4" />
<PackageReference Include="Dapper" Version="1.50.5" />
<PackageReference Include="Dapper.SqlBuilder" Version="1.50.5" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="2.1.30" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="2.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="2.2.0" />
Expand Down
16 changes: 9 additions & 7 deletions api/QCVOC.Api/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace QCVOC.Api
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Cors.Infrastructure;
Expand All @@ -21,8 +22,6 @@ namespace QCVOC.Api
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.IdentityModel.Tokens;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using NLog;
using QCVOC.Api.Common;
using QCVOC.Api.Common.Data.ConnectionFactory;
Expand Down Expand Up @@ -72,7 +71,7 @@ public Startup(IConfiguration configuration)
/// <param name="app">The default application builder.</param>
/// <param name="env">The hosting environment.</param>
/// <param name="provider">The API version information provider.</param>
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApiVersionDescriptionProvider provider)
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider provider)
{
app.UseExceptionMiddleware(options => options.Verbosity = ExceptionMiddlwareVerbosity.Terse);

Expand All @@ -81,7 +80,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApiVers
app.UseAuthentication();
app.UseCors("AllowAll");

app.UseMvc();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});

app.UseSwagger(options => ConfigureSwaggerOptions(options));
app.UseSwaggerUI(options => ConfigureSwaggerUIOptions(options, provider));
Expand Down Expand Up @@ -153,10 +155,10 @@ private static void ConfigureCorsOptions(CorsOptions options)
});
}

private static void ConfigureJsonOptions(MvcJsonOptions options)
private static void ConfigureJsonOptions(JsonOptions options)
{
options.SerializerSettings.Converters.Add(new StringEnumConverter());
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
options.JsonSerializerOptions.IgnoreNullValues = true;
}

private static void ConfigureJwtBearerOptions(JwtBearerOptions options)
Expand Down

0 comments on commit f0a2b22

Please sign in to comment.