Skip to content

Develop #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/workflows/develop_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and test

on:
push:
branches:
- '!master'
pull_request:
branches:
- 'develop'
workflow_dispatch:

env:
AZURE_WEBAPP_NAME: 'auto-hub-app' # set this to your application's name
AZURE_WEBAPP_PACKAGE_PATH: './publish' # set this to the path to your web app project, defaults to the repository root
DOTNET_VERSION: '8.x' # set this to the dot net version to use

jobs:
build:
name: Build
runs-on: windows-latest

steps:
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Build with dotnet
run: dotnet build --configuration Release

- name: Publish artifact
run: dotnet publish -c Release -o ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.AZURE_WEBAPP_NAME }}
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

test:
name: Test
runs-on: windows-latest
needs: build

steps:
- uses: actions/checkout@v4

- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Build with dotnet
run: dotnet build --configuration Release

- name: Restore dependencies
run: dotnet restore

- name: Run tests with dotnet
run: dotnet test --no-build --no-restore --configuration Release
35 changes: 21 additions & 14 deletions .github/workflows/ci.yml → .github/workflows/master_ci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy
name: Build, test and deploy

on:
push:
branches:
- master
- 'master'
pull_request:
branches:
- 'master'
workflow_dispatch:

env:
AZURE_WEBAPP_NAME: 'AutoHubApp' # set this to your application's name
AZURE_WEBAPP_PACKAGE_PATH: './publish' # set this to the path to your web app project, defaults to the repository root
DOTNET_VERSION: '8.x' # set this to the dot net version to use

jobs:
build:
name: Build
Expand All @@ -20,19 +28,19 @@ jobs:
- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Build with dotnet
run: dotnet build --configuration Release

- name: Publish artifact
run: dotnet publish -c Release -o ./publish
run: dotnet publish -c Release -o ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: .autohub-artifacts
path: ./publish
name: ${{ env.AZURE_WEBAPP_NAME }}
path: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

test:
name: Test
Expand All @@ -45,7 +53,7 @@ jobs:
- name: Set up .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.x"
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Build with dotnet
run: dotnet build --configuration Release
Expand All @@ -56,7 +64,6 @@ jobs:
- name: Run tests with dotnet
run: dotnet test --no-build --no-restore --configuration Release


deploy:
name: Deploy to Azure
runs-on: windows-latest
Expand All @@ -72,20 +79,20 @@ jobs:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: .autohub-artifacts
name: ${{ env.AZURE_WEBAPP_NAME }}

- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_C858A91760294A7E968810EBCA7F4CFD }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_E46CDD63D0554EE68973979DDB7E5095 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_96C8763478B642DF952093578964EE66 }}
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_D8F08FF4580C4308A9B851754C2EB53A }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_20D1A7B5198E45CB92C2D3AC6AEF683E }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_6503C5D792634D21975C28A9B4896C84 }}

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: 'AutoHubApp'
app-name: ${{ env.AZURE_WEBAPP_NAME }}
slot-name: 'Production'
package: .


18 changes: 18 additions & 0 deletions AutoHub.API/Middlewares/ReditectMiddleware.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Microsoft.AspNetCore.Http;
using System.Threading.Tasks;

namespace AutoHub.API.Middlewares;

public class RedirectMiddleware(RequestDelegate next)
{
public async Task InvokeAsync(HttpContext httpContext)
{
if (httpContext.Request.Path == "/")
{
httpContext.Response.Redirect("/index.html");
return;
}

await next(httpContext);
}
}
1 change: 1 addition & 0 deletions AutoHub.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
app.UseSwaggerDocumentation();
app.UseRedocDocumentation();
app.UseMiddleware<ApplicationExceptionMiddleware>();
app.UseMiddleware<RedirectMiddleware>();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
Expand Down
1 change: 0 additions & 1 deletion AutoHub.API/Validators/PaginationValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using AutoHub.BusinessLogic.Models;
using AutoHub.Domain.Constants;
using FluentValidation;
using Microsoft.IdentityModel.Tokens;

namespace AutoHub.API.Validators;

Expand Down
2 changes: 1 addition & 1 deletion AutoHub.API/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"HoursToExpire": 3
},
"ConnectionStrings": {
"PostgresConnectionString": "Host=localhost;Port=5432;Database=AutoHubDb;Username=postgres;Password=admin;Include Error Detail=true;",
"PostgresConnectionString": "Server=tcp:autohub-server.database.windows.net,1433;Initial Catalog=autohub-db;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Authentication=Active Directory Default;",
"AzureSqlServerConnectionString": "Server=autohub-db.database.windows.net,1433;Initial Catalog=AutoHubDb;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Authentication=Active Directory Default"
}
}
2 changes: 1 addition & 1 deletion AutoHub.API/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"HoursToExpire": 3
},
"ConnectionStrings": {
"AzureSqlServerConnectionString": "Server=autohub-db.database.windows.net,1433;Initial Catalog=AutoHubDb;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Authentication=Active Directory Default"
"AzureSqlServerConnectionString": "Server=tcp:autohub-server.database.windows.net,1433;Initial Catalog=autohub-db;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Authentication=Active Directory Default;"
}
}
3 changes: 1 addition & 2 deletions AutoHub.BusinessLogic/Services/EmailService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.IO;
using AutoHub.BusinessLogic.Configuration;
using AutoHub.BusinessLogic.Configuration;
using AutoHub.BusinessLogic.Interfaces;
using MailKit.Net.Smtp;
using Microsoft.Extensions.Options;
Expand Down
2 changes: 0 additions & 2 deletions AutoHub.BusinessLogic/Services/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
using AutoHub.Domain.Exceptions;
using AutoMapper;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoHub.BusinessLogic.Common;
using AutoHub.BusinessLogic.Models;
Expand Down
2 changes: 1 addition & 1 deletion AutoHub.DataAccess/AutoHubContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer("Server=autohub-db.database.windows.net,1433;Initial Catalog=AutoHubDb;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Authentication=Active Directory Default");
optionsBuilder.UseSqlServer("Server=tcp:autohub-server.database.windows.net,1433;Initial Catalog=autohub-db;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Authentication=Active Directory Default;");

Check warning on line 32 in AutoHub.DataAccess/AutoHubContext.cs

View workflow job for this annotation

GitHub Actions / Build

Split this 223 characters long line (which is greater than 200 authorized). (https://rules.sonarsource.com/csharp/RSPEC-103)

Check warning on line 32 in AutoHub.DataAccess/AutoHubContext.cs

View workflow job for this annotation

GitHub Actions / Test

Split this 223 characters long line (which is greater than 200 authorized). (https://rules.sonarsource.com/csharp/RSPEC-103)
optionsBuilder.UseLazyLoadingProxies();
optionsBuilder.LogTo(Console.WriteLine);
}
Expand Down
3 changes: 1 addition & 2 deletions AutoHub.Tests/ValidatorsTests/UserValidatorTests.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using AutoFixture;
using AutoHub.API.Models.UserModels;
using AutoHub.API.Models.UserModels;
using AutoHub.API.Validators.ModelValidators;
using FluentValidation.TestHelper;
using Xunit;
Expand Down
Loading