Skip to content
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

feat: Switch to using an Azure Function instead of a Container App Job #18

Merged
merged 3 commits into from
Dec 12, 2023
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
95 changes: 0 additions & 95 deletions .github/workflows/build-docker-image.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/dotnet-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Dotnet Publish

on:
release:
types: [published]

env:
RELEASE_TAG: ${{ github.event.release.tag_name }}

jobs:
build:
name: 'Build Deployment Package'
runs-on: ubuntu-latest
steps:
- name: Checkout repository ${{ env.RELEASE_TAG }}
uses: actions/checkout@v3
with:
ref: ${{ env.RELEASE_TAG }}

- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'

- name: dotnet publish
run: dotnet publish ./Childrens-Social-Care-CPD-Indexer/Childrens-Social-Care-CPD-Indexer.csproj -c Release -o ./publish
working-directory: ./src

- name: Zip output
run: zip -r ../${{ env.RELEASE_TAG }}.zip ./
working-directory: ./src/publish

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: resource-indexing-deployment
path: ./src/${{ env.RELEASE_TAG }}.zip
Original file line number Diff line number Diff line change
@@ -1,34 +1,25 @@
using Childrens_Social_Care_CPD_Indexer.Core;
using Microsoft.ApplicationInsights;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;
using NSubstitute.ExceptionExtensions;

namespace Childrens_Social_Care_CPD_Indexer.Tests;

public class IndexingServiceTests
{
private ILogger<IndexingService> _logger;
private ILogger<Indexer> _logger;
private IResourcesIndexerConfig _config;
private IResourcesIndexer _indexer;
private IndexingService _sut;
private Indexer _sut;

[SetUp]
public void Setup()
{
_logger = Substitute.For<ILogger<IndexingService>>();
_logger = Substitute.For<ILogger<Indexer>>();
_config = Substitute.For<IResourcesIndexerConfig>();
_indexer = Substitute.For<IResourcesIndexer>();
_sut = new IndexingService(_indexer, _logger, _config);
}

[Test]
public void StopAsync_Returns_Completed_Task()
{
// act
var task = _sut.StopAsync(default);

// assert
task.IsCompleted.Should().BeTrue();
_sut = new Indexer(_logger, _indexer, _config);
}

[Test]
Expand All @@ -38,7 +29,7 @@ public async Task StartAsync_Deletes_Index_If_Configured()
_config.RecreateIndex.Returns(true);

// act
await _sut.StartAsync(default);
await _sut.Run(new TimerInfo());

// assert
await _indexer.Received(1).DeleteIndexAsync(Arg.Any<string>(), Arg.Any<CancellationToken>());
Expand All @@ -52,7 +43,7 @@ public async Task StartAsync_Populates_Index()
_config.RecreateIndex.Returns(false);

// act
await _sut.StartAsync(default);
await _sut.Run(new TimerInfo());

// assert
await _indexer.Received(1).PopulateIndexAsync(Arg.Any<string>(), Arg.Any<int>(), Arg.Any<CancellationToken>());
Expand All @@ -67,7 +58,7 @@ public async Task StartAsync_Logs_Exception()
_indexer.DeleteIndexAsync(Arg.Any<string>(), Arg.Any<CancellationToken>()).Throws(exception);

// act
await _sut.StartAsync(default);
await _sut.Run(new TimerInfo());

// assert
_logger.Received(1).LogError(exception, "Unhandled exception occured");
Expand Down
12 changes: 6 additions & 6 deletions src/Childrens-Social-Care-CPD-Indexer.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.8.34322.80
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Childrens-Social-Care-CPD-Indexer", "Childrens-Social-Care-CPD-Indexer\Childrens-Social-Care-CPD-Indexer.csproj", "{D806CCEA-5505-4CD9-98B6-08A5F161C06A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Childrens-Social-Care-CPD-Indexer.Tests", "Childrens-Social-Care-CPD-Indexer.Tests\Childrens-Social-Care-CPD-Indexer.Tests.csproj", "{6984BF56-808E-4294-949D-FFE4B02CCE16}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Childrens-Social-Care-CPD-Indexer.Tests", "Childrens-Social-Care-CPD-Indexer.Tests\Childrens-Social-Care-CPD-Indexer.Tests.csproj", "{6984BF56-808E-4294-949D-FFE4B02CCE16}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Childrens-Social-Care-CPD-Indexer", "Childrens-Social-Care-CPD-Indexer\Childrens-Social-Care-CPD-Indexer.csproj", "{3555944D-1913-4979-B5BF-991C7064613E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D806CCEA-5505-4CD9-98B6-08A5F161C06A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D806CCEA-5505-4CD9-98B6-08A5F161C06A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D806CCEA-5505-4CD9-98B6-08A5F161C06A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D806CCEA-5505-4CD9-98B6-08A5F161C06A}.Release|Any CPU.Build.0 = Release|Any CPU
{6984BF56-808E-4294-949D-FFE4B02CCE16}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6984BF56-808E-4294-949D-FFE4B02CCE16}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6984BF56-808E-4294-949D-FFE4B02CCE16}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6984BF56-808E-4294-949D-FFE4B02CCE16}.Release|Any CPU.Build.0 = Release|Any CPU
{3555944D-1913-4979-B5BF-991C7064613E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3555944D-1913-4979-B5BF-991C7064613E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3555944D-1913-4979-B5BF-991C7064613E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3555944D-1913-4979-B5BF-991C7064613E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading