Skip to content

Commit

Permalink
updated the workflow with backend
Browse files Browse the repository at this point in the history
  • Loading branch information
surajyadav1108 committed Aug 16, 2023
1 parent e652ae1 commit 5d989ee
Show file tree
Hide file tree
Showing 234 changed files with 15,951 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/backend.main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: deploy_backend

on:
push:
branches: [ main ]
paths:
- 'backend/**'


env:
AZURE_FUNCTIONAPP_NAME: 'MyGetResumeCounter' # set this to your function app name on Azure
AZURE_FUNCTIONAPP_PACKAGE_PATH: 'backend' # set this to the path to your function app project, defaults to the repository root
DOTNET_VERSION: '6.0.412' # set this to the dotnet version to use (e.g. '2.1.x', '3.1.x', '5.0.x')

jobs:
build-and-deploy:
runs-on: windows-latest
environment: dev
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v3

- name: 'Login via azureCLI'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_RESUME_SECRET }}

- name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: 'Resolve Project Dependencies Using Dotnet'
shell: pwsh
run: |
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/api'
dotnet build --configuration Release --output ./output
popd
- name: 'Run unit test'
shell: pwsh
run: |
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}/tests'
dotnet test
- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1
id: fa
with:
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
package: '${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}api/output'

31 changes: 31 additions & 0 deletions backend/tests/ListLogger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Text;

namespace tests
{
public class ListLogger : ILogger
{
public IList<string> Logs;

public IDisposable BeginScope<TState>(TState state) => NullScope.Instance;

public bool IsEnabled(LogLevel logLevel) => false;

public ListLogger()
{
this.Logs = new List<string>();
}

public void Log<TState>(LogLevel logLevel,
EventId eventId,
TState state,
Exception exception,
Func<TState, Exception, string> formatter)
{
string message = formatter(state, exception);
this.Logs.Add(message);
}
}
}
8 changes: 8 additions & 0 deletions backend/tests/LoggerTypes.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace tests
{
public enum LoggerTypes
{
Null,
List
}
}
13 changes: 13 additions & 0 deletions backend/tests/NullScope.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;

namespace tests
{
public class NullScope : IDisposable
{
public static NullScope Instance { get; } = new NullScope();

private NullScope() { }

public void Dispose() { }
}
}
31 changes: 31 additions & 0 deletions backend/tests/TestCounter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Xunit;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;

Check warning on line 7 in backend/tests/TestCounter.cs

View workflow job for this annotation

GitHub Actions / build-and-deploy

The using directive for 'Microsoft.Extensions.Logging' appeared previously in this namespace
using Newtonsoft.Json;
using System.Net;
using System.Net.Http;
using System.Text;

namespace tests
{
public class TestCounter
{
private readonly ILogger logger = TestFactory.CreateLogger();

[Fact]
public async void Http_trigger_should_return_known_string()

Check warning on line 20 in backend/tests/TestCounter.cs

View workflow job for this annotation

GitHub Actions / build-and-deploy

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
var counter = new Company.Function.Counter();
counter.Id = "1";
counter.Count = 2;
var request = TestFactory.CreateHttpRequest();
var response = (HttpResponseMessage) Company.Function.GetResumeCounter.Run(request, counter, out counter, logger);
Assert.Equal(3, counter.Count);
}

}
}
36 changes: 36 additions & 0 deletions backend/tests/TestFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Primitives;
using System.Collections.Generic;

namespace tests
{
public class TestFactory
{

public static HttpRequest CreateHttpRequest()
{
var context = new DefaultHttpContext();
var request = context.Request;
return request;
}

public static ILogger CreateLogger(LoggerTypes type = LoggerTypes.Null)
{
ILogger logger;

if (type == LoggerTypes.List)
{
logger = new ListLogger();
}
else
{
logger = NullLoggerFactory.Instance.CreateLogger("Null Logger");
}

return logger;
}
}
}
1 change: 1 addition & 0 deletions backend/tests/Usings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
global using Xunit;
Binary file added backend/tests/bin/Debug/net6.0/Azure.Core.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added backend/tests/bin/Debug/net6.0/api.dll
Binary file not shown.
Binary file added backend/tests/bin/Debug/net6.0/api.pdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions backend/tests/bin/Debug/net6.0/host.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 14 additions & 0 deletions backend/tests/bin/Debug/net6.0/local.settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"AzureResumeConnectionString": "AccountEndpoint=https://azureresume-suraj.documents.azure.com:443/;AccountKey=IzZTfGt9B4sY0gaAClEQpv8kGyKfHT316AgKfhk9lqNb9UG6rxYtb7z7LVy05aPaA8K1Fq1qmnniACDb9rstJA==;"
},
"Host":
{
"CORS": "*"

}

}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added backend/tests/bin/Debug/net6.0/testhost.dll
Binary file not shown.
Binary file added backend/tests/bin/Debug/net6.0/testhost.exe
Binary file not shown.
Loading

0 comments on commit 5d989ee

Please sign in to comment.