From a5b5f512f260602d19afd021e678571db2aec2c9 Mon Sep 17 00:00:00 2001 From: Farshad DASHTI Date: Wed, 14 Aug 2024 12:02:10 +0100 Subject: [PATCH 1/7] Added a new step to the build workfow to build and publish a nuget package --- .../workflows/continuous-integration-dotnet.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/continuous-integration-dotnet.yml b/.github/workflows/continuous-integration-dotnet.yml index fe5af2b1b..4f8ac8a7f 100644 --- a/.github/workflows/continuous-integration-dotnet.yml +++ b/.github/workflows/continuous-integration-dotnet.yml @@ -97,6 +97,21 @@ jobs: reportgenerator -reports:./**/coverage.cobertura.xml -targetdir:./CoverageReport -reporttypes:SonarQube dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}" + - uses: dorny/paths-filter@v3 + id: person-api-changes + with: + filters: | + client: + - 'Dfe.PersonsApi.Client/**' + + - name: Build, pack and publish + working-directory: Dfe.PersonsApi.Client + run: | + dotnet build -c Release + dotnet pack -c Release --no-build --output . + dotnet nuget push "*.nupkg" --api-key ${{ secrets.GITHUB_TOKEN }} --source https://nuget.pkg.github.com/DFE-Digital/index.json + if: steps.person-api-changes.client.src == 'true' + - name: Stop containers if: always() run: docker compose -f "docker-compose.yml" down From 6d7db895f8c903ef055063413a66c816293ab730 Mon Sep 17 00:00:00 2001 From: Farshad DASHTI Date: Wed, 14 Aug 2024 12:09:37 +0100 Subject: [PATCH 2/7] Changed the target condition so it wont run in CI --- PersonsApi/PersonsApi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PersonsApi/PersonsApi.csproj b/PersonsApi/PersonsApi.csproj index 0dfc029db..c21772e90 100644 --- a/PersonsApi/PersonsApi.csproj +++ b/PersonsApi/PersonsApi.csproj @@ -42,7 +42,7 @@ - + Date: Wed, 14 Aug 2024 12:18:10 +0100 Subject: [PATCH 3/7] Added a change for testing the new workflow --- Dfe.PersonsApi.Client/Generated/Client.g.cs | 2 +- Dfe.PersonsApi.Client/Generated/swagger.json | 2 +- PersonsApi/Controllers/ConstituenciesController.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dfe.PersonsApi.Client/Generated/Client.g.cs b/Dfe.PersonsApi.Client/Generated/Client.g.cs index cf06620d3..ea4e49c0e 100644 --- a/Dfe.PersonsApi.Client/Generated/Client.g.cs +++ b/Dfe.PersonsApi.Client/Generated/Client.g.cs @@ -139,7 +139,7 @@ public virtual async System.Threading.Tasks.Task GetMemberOf if (status_ == 404) { string responseText_ = ( response_.Content == null ) ? string.Empty : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - throw new PersonsApiException("Constituency not found", status_, responseText_, headers_, null); + throw new PersonsApiException("Constituency not found ", status_, responseText_, headers_, null); } else if (status_ == 400) diff --git a/Dfe.PersonsApi.Client/Generated/swagger.json b/Dfe.PersonsApi.Client/Generated/swagger.json index 719514ceb..42df4946a 100644 --- a/Dfe.PersonsApi.Client/Generated/swagger.json +++ b/Dfe.PersonsApi.Client/Generated/swagger.json @@ -35,7 +35,7 @@ } }, "404": { - "description": "Constituency not found" + "description": "Constituency not found " }, "400": { "description": "Constituency cannot be null or empty" diff --git a/PersonsApi/Controllers/ConstituenciesController.cs b/PersonsApi/Controllers/ConstituenciesController.cs index 999cfdf3c..b25e0da42 100644 --- a/PersonsApi/Controllers/ConstituenciesController.cs +++ b/PersonsApi/Controllers/ConstituenciesController.cs @@ -20,7 +20,7 @@ public ConstituenciesController(IPersonsQueries personQueries) [HttpGet("{constituencyName}/mp")] [SwaggerOperation(Summary = "Retrieve Member of Parliament by constituency name", Description = "Receives a constituency name and returns a Person object representing the Member of Parliament.")] [SwaggerResponse(200, "A Person object representing the Member of Parliament.", typeof(MemberOfParliament))] - [SwaggerResponse(404, "Constituency not found")] + [SwaggerResponse(404, "Constituency not found ")] [SwaggerResponse(400, "Constituency cannot be null or empty")] public async Task GetMemberOfParliamentByConstituencyAsync([FromRoute] string constituencyName, CancellationToken cancellationToken) { From 85ac647e8eab9c7a459b26747dd7b6aff4b4b4df Mon Sep 17 00:00:00 2001 From: Farshad DASHTI Date: Wed, 14 Aug 2024 12:26:49 +0100 Subject: [PATCH 4/7] Added environment varibale CI to the CI yaml file --- .github/workflows/continuous-integration-dotnet.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/continuous-integration-dotnet.yml b/.github/workflows/continuous-integration-dotnet.yml index 4f8ac8a7f..638bbb858 100644 --- a/.github/workflows/continuous-integration-dotnet.yml +++ b/.github/workflows/continuous-integration-dotnet.yml @@ -90,6 +90,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} ConnectionStrings__DefaultConnection: ${{ env.CONNECTION_STRING }} + CI: true run: | dotnet-sonarscanner begin /k:"DFE-Digital_academies-api" /o:"dfe-digital" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.coverageReportPaths=CoverageReport/SonarQube.xml dotnet build --no-restore From 895d9c96c1d6630030a74a1c662e5ccf1baaee17 Mon Sep 17 00:00:00 2001 From: Farshad DASHTI Date: Wed, 14 Aug 2024 12:44:47 +0100 Subject: [PATCH 5/7] Added build-args in the docker-build --- .github/workflows/continuous-integration-dotnet.yml | 1 - .github/workflows/docker-build.yml | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration-dotnet.yml b/.github/workflows/continuous-integration-dotnet.yml index 638bbb858..4f8ac8a7f 100644 --- a/.github/workflows/continuous-integration-dotnet.yml +++ b/.github/workflows/continuous-integration-dotnet.yml @@ -90,7 +90,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} ConnectionStrings__DefaultConnection: ${{ env.CONNECTION_STRING }} - CI: true run: | dotnet-sonarscanner begin /k:"DFE-Digital_academies-api" /o:"dfe-digital" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.coverageReportPaths=CoverageReport/SonarQube.xml dotnet build --no-restore diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 16deefd1d..9f2de2d02 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -26,6 +26,8 @@ jobs: - name: Build docker image uses: docker/build-push-action@v6 with: + build-args: | + CI=true file: './${{ matrix.image }}' secrets: github_token=${{ secrets.GITHUB_TOKEN }} push: false From 3eb81d30b16b4bf223fd55d948ea7d99e363627a Mon Sep 17 00:00:00 2001 From: Farshad DASHTI Date: Wed, 14 Aug 2024 12:51:01 +0100 Subject: [PATCH 6/7] Fixed the casing in teh target condition --- PersonsApi/PersonsApi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PersonsApi/PersonsApi.csproj b/PersonsApi/PersonsApi.csproj index c21772e90..3c4389f2b 100644 --- a/PersonsApi/PersonsApi.csproj +++ b/PersonsApi/PersonsApi.csproj @@ -42,7 +42,7 @@ - + Date: Wed, 14 Aug 2024 13:02:21 +0100 Subject: [PATCH 7/7] Modified target condition --- PersonsApi/PersonsApi.csproj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/PersonsApi/PersonsApi.csproj b/PersonsApi/PersonsApi.csproj index 3c4389f2b..79deae204 100644 --- a/PersonsApi/PersonsApi.csproj +++ b/PersonsApi/PersonsApi.csproj @@ -42,7 +42,11 @@ - + + + + +