Skip to content

Commit fdb50e3

Browse files
authored
Merge pull request #124 from TechnologyEnhancedLearning/RC
Merge LH Canterbury release to master
2 parents e59dc78 + 0c3fa62 commit fdb50e3

File tree

16 files changed

+7669
-87
lines changed

16 files changed

+7669
-87
lines changed

.github/workflows/auto-merge.yml

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
name: Auto Merge Dependabot PRs
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
9+
permissions:
10+
pull-requests: write
11+
contents: write
12+
13+
jobs:
14+
auto-merge:
15+
runs-on: ubuntu-latest
16+
if: github.actor == 'dependabot[bot]'
17+
18+
steps:
19+
- name: Checkout the repository
20+
uses: actions/checkout@v3
21+
22+
- name: Set up GitHub CLI
23+
run: |
24+
# Install GitHub CLI (gh)
25+
sudo apt-get update
26+
sudo apt-get install gh
27+
28+
# Authenticate GitHub CLI using the provided token
29+
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
30+
31+
- name: Wait for CI workflow to pass (Ensure CI workflow succeeded)
32+
id: wait_for_ci
33+
run: |
34+
# Get the PR number from the GitHub event
35+
PR_NUMBER=${{ github.event.pull_request.number }}
36+
echo "Checking CI status for PR #$PR_NUMBER"
37+
38+
# Define the maximum wait time (in seconds) and the polling interval (in seconds)
39+
MAX_WAIT_TIME=1800 # 30 minutes
40+
POLL_INTERVAL=10 # Check every 10 seconds
41+
42+
# Initialize a timer
43+
elapsed_time=0
44+
45+
# Poll CI status until all checks are completed
46+
while true; do
47+
# Fetch the status check rollup for the PR
48+
CI_STATUS=$(gh pr view $PR_NUMBER --json statusCheckRollup)
49+
50+
# Log the fetched response
51+
echo "CI Status Response: $CI_STATUS"
52+
53+
# Parse the checks and check their status
54+
ALL_COMPLETED=true
55+
ALL_CHECKS_PASSED=true
56+
57+
for check in $(echo "$CI_STATUS" | jq -r '.statusCheckRollup[] | @base64'); do
58+
_jq() {
59+
echo "${check}" | base64 --decode | jq -r "${1}"
60+
}
61+
62+
status=$(_jq '.status')
63+
conclusion=$(_jq '.conclusion')
64+
check_name=$(_jq '.name')
65+
66+
# Log check details
67+
echo "Check: $check_name, Status: $status, Conclusion: $conclusion"
68+
if [[ "$check_name" == "auto-merge" ]]; then
69+
echo "Skipping 'auto-merge' workflow check to prevent self-referencing."
70+
continue
71+
fi
72+
73+
# If any check is still queued, set ALL_COMPLETED to false
74+
if [[ "$status" == "QUEUED" ]]; then
75+
ALL_COMPLETED=false
76+
fi
77+
78+
# If any check is still in progress, set ALL_COMPLETED to false
79+
if [[ "$status" == "IN_PROGRESS" ]]; then
80+
ALL_COMPLETED=false
81+
fi
82+
83+
# If any completed check has failed, set ALL_CHECKS_PASSED to false
84+
if [[ "$status" == "COMPLETED" && "$conclusion" != "SUCCESS" ]]; then
85+
ALL_CHECKS_PASSED=false
86+
fi
87+
done
88+
89+
# Break the loop if all checks are completed
90+
if [[ "$ALL_COMPLETED" == true ]]; then
91+
break
92+
fi
93+
94+
# Wait for the next polling interval
95+
echo "Waiting for checks to complete... ($elapsed_time/$MAX_WAIT_TIME seconds elapsed)"
96+
sleep $POLL_INTERVAL
97+
elapsed_time=$((elapsed_time + POLL_INTERVAL))
98+
99+
# Exit if the maximum wait time is exceeded
100+
if [[ "$elapsed_time" -ge "$MAX_WAIT_TIME" ]]; then
101+
echo "Timed out waiting for CI checks to complete."
102+
exit 1
103+
fi
104+
done
105+
106+
# Final check: Ensure all CI checks passed
107+
if [[ "$ALL_CHECKS_PASSED" == false ]]; then
108+
echo "One or more CI checks failed. Aborting merge."
109+
exit 1
110+
fi
111+
112+
echo "All CI checks passed successfully."
113+
114+
115+
- name: Check Target Branch and PR Title
116+
id: check_branch
117+
run: |
118+
PR_TITLE='${{ github.event.pull_request.title }}'
119+
echo "Original PR Title: $PR_TITLE"
120+
121+
# Escape problematic quotes
122+
ESCAPED_TITLE=$(echo "$PR_TITLE" | sed 's/"/\\"/g')
123+
echo "Escaped PR Title: $ESCAPED_TITLE"
124+
125+
if [[ "$ESCAPED_TITLE" =~ ([0-9]+\.[0-9]+\.[0-9]+).*to.*([0-9]+\.[0-9]+\.[0-9]+) ]]; then
126+
# Extract version numbers
127+
OLD_VERSION="${BASH_REMATCH[1]}"
128+
NEW_VERSION="${BASH_REMATCH[2]}"
129+
echo "Version change detected: $OLD_VERSION to $NEW_VERSION"
130+
131+
# Split version into major, minor, patch components
132+
OLD_MAJOR=$(echo "$OLD_VERSION" | cut -d '.' -f1)
133+
OLD_MINOR=$(echo "$OLD_VERSION" | cut -d '.' -f2)
134+
OLD_PATCH=$(echo "$OLD_VERSION" | cut -d '.' -f3)
135+
136+
NEW_MAJOR=$(echo "$NEW_VERSION" | cut -d '.' -f1)
137+
NEW_MINOR=$(echo "$NEW_VERSION" | cut -d '.' -f2)
138+
NEW_PATCH=$(echo "$NEW_VERSION" | cut -d '.' -f3)
139+
140+
# Check if it's a minor or patch update
141+
if [[ "$OLD_MAJOR" == "$NEW_MAJOR" ]] && [[ "$OLD_MINOR" == "$NEW_MINOR" ]] && [[ "$NEW_PATCH" -gt "$OLD_PATCH" ]]; then
142+
echo "Patch update detected"
143+
echo "should_merge=true" >> $GITHUB_ENV
144+
elif [[ "$OLD_MAJOR" == "$NEW_MAJOR" ]] && [[ "$NEW_MINOR" -gt "$OLD_MINOR" ]]; then
145+
echo "Minor update detected"
146+
echo "should_merge=true" >> $GITHUB_ENV
147+
else
148+
echo "No minor/patch update detected"
149+
echo "should_merge=false" >> $GITHUB_ENV
150+
fi
151+
else
152+
echo "No version change detected"
153+
echo "should_merge=false" >> $GITHUB_ENV
154+
fi
155+
156+
- name: Debug Context
157+
uses: actions/github-script@v6
158+
with:
159+
script: |
160+
console.log("Target branch:", context.payload.pull_request.base.ref);
161+
162+
- name: Check if Should Merge
163+
run: |
164+
echo "DEBUG: should_merge=${{ env.should_merge }}"
165+
if [[ "${{ env.should_merge }}" == "true" ]] && [[ "${{ github.event.pull_request.base.ref }}" == "Automatic_version_update_dependabot" ]]; then
166+
echo "DEBUG: should merge PR"
167+
echo "should_merge=true" >> $GITHUB_ENV
168+
else
169+
echo "DEBUG: skip merge"
170+
echo "should_merge=false" >> $GITHUB_ENV
171+
fi
172+
173+
- name: Merge Pull Request
174+
if: ${{ env.should_merge == 'true' }}
175+
uses: actions/github-script@v6
176+
with:
177+
script: |
178+
github.rest.pulls.merge({
179+
owner: context.repo.owner,
180+
repo: context.repo.repo,
181+
pull_number: context.payload.pull_request.number,
182+
merge_method: "squash"
183+
});

.github/workflows/continuous-integration-workflow.yml

Lines changed: 70 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v3
1414

15-
- name: Setup .NET Core SDK 6.0
15+
- name: Setup .NET Core SDK 8.0
1616
uses: actions/setup-dotnet@v3
1717
with:
18-
dotnet-version: 6.0.x
18+
dotnet-version: 8.0.x
1919

2020
- name: Add Azure artifact
2121
run: dotnet nuget add source 'https://pkgs.dev.azure.com/e-LfH/_packaging/LearningHubFeed/nuget/v3/index.json' --name 'LearningHubFeed' --username 'kevin.whittaker' --password ${{ secrets.AZURE_DEVOPS_PAT }} --store-password-in-clear-text
@@ -43,25 +43,77 @@ jobs:
4343

4444
- name: Build SQL Server Database project
4545
run: |
46-
# List all .sqlproj files except for .sqlproj
46+
# Enable strict error handling
47+
$ErrorActionPreference = 'Stop'
48+
49+
# Initialize an error collection
50+
$errors = @()
51+
52+
# List all .sqlproj files
4753
$sqlproj_files = Get-ChildItem -Path . -Filter *.sqlproj -Recurse
48-
49-
# Build each .csproj file
50-
foreach ($sqlproj_file in $sqlproj_files) {
51-
Write-Host "Building $($sqlproj_file.FullName)"
52-
msbuild "$($sqlproj_file.FullName)" /p:Configuration=Release
53-
}
54-
55-
- name: Build solution excluding SQL project
54+
55+
if ($sqlproj_files.Count -eq 0) {
56+
$errors += "No .sqlproj files found."
57+
} else {
58+
foreach ($sqlproj_file in $sqlproj_files) {
59+
Write-Host "Building $($sqlproj_file.FullName)"
60+
try {
61+
$output = &msbuild "$($sqlproj_file.FullName)" /p:Configuration=Release /nologo 2>&1
62+
if (!$?) {
63+
$errors += "Failed to build $($csproj_file.FullName): $output"
64+
}
65+
} catch {
66+
# Capture detailed error information
67+
$errorMessage = "Error building $($sqlproj_file.FullName): $($_.Exception.Message)"
68+
Write-Host $errorMessage
69+
$errors += $errorMessage
70+
}
71+
}
72+
}
73+
74+
# Display all accumulated errors
75+
if ($errors.Count -gt 0) {
76+
Write-Host "SQL Project Build Errors:"
77+
$errors | ForEach-Object { Write-Host $_ }
78+
exit 1
79+
}
80+
81+
- name: Build Solution Excluding SQL Project
5682
run: |
57-
# List all .csproj files except for .sqlproj
83+
# Enable strict error handling
84+
$ErrorActionPreference = 'Stop'
85+
86+
# Initialize an error collection
87+
$errors = @()
88+
89+
# List all .csproj files except .sqlproj
5890
$csproj_files = Get-ChildItem -Path . -Filter *.csproj -Recurse | Where-Object { $_.FullName -notmatch '\\.sqlproj$' }
59-
60-
# Build each .csproj file
61-
foreach ($csproj_file in $csproj_files) {
62-
Write-Host "Building $($csproj_file.FullName)"
63-
dotnet build "$($csproj_file.FullName)"
64-
}
91+
92+
if ($csproj_files.Count -eq 0) {
93+
$errors += "No .csproj files found."
94+
} else {
95+
foreach ($csproj_file in $csproj_files) {
96+
Write-Host "Building $($csproj_file.FullName)"
97+
try {
98+
$output = &dotnet build "$($csproj_file.FullName)" --configuration Release 2>&1
99+
if (!$?) {
100+
$errors += "Failed to build $($csproj_file.FullName): $output"
101+
}
102+
} catch {
103+
# Capture detailed error information
104+
$errorMessage = "Error building $($csproj_file.FullName): $($_.Exception.Message)"
105+
Write-Host $errorMessage
106+
$errors += $errorMessage
107+
}
108+
}
109+
}
110+
111+
# Display all accumulated errors
112+
if ($errors.Count -gt 0) {
113+
Write-Host "Solution Build Errors:"
114+
$errors | ForEach-Object { Write-Host $_ }
115+
exit 1
116+
}
65117

66118
#- name: Test
67119
# run: dotnet test ${{ env.BuildParameters.TestProjects }}

Auth/LearningHub.Nhs.Auth.Tests/LearningHub.Nhs.Auth.Tests.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
<IsPackable>false</IsPackable>
77
<Platforms>x64</Platforms>
@@ -11,15 +11,15 @@
1111
<ItemGroup>
1212
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.8" />
1313
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.33" />
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
15-
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="17.0.0" />
16-
<PackageReference Include="Moq" Version="4.16.1" />
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
15+
<PackageReference Include="Microsoft.TestPlatform.TestHost" Version="17.12.0" />
16+
<PackageReference Include="Moq" Version="4.20.72" />
1717
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
1818
<PrivateAssets>all</PrivateAssets>
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2020
</PackageReference>
21-
<PackageReference Include="xunit" Version="2.4.1" />
22-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
21+
<PackageReference Include="xunit" Version="2.9.3" />
22+
<PackageReference Include="xunit.runner.visualstudio" Version="3.0.1">
2323
<PrivateAssets>all</PrivateAssets>
2424
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2525
</PackageReference>

Auth/LearningHub.Nhs.Auth/LearningHub.Nhs.Auth.csproj

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<UserSecretsId>00EF27C2-ECB6-4E37-A6B6-58E4E6189D0E</UserSecretsId>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
77
<Platforms>x64</Platforms>
@@ -98,12 +98,12 @@
9898
<ItemGroup>
9999
<PackageReference Include="AutoMapper" Version="10.1.1" />
100100
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.1.1" />
101-
<PackageReference Include="Azure.Extensions.AspNetCore.DataProtection.Blobs" Version="1.2.1" />
102-
<PackageReference Include="Azure.Extensions.AspNetCore.DataProtection.Keys" Version="1.1.0" />
103-
<PackageReference Include="Azure.Identity" Version="1.5.0" />
101+
<PackageReference Include="Azure.Extensions.AspNetCore.DataProtection.Blobs" Version="1.4.0" />
102+
<PackageReference Include="Azure.Extensions.AspNetCore.DataProtection.Keys" Version="1.3.0" />
103+
<PackageReference Include="Azure.Identity" Version="1.13.2" />
104104
<PackageReference Include="elfhHub.Nhs.Models" Version="3.0.8" />
105-
<PackageReference Include="FluentValidation" Version="10.3.4" />
106-
<PackageReference Include="IdentityServer4" Version="4.1.1" />
105+
<PackageReference Include="FluentValidation" Version="11.11.0" />
106+
<PackageReference Include="IdentityServer4" Version="4.1.2" />
107107
<PackageReference Include="IdentityServer4.Contrib.RedisStore" Version="4.0.0" />
108108
<PackageReference Include="LearningHub.Nhs.Caching" Version="2.0.0" />
109109
<PackageReference Include="LearningHub.Nhs.Models" Version="3.0.33" />
@@ -113,14 +113,14 @@
113113
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.0" />
114114
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="6.0.0" />
115115
<PackageReference Include="NHSUKViewComponents.Web" Version="1.0.27" />
116-
<PackageReference Include="NLog.Web.AspNetCore" Version="4.14.0" />
116+
<PackageReference Include="NLog.Web.AspNetCore" Version="5.3.15" />
117117
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
118118
<PrivateAssets>all</PrivateAssets>
119119
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
120120
</PackageReference>
121-
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
121+
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
122122
<PackageReference Include="UAParser" Version="3.1.47" />
123-
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.19.0" />
123+
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
124124
</ItemGroup>
125125

126126
<ItemGroup>

0 commit comments

Comments
 (0)