Skip to content

Commit

Permalink
Merge pull request #347 from DFE-Digital/next
Browse files Browse the repository at this point in the history
Perform release
  • Loading branch information
killij authored Dec 6, 2023
2 parents 5c8543c + 68347a1 commit 95e121b
Show file tree
Hide file tree
Showing 24 changed files with 152 additions and 74 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/app-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ jobs:

steps:

- name: Docker pull check
run: docker pull ghcr.io/dfe-digital/childrens-social-care-cpd:${{inputs.tag}}

- name: Sign in to Azure
uses: azure/login@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docker-dev-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Run integration tests
on:
pull_request:
branches:
- master
- main
- next
jobs:
build-test-scan:
name: Build image and integration test
Expand Down
10 changes: 6 additions & 4 deletions .github/workflows/load-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ jobs:
run: terraform -chdir=Terraform apply -auto-approve -input=false

- name: Install Locust Load Test Tool
run: pip3 install locust
run: |
pip3 install locust
pip3 install charset_normalizer
- name: Sign in to Azure
uses: azure/login@v1
Expand All @@ -75,11 +77,11 @@ jobs:
- name: Whitelist Runner IP
run: az network nsg rule create -g s185d03-childrens-social-care-cpd-rg --nsg-name s185d03-chidrens-social-care-cpd-sn01-nsg -n GitHubRunnerRule --priority 4000 --source-address-prefixes ${{ env.theIP }} --source-port-ranges '*' --destination-address-prefixes '*' --destination-port-ranges '*' --access Allow --protocol Tcp --description "Allow Access from GitHub Action"

- name: Wait for 15 minutes
run: sleep 900s
- name: Wait for 10 minutes
run: sleep 600s

- name: Run Load Test
run: locust -f ./LoadTest/locustfile.py --headless -u 50 -r 1 --run-time 60s -H https://20.107.65.156/
run: locust -f ./LoadTest/locustfile.py --headless -u 5 -r 10 --run-time 300s -H https://20.107.65.156/

- name: Terraform Destroy 3
if: always()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,21 @@
using Childrens_Social_Care_CPD.Contentful.Renderers;
using FluentAssertions;
using Microsoft.Extensions.WebEncoders.Testing;
using NSubstitute;
using NUnit.Framework;
using System.IO;

namespace Childrens_Social_Care_CPD_Tests.Contentful.Renderers;

public class ContentLinkRendererTests
{
private readonly IRendererWithOptions<ContentLink> _sut = new ContentLinkRenderer();
private readonly IRendererWithOptions<ContentLink> _sut;

public ContentLinkRendererTests()
{
var mockContentLinkContext = Substitute.For<IContentLinkContext>();
_sut = new ContentLinkRenderer(mockContentLinkContext);
}

[TestCase("http://foo", "http://foo")]
[TestCase("https://foo", "https://foo")]
Expand All @@ -31,7 +38,8 @@ public void ContentLink_Renders(string uri, string expectedUri)
var actual = stringWriter.ToString();

// assert
actual.Should().Be($"<a class=\"HtmlEncode[[govuk-link]]\" href=\"HtmlEncode[[{expectedUri}]]\">HtmlEncode[[Foo]]</a>");
actual.Should().Be($"<a class=\"HtmlEncode[[govuk-link]]\" data-track-label=\"\" href=\"HtmlEncode[[{expectedUri}]]\">HtmlEncode[[Foo]]</a>");

}

[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Contentful.Core.Models;
using FluentAssertions;
using Microsoft.Extensions.WebEncoders.Testing;
using NSubstitute;
using NUnit.Framework;
using System.Collections.Generic;
using System.IO;
Expand All @@ -10,7 +11,13 @@ namespace Childrens_Social_Care_CPD_Tests.Contentful.Renderers;

public class HyperlinkRendererTests
{
private readonly HyperlinkRenderer _sut = new();
private readonly HyperlinkRenderer _sut;

public HyperlinkRendererTests()
{
var mockContentLinkContext = Substitute.For<IContentLinkContext>();
_sut = new HyperlinkRenderer(mockContentLinkContext);
}

[Test]
public void HyperlinkToHtml_Returns_Anchor()
Expand All @@ -34,7 +41,7 @@ public void HyperlinkToHtml_Returns_Anchor()
var actual = stringWriter.ToString();

// assert
actual.Should().Be("<a class=\"HtmlEncode[[govuk-link]]\" href=\"HtmlEncode[[Bar]]\">HtmlEncode[[Foo]]</a>");
actual.Should().Be("<a class=\"HtmlEncode[[govuk-link]]\" data-track-label=\"\" href=\"HtmlEncode[[Bar]]\">HtmlEncode[[Foo]]</a>");
}

[Test]
Expand All @@ -57,6 +64,6 @@ public void HyperlinkToHtml_Returns_Anchor_With_Empty_Text()
var actual = stringWriter.ToString();

// assert
actual.Should().Be("<a class=\"HtmlEncode[[govuk-link]]\" href=\"HtmlEncode[[Bar]]\"></a>");
actual.Should().Be("<a class=\"HtmlEncode[[govuk-link]]\" data-track-label=\"\" href=\"HtmlEncode[[Bar]]\"></a>");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Childrens_Social_Care_CPD.Contentful.Renderers;

namespace Childrens_Social_Care_CPD.Contentful.Contexts
{
public class ContentLinkContext : IContentLinkContext
{
private readonly IHttpContextAccessor _httpContextAccessor;
public ContentLinkContext(IHttpContextAccessor httpContextAccessor)
{
_httpContextAccessor = httpContextAccessor;
}
public string Path => _httpContextAccessor.HttpContext?.Request.Path;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,18 @@

namespace Childrens_Social_Care_CPD.Contentful.Renderers;

interface IContentLinkContext
{
string Path { get; }
}

internal class ContentLinkRenderer : IRendererWithOptions<ContentLink>
{
private readonly IContentLinkContext _context;
public ContentLinkRenderer(IContentLinkContext contentLinkContext)
{
_context = contentLinkContext;
}
public IHtmlContent Render(ContentLink item, RendererOptions options = null)
{
var tagBuilder = new TagBuilder("a");
Expand All @@ -23,6 +33,7 @@ string s when s.StartsWith('/') => s,
{
tagBuilder.AddCssClass(options.Css);
}
tagBuilder.Attributes.Add("data-track-label", _context.Path);
tagBuilder.InnerHtml.Append(item.Name);
return tagBuilder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ namespace Childrens_Social_Care_CPD.Contentful.Renderers;

internal class HyperlinkRenderer : IRenderer<Hyperlink>
{
private readonly IContentLinkContext _context;
public HyperlinkRenderer(IContentLinkContext contentLinkContext)
{
_context = contentLinkContext;
}
public IHtmlContent Render(Hyperlink item)
{
var linkText = (item.Content.FirstOrDefault() as Text)?.Value;
var anchor = new TagBuilder("a");
anchor.AddCssClass("govuk-link");
anchor.Attributes.Add("href", item.Data.Uri);
anchor.Attributes.Add("data-track-label", _context.Path);
anchor.InnerHtml.SetContent(linkText);
return anchor;
}
Expand Down
5 changes: 4 additions & 1 deletion Childrens-Social-Care-CPD/Views/Shared/_BackLink.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

@model ContentLink

@if (Model == null) return;
@if (Model == null)
{
return;
}

<div class="govuk-width-container back-link">
@{
Expand Down
4 changes: 2 additions & 2 deletions Childrens-Social-Care-CPD/Views/Shared/_ColumnLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

@foreach (var group in Model.Items.Select((e, i) => new { ContentItem = e, Grouping = (i / Model.ColumnCount) }).GroupBy(e => e.Grouping))
{
<div class="govuk-grid-row">
<div class="govuk-grid-row column-layout-row">
@foreach (var item in group)
{
<div class="@gridClass govuk-!-margin-bottom-4">
<div class="@gridClass govuk-!-margin-bottom-4 column">
@{ await Html.RenderContentfulPartialAsync(item.ContentItem); }
</div>
}
Expand Down
2 changes: 1 addition & 1 deletion Childrens-Social-Care-CPD/Views/Shared/_ErrorLayout.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
</header>

<main class="govuk-main-wrapper govuk-main-wrapper--auto-spacing govuk-!-padding-top-0" id="main-content" role="main">
<partial name="_BetaBanner" />
<partial name="_BetaBanner" />
<div class="govuk-width-container ">
@RenderBody()
</div>
Expand Down
28 changes: 15 additions & 13 deletions Childrens-Social-Care-CPD/Views/Shared/_LinkListCard.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
@model LinkListCard
@inject IRenderer<ContentLink> _contentLinkRenderer

<govuk-heading level="2" display-size="3">
@Model.Title
</govuk-heading>
<ul class="govuk-list">
@foreach (var contentLink in Model.Links)
{
<li>
<h3>
@_contentLinkRenderer.Render(contentLink)
</h3>
</li>
}
</ul>
<div>
<govuk-heading level="2" display-size="3">
@Model.Title
</govuk-heading>
<ul class="govuk-list">
@foreach (var contentLink in Model.Links)
{
<li>
<h3>
@_contentLinkRenderer.Render(contentLink)
</h3>
</li>
}
</ul>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
: "dfe-vertical-nav__section-item";

<li class="@css">
<a class="dfe-vertical-nav__link" href="@menuItem.Uri">@menuItem.Name</a>
<a class="dfe-vertical-nav__link" href="@uri">@menuItem.Name</a>
</li>
}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion Childrens-Social-Care-CPD/Views/_ViewStart.cshtml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@{
Layout = "_Layout";
Layout = "_SiteLayout";
}
3 changes: 3 additions & 0 deletions Childrens-Social-Care-CPD/WebApplicationBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Childrens_Social_Care_CPD.Configuration;
using Childrens_Social_Care_CPD.Contentful;
using Childrens_Social_Care_CPD.Contentful.Contexts;
using Childrens_Social_Care_CPD.Contentful.Renderers;
using Childrens_Social_Care_CPD.Core.Resources;
using Childrens_Social_Care_CPD.DataAccess;
Expand Down Expand Up @@ -52,6 +53,8 @@ public static void AddDependencies(this WebApplicationBuilder builder)
return client;
});

builder.Services.AddScoped<IContentLinkContext, ContentLinkContext>();

// Register all the IRender<T> & IRenderWithOptions<T> implementations in the assembly
var assemblyTypes = System.Reflection.Assembly.GetExecutingAssembly().GetTypes();

Expand Down
3 changes: 2 additions & 1 deletion Childrens-Social-Care-CPD/styles/scss/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ $moj-images-path: "/assets/images/moj/";
@import "overrides/dfe-overrides";
@import "overrides/dfe-vertical-nav";
@import "overrides/govuk-overrides";
@import "overrides/site";
@import "overrides/site";
@import "components/ColumnLayout";
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.column-layout-row {
display: flex;
min-height: 200px
}

.column-layout-row .column {
display: flex;
}
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ CONTENT TITLE BANNER
background-color: #f3f2f1;
border-bottom: 3px solid #003a69;
max-width: 100%;
flex: 1;
}

.dfe-card.dfe-card--blog-card {
Expand Down
9 changes: 9 additions & 0 deletions Childrens-Social-Care-CPD/wwwroot/css/application.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Childrens-Social-Care-CPD/wwwroot/css/application.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Childrens-Social-Care-CPD/wwwroot/css/application.min.css

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading

0 comments on commit 95e121b

Please sign in to comment.