diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..c25be37 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "nuget" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "weekly" + commit-message: + prefix: "CONFIG" + labels: + - "dependencies" + ignore: + - dependency-name: "FluentAssertions" + versions: ["8.x", "9.x", "10.x", "*"] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8c7da3a..75e668b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,8 +9,6 @@ on: - synchronize - reopened - closed - branches: - - main jobs: build: name: Build @@ -19,9 +17,9 @@ jobs: - name: Enable long paths for Git run: git config --system core.longpaths true - name: Check out - uses: actions/checkout@v3 + uses: actions/checkout@v5 - name: Setup .Net - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v5 with: dotnet-version: 10.0.100 - name: Restore @@ -62,7 +60,7 @@ jobs: contains(github.event.pull_request.labels.*.name, 'RELEASES') steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v5 with: token: ${{ secrets.PAT_FOR_TAGGING }} - name: Configure Git @@ -135,9 +133,9 @@ jobs: if: needs.add_tag.result == 'success' steps: - name: Check out - uses: actions/checkout@v3 + uses: actions/checkout@v5 - name: Setup .Net - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v5 with: dotnet-version: 10.0.100 - name: Restore diff --git a/.github/workflows/prLinter.yml b/.github/workflows/prLinter.yml index ec62d16..6785565 100644 --- a/.github/workflows/prLinter.yml +++ b/.github/workflows/prLinter.yml @@ -13,9 +13,10 @@ jobs: label: name: Label runs-on: ubuntu-latest + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} steps: - name: Apply Label - uses: actions/github-script@v6 + uses: actions/github-script@v8 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: >- @@ -84,17 +85,17 @@ jobs: } permissions: contents: read - pull-requests: write issues: write + pull-requests: write requireIssueOrTask: name: Require Issue Or Task Association runs-on: ubuntu-latest steps: - name: Check out - uses: actions/checkout@v3 + uses: actions/checkout@v5 - name: Get PR Information id: get_pr_info - uses: actions/github-script@v6 + uses: actions/github-script@v8 with: script: >2- const pr = await github.rest.pulls.get({ @@ -111,20 +112,18 @@ jobs: console.log(`PR Body: ${prBody}`); - name: Check For Associated Issues Or Tasks id: check_for_issues_or_tasks - if: ${{ steps.get_pr_info.outputs.prOwner != 'dependabot[bot]' }} + if: ${{ !contains(',dependabot[bot],', format(',{0},', steps.get_pr_info.outputs.prOwner)) }} + env: + PR_BODY: ${{ steps.get_pr_info.outputs.description }} run: >2- - PR_BODY="${{ steps.get_pr_info.outputs.description }}" - echo "::notice::Raw PR Body: $PR_BODY" - - if [[ -z "$PR_BODY" ]]; then + if [[ -z "${PR_BODY:-}" ]]; then echo "Error: PR description does not contain any links to issue(s)/task(s) (e.g., 'closes #123' / 'closes AB#123' / 'fixes #123' / 'fixes AB#123')." exit 1 fi - PR_BODY=$(echo "$PR_BODY" | tr -s '\r\n' ' ' | tr '\n' ' ' | xargs) - echo "::notice::Normalized PR Body: $PR_BODY" + NORMALIZED_PR_BODY=$(printf '%s' "$PR_BODY" | tr '\r\n' ' ' | tr -s ' ') - if echo "$PR_BODY" | grep -Piq "((close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\s*(\[#\d+\]|\#\d+)|(?:close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\s*(\[AB#\d+\]|AB#\d+))"; then + if printf '%s' "$NORMALIZED_PR_BODY" | grep -Piq "(close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\s*(\[#[0-9]+\]|#[0-9]+|\[AB#[0-9]+\]|AB#[0-9]+)"; then echo "Valid PR description." else echo "Error: PR description does not contain any links to issue(s)/task(s) (e.g., 'closes #123' / 'closes AB#123' / 'fixes #123' / 'fixes AB#123')." @@ -134,3 +133,42 @@ jobs: permissions: contents: read pull-requests: read + setAuthorAsPrAssignee: + name: Set Author As PR Assignee + runs-on: ubuntu-latest + if: ${{ github.event.pull_request.head.repo.full_name == github.repository }} + steps: + - name: Set Author As PR Assignee + uses: actions/github-script@v8 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: > + const pr = context.payload.pull_request; + + if (!pr) { + console.log('No pull request context available.'); + return; + } + + + const author = pr.user.login; + + if (author.endsWith('[bot]')) { + console.log(`Skipping bot author: ${author}`); + return; + } + + + console.log(`Assigning PR to author: ${author}`); + + + await github.rest.issues.addAssignees({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pr.number, + assignees: [author] + }); + permissions: + contents: read + issues: write + pull-requests: write diff --git a/NHSDigital.ApiPlatform.Infrastructure/NHSDigital.ApiPlatform.Infrastructure.csproj b/NHSDigital.ApiPlatform.Infrastructure/NHSDigital.ApiPlatform.Infrastructure.csproj index 5a2a5b3..b98691e 100644 --- a/NHSDigital.ApiPlatform.Infrastructure/NHSDigital.ApiPlatform.Infrastructure.csproj +++ b/NHSDigital.ApiPlatform.Infrastructure/NHSDigital.ApiPlatform.Infrastructure.csproj @@ -9,7 +9,7 @@ - + diff --git a/NHSDigital.ApiPlatform.Infrastructure/Services/ScriptGenerationService.cs b/NHSDigital.ApiPlatform.Infrastructure/Services/ScriptGenerationService.cs index 8457d81..cdb60a7 100644 --- a/NHSDigital.ApiPlatform.Infrastructure/Services/ScriptGenerationService.cs +++ b/NHSDigital.ApiPlatform.Infrastructure/Services/ScriptGenerationService.cs @@ -7,7 +7,7 @@ using ADotNet.Clients; using ADotNet.Models.Pipelines.GithubPipelines.DotNets; using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks; -using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks.SetupDotNetTaskV3s; +using ADotNet.Models.Pipelines.GithubPipelines.DotNets.Tasks.SetupDotNetTaskV5s; namespace NHSDigital.ApiPlatform.Infrastructure.Services { @@ -30,8 +30,7 @@ public void GenerateBuildScript(string branchName, string projectName, string do PullRequest = new PullRequestEvent { - Types = ["opened", "synchronize", "reopened", "closed"], - Branches = [branchName] + Types = ["opened", "synchronize", "reopened", "closed"] } }, @@ -52,16 +51,16 @@ public void GenerateBuildScript(string branchName, string projectName, string do Run = "git config --system core.longpaths true" }, - new CheckoutTaskV3 + new CheckoutTaskV5 { Name = "Check out" }, - new SetupDotNetTaskV3 + new SetupDotNetTaskV5 { Name = "Setup .Net", - With = new TargetDotNetVersionV3 + With = new TargetDotNetVersionV5 { DotNetVersion = dotNetVersion } @@ -108,7 +107,7 @@ dotnet test $project.FullName --no-build --verbosity normal }, { "add_tag", - new TagJob( + new TagJobV2( runsOn: BuildMachines.UbuntuLatest, dependsOn: "build", projectRelativePath: $"{projectName}/{projectName}.csproj", @@ -120,7 +119,7 @@ dotnet test $project.FullName --no-build --verbosity normal }, { "publish", - new PublishJobV2( + new PublishJobV4( runsOn: BuildMachines.UbuntuLatest, dependsOn: "add_tag", dotNetVersion: dotNetVersion, @@ -164,24 +163,25 @@ public void GeneratePrLintScript(string branchName) { { "label", - new LabelJobV2(runsOn: BuildMachines.UbuntuLatest) + new LabelJobV3(runsOn: BuildMachines.UbuntuLatest) { - Name = "Label", - Permissions = new Dictionary - { - { "contents", "read" }, - { "pull-requests", "write" }, - { "issues", "write" } - } + Name = "Label" } }, { "requireIssueOrTask", - new RequireIssueOrTaskJob() + new RequireIssueOrTaskJobV2(excludedAuthors: "dependabot[bot]") { Name = "Require Issue Or Task Association", } }, + { + "setAuthorAsPrAssignee", + new SetAuthorAsPrAssigneeJobV2(runsOn: BuildMachines.UbuntuLatest) + { + Name = "Set Author As PR Assignee", + } + }, } }; diff --git a/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Acceptance/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Acceptance.csproj b/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Acceptance/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Acceptance.csproj index 4873b2f..988a537 100644 --- a/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Acceptance/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Acceptance.csproj +++ b/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Acceptance/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Acceptance.csproj @@ -15,10 +15,10 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + - + all diff --git a/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Integration/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Integration.csproj b/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Integration/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Integration.csproj index 9703366..7da49e5 100644 --- a/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Integration/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Integration.csproj +++ b/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Integration/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Integration.csproj @@ -19,12 +19,12 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - + + + + + + all diff --git a/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Unit/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Unit.csproj b/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Unit/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Unit.csproj index 760e289..80d7a31 100644 --- a/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Unit/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Unit.csproj +++ b/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Unit/NHSDigital.ApiPlatform.Sdk.AspNetCore.Tests.Unit.csproj @@ -15,8 +15,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/NHSDigital.ApiPlatform.Sdk.Tests.Acceptance/NHSDigital.ApiPlatform.Sdk.Tests.Acceptance.csproj b/NHSDigital.ApiPlatform.Sdk.Tests.Acceptance/NHSDigital.ApiPlatform.Sdk.Tests.Acceptance.csproj index 86cf35c..aa0fbee 100644 --- a/NHSDigital.ApiPlatform.Sdk.Tests.Acceptance/NHSDigital.ApiPlatform.Sdk.Tests.Acceptance.csproj +++ b/NHSDigital.ApiPlatform.Sdk.Tests.Acceptance/NHSDigital.ApiPlatform.Sdk.Tests.Acceptance.csproj @@ -15,10 +15,10 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - + - + all diff --git a/NHSDigital.ApiPlatform.Sdk.Tests.Integration/NHSDigital.ApiPlatform.Sdk.Tests.Integration.csproj b/NHSDigital.ApiPlatform.Sdk.Tests.Integration/NHSDigital.ApiPlatform.Sdk.Tests.Integration.csproj index a37ddc5..87d16f0 100644 --- a/NHSDigital.ApiPlatform.Sdk.Tests.Integration/NHSDigital.ApiPlatform.Sdk.Tests.Integration.csproj +++ b/NHSDigital.ApiPlatform.Sdk.Tests.Integration/NHSDigital.ApiPlatform.Sdk.Tests.Integration.csproj @@ -19,12 +19,12 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - + + + + + + all diff --git a/NHSDigital.ApiPlatform.Sdk.Tests.Unit/NHSDigital.ApiPlatform.Sdk.Tests.Unit.csproj b/NHSDigital.ApiPlatform.Sdk.Tests.Unit/NHSDigital.ApiPlatform.Sdk.Tests.Unit.csproj index a424a23..8af5f6b 100644 --- a/NHSDigital.ApiPlatform.Sdk.Tests.Unit/NHSDigital.ApiPlatform.Sdk.Tests.Unit.csproj +++ b/NHSDigital.ApiPlatform.Sdk.Tests.Unit/NHSDigital.ApiPlatform.Sdk.Tests.Unit.csproj @@ -15,8 +15,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - + + diff --git a/NHSDigital.ApiPlatform.Sdk/NHSDigital.ApiPlatform.Sdk.csproj b/NHSDigital.ApiPlatform.Sdk/NHSDigital.ApiPlatform.Sdk.csproj index 68d7b6f..737aef8 100644 --- a/NHSDigital.ApiPlatform.Sdk/NHSDigital.ApiPlatform.Sdk.csproj +++ b/NHSDigital.ApiPlatform.Sdk/NHSDigital.ApiPlatform.Sdk.csproj @@ -56,8 +56,8 @@ - - + +