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: Details component, and schema deployment hardening #513

Merged
merged 28 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3bf4dcf
Details component (#500)
Maria-C1 Sep 9, 2024
30c8c9a
feat: added whitespace to force release (completion of detail component)
mattb-hippo Sep 10, 2024
150cd34
Merge pull request #507 from DFE-Digital/mattb/force-release
mattb-hippo Sep 10, 2024
c3936ca
fix: restore posix-style carriage returns
mattb-hippo Sep 11, 2024
a0d78c2
Merge pull request #508 from DFE-Digital/mattb/fix-carriage-returns
mattb-hippo Sep 11, 2024
be7b6d5
fix: restore posix-style carriage returns
mattb-hippo Sep 11, 2024
af045de
Merge branch 'next' into mattb/fix-carriage-returns
mattb-hippo Sep 11, 2024
9c21b07
Merge pull request #509 from DFE-Digital/mattb/fix-carriage-returns
mattb-hippo Sep 11, 2024
58bed61
removing all content to nuke carriage returns
mattb-hippo Sep 11, 2024
65a87f1
restored manifest content
mattb-hippo Sep 11, 2024
0bcac12
updated archive with new manifest
mattb-hippo Sep 11, 2024
c01c7fb
Merge pull request #510 from DFE-Digital/mattb/fix-carriage-returns
mattb-hippo Sep 11, 2024
8ba9f5b
ci: made environment choice instead of free text, handled mismatch be…
mattb-hippo Sep 16, 2024
bd73e15
ci: add SPACE ID env var to setup job
mattb-hippo Sep 16, 2024
41286a1
added test migration
mattb-hippo Sep 16, 2024
4e24b80
updated test migration
mattb-hippo Sep 16, 2024
88c0846
ci: add SPACE_ID to env vars for repoint alias job
mattb-hippo Sep 16, 2024
a8b3477
restored archive and manifest to original state
mattb-hippo Sep 16, 2024
79e0144
MC test script and carriage return test
Sep 18, 2024
63ea5f6
delete migrations file
Sep 18, 2024
3bb8d8e
archive and manifest with LF line endings
mattb-hippo Sep 18, 2024
7cb8c62
re-adding migrations archive file
Sep 18, 2024
9c9da31
resolve conflict
Sep 19, 2024
ca0bed9
fresh archive file
Sep 19, 2024
602ee9d
Merge pull request #511 from DFE-Digital/mattb/SWCD-2424-schema-deplo…
mattb-hippo Sep 19, 2024
a125d62
Merge branch 'main' into mattb/merge-main-to-next
mattb-hippo Sep 19, 2024
b68e295
whitespace change to force commit
mattb-hippo Sep 19, 2024
c260032
Merge pull request #514 from DFE-Digital/mattb/merge-main-to-next
mattb-hippo Sep 19, 2024
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
53 changes: 35 additions & 18 deletions .github/workflows/contentful-schema-migrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,24 @@ on:
inputs:
target_environment:
required: true
type: string

env:
MANAGEMENT_TOKEN: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
DELIVERY_KEY: ${{ secrets.TF_VAR_CPD_DELIVERY_KEY }}
SPACE_ID: ${{ secrets.TF_VAR_CPD_SPACE_ID }}
ENVIRONMENT: ${{ inputs.target_environment }}
SPACE_CAPACITY: ${{ vars.CONTENTFUL_SPACE_CAPACITY }}
default: 'dev'
type: choice
options:
- dev
- test
- prod

jobs:
setup:
runs-on: ubuntu-latest
environment: ${{inputs.target_environment}}

env:
MANAGEMENT_TOKEN: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
DELIVERY_KEY: ${{ secrets.TF_VAR_CPD_DELIVERY_KEY }}
ENVIRONMENT: ${{ inputs.target_environment == 'prod' && 'master' || inputs.target_environment }}
SPACE_CAPACITY: ${{ vars.CONTENTFUL_SPACE_CAPACITY }}
SPACE_ID: ${{ secrets.TF_VAR_CPD_SPACE_ID }}

outputs:
staging-environment: ${{ steps.staging-env.outputs.staging-environment }}
Expand All @@ -33,21 +39,21 @@ jobs:
working-directory: ./Contentful-Schema
run: npm ci

- name: Verify contentful space has available environment capacity
working-directory: ./Contentful-Schema/utils
run: node verify-space-capacity.js

- name: Get target environment current migration version
id: current-migration-version
working-directory: ./Contentful-Schema/utils
run: node get-environment-version.js

- name: Verify contentful space has available environment capacity
working-directory: ./Contentful-Schema/utils
run: node verify-space-capacity.js

- name: Determine timestamp for new staging environment
run: echo "TIMESTAMP=$(date +%Y-%m-%d-%H-%M-%S)" >> $GITHUB_ENV

- name: Set var for name of new environment
id: staging-env
run: echo "staging-environment=$(echo ${{ inputs.target_environment }}-${{ env.TIMESTAMP }})" >> $GITHUB_OUTPUT
run: echo "staging-environment=$(echo ${{ inputs.target_environment == 'prod' && 'master' || inputs.target_environment }}-${{ env.TIMESTAMP }})" >> $GITHUB_OUTPUT

- name: Extract migration files from archive
working-directory: ./Contentful-Schema/migrations
Expand All @@ -66,19 +72,23 @@ jobs:
if: ${{ join(needs.setup.outputs.required-migrations, '') != '[]' }}
needs: [setup]
runs-on: ubuntu-latest
steps:

env:
MANAGEMENT_TOKEN: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
SPACE_ID: ${{ secrets.TF_VAR_CPD_SPACE_ID }}

steps:
- name: Install Contentful CLI
run: npm install -g contentful-cli

- name: Login to Contentful with management token
run: contentful login --management-token "${{ env.MANAGEMENT_TOKEN }}"

- name: Set target space
run: contentful space use --space-id ${{ env.SPACE_ID }} --environment-id ${{ inputs.target_environment }}
run: contentful space use --space-id ${{ env.SPACE_ID }} --environment-id ${{ inputs.target_environment == 'prod' && 'master' || inputs.target_environment }}

- name: Clone target environment ${{ inputs.target_environment }} to staging environment ${{ needs.setup.outputs.staging-environment }}
run: contentful space environment create --name ${{ needs.setup.outputs.staging-environment }} --environment-id ${{ needs.setup.outputs.staging-environment }} --source ${{ inputs.target_environment }}
- name: Clone target environment ${{ inputs.target_environment == 'prod' && 'master' || inputs.target_environment }} to staging environment ${{ needs.setup.outputs.staging-environment }}
run: contentful space environment create --name ${{ needs.setup.outputs.staging-environment }} --environment-id ${{ needs.setup.outputs.staging-environment }} --source ${{ inputs.target_environment == 'prod' && 'master' || inputs.target_environment }}

migrate:
if: ${{ join(needs.setup.outputs.required-migrations, '') != '[]' }}
Expand All @@ -89,6 +99,10 @@ jobs:
matrix:
value: ${{fromJSON(needs.setup.outputs.required-migrations)}}

env:
MANAGEMENT_TOKEN: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
SPACE_ID: ${{ secrets.TF_VAR_CPD_SPACE_ID }}

steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -124,6 +138,9 @@ jobs:
runs-on: ubuntu-latest
env:
STAGING_ENVIRONMENT: ${{ needs.setup.outputs.staging-environment }}
MANAGEMENT_TOKEN: ${{ secrets.CONTENTFUL_MANAGEMENT_TOKEN }}
ENVIRONMENT: ${{ inputs.target_environment == 'prod' && 'master' || inputs.target_environment }}
SPACE_ID: ${{ secrets.TF_VAR_CPD_SPACE_ID }}

steps:
- uses: actions/checkout@v3
Expand All @@ -136,6 +153,6 @@ jobs:
working-directory: ./Contentful-Schema
run: npm ci

- name: Run script to point alias ${{ inputs.target_environment }} at new environment ${{ env.STAGING_ENVIRONMENT }}
- name: Run script to point alias ${{ inputs.target_environment == 'prod' && 'master' || inputs.target_environment }} at new environment ${{ env.STAGING_ENVIRONMENT }}
working-directory: ./Contentful-Schema/utils
run: node point-alias-at-environment.js
128 changes: 65 additions & 63 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
@@ -1,66 +1,68 @@
name: Static code analysis
on:
pull_request:
branches:
- main
- next
jobs:
code-analysis:
name: Static code analysis
on:
pull_request:
branches:
- main
- next
jobs:
code-analysis:
name: Static code analysis
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu' # Alternative distribution options are available.

- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v3
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache SonarCloud coverage
id: cache-sonar-coverage
uses: actions/cache@v3
with:
path: ~\sonar\cache
key: ${{ runner.os }}-coverage
restore-keys: ${{ runner.os }}-coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install SonarCloud scanners
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
run: dotnet tool install --global dotnet-sonarscanner

- name: Install SonarCloud coverage
if: steps.cache-sonar-coverage.outputs.cache-hit != 'true'
run: dotnet tool install --global dotnet-coverage
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: "zulu" # Alternative distribution options are available.

- name: Build, Test and Analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet-sonarscanner begin \
/k:"DFE-Digital_childrens-social-care-cpd" \
/o:"dfe-digital" \
/d:sonar.qualitygate.wait=true \
/d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml \
/d:sonar.exclusions="**/*.css,**/*.scss,**/Models/*,**/Program.cs,**/WebApplicationBuilderExtensions.cs,**/GraphQL/Queries/*" \
/d:sonar.test.exclusions="Childrens-Social-Care-CPD-Tests/**/*" \
/d:sonar.token="${{ secrets.SONAR_TOKEN }}" \
/d:sonar.host.url="https://sonarcloud.io"
dotnet build --no-incremental
dotnet-coverage collect --settings dotnet-cover-config.xml -f xml -o coverage.xml "dotnet test"
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
- name: Cache SonarCloud packages
uses: actions/cache@v1
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v3
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache SonarCloud coverage
id: cache-sonar-coverage
uses: actions/cache@v3
with:
path: ~\sonar\cache
key: ${{ runner.os }}-coverage
restore-keys: ${{ runner.os }}-coverage

- name: Install SonarCloud scanners
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
run: dotnet tool install --global dotnet-sonarscanner

- name: Install SonarCloud coverage
if: steps.cache-sonar-coverage.outputs.cache-hit != 'true'
run: dotnet tool install --global dotnet-coverage

- name: Build, Test and Analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
dotnet-sonarscanner begin \
/k:"DFE-Digital_childrens-social-care-cpd" \
/o:"dfe-digital" \
/d:sonar.qualitygate.wait=true \
/d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml \
/d:sonar.exclusions="**/*.css,**/*.scss,**/Models/*,**/Program.cs,**/WebApplicationBuilderExtensions.cs,**/GraphQL/Queries/*,**/Contentful-Schema/migrations/*.cjs" \
/d:sonar.test.exclusions="Childrens-Social-Care-CPD-Tests/**/*" \
/d:sonar.token="${{ secrets.SONAR_TOKEN }}" \
/d:sonar.host.url="https://sonarcloud.io"
dotnet build --no-incremental
dotnet-coverage collect --settings dotnet-cover-config.xml -f xml -o coverage.xml "dotnet test"
dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class EntityResolverTests
[TestCase("contentSeparator", typeof(ContentSeparator))]
[TestCase("detailedPathway", typeof(DetailedPathway))]
[TestCase("detailedRole", typeof(DetailedRole))]
[TestCase("details", typeof(Details))]
[TestCase("feedback", typeof(Feedback))]
[TestCase("heroBanner", typeof(HeroBanner))]
[TestCase("imageCard", typeof(ImageCard))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public partial class PartialsFactoryTests
new object[] { new ContentsAnchor(), "_ContentsAnchor" },
new object[] { new DetailedPathway(), "_DetailedPathway" },
new object[] { new DetailedRole(), "_DetailedRole" },
new object[] { new Details(), "_Details" },
new object[] { new Feedback(), "_Feedback" },
new object[] { new HeroBanner(), string.Empty },
new object[] { new LinkCard(), "_LinkCard" },
Expand Down
1 change: 1 addition & 0 deletions Childrens-Social-Care-CPD/Contentful/EntityResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public Type Resolve(string contentTypeId)
"contentSeparator" => typeof(ContentSeparator),
"detailedPathway" => typeof(DetailedPathway),
"detailedRole" => typeof(DetailedRole),
"details" => typeof(Details),
"feedback" => typeof(Feedback),
"heroBanner" => typeof(HeroBanner),
"imageCard" => typeof(ImageCard),
Expand Down
9 changes: 9 additions & 0 deletions Childrens-Social-Care-CPD/Contentful/Models/Details.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Contentful.Core.Models;

namespace Childrens_Social_Care_CPD.Contentful.Models;

public class Details : IContent
{
public string SummaryText { get; set; }
public Document DetailsText { get; set; }
}
1 change: 1 addition & 0 deletions Childrens-Social-Care-CPD/Contentful/PartialsFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static string GetPartialFor(IContent item)
ContentsAnchor => "_ContentsAnchor",
DetailedRole => "_DetailedRole",
DetailedPathway => "_DetailedPathway",
Details => "_Details",
Feedback => "_Feedback",
HeroBanner => string.Empty,// skip - handled in specific layout section
ImageCard => "_ImageCard",
Expand Down
6 changes: 3 additions & 3 deletions Childrens-Social-Care-CPD/Views/Shared/_AudioResource.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
@if (Model.Transcript.Content != null)
{
<details class="govuk-details govuk-!-margin-top-3" data-module="govuk-details">
<summary class="govuk-details__summary"> <span class="govuk-details__summary-text">View transcript </span></summary>
<summary class="govuk-details__summary"> <span class="govuk-details__summary-text">View transcript </span>
</summary>
<div class="govuk-details__text">
@{
await Html.RenderPartialAsync("_RichText", Model.Transcript);
Expand All @@ -23,5 +24,4 @@
</details>
}
</div>
</div>

</div>
16 changes: 16 additions & 0 deletions Childrens-Social-Care-CPD/Views/Shared/_Details.cshtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@using Childrens_Social_Care_CPD.Contentful;
@using Childrens_Social_Care_CPD.Contentful.Models;
@using Childrens_Social_Care_CPD.Contentful.Renderers;

@model Details

<details class="govuk-details">
<summary class="govuk-details__summary">
<span class="govuk-details__summary-text">
@Model.SummaryText
</span>
</summary>
<div class="govuk-details__text">
<partial name="_RichText" model="Model.DetailsText" />
</div>
</details>
Loading
Loading