From c0dbcd28014c6f55ad4a18206f5d2a5ee17c97ec Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Tue, 29 Oct 2024 14:19:32 +0200 Subject: [PATCH 01/34] removed pages.yaml --- .github/workflows/pages.yml | 62 ------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 .github/workflows/pages.yml diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml deleted file mode 100644 index cedae546..00000000 --- a/.github/workflows/pages.yml +++ /dev/null @@ -1,62 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# Sample workflow for building and deploying a Jekyll site to GitHub Pages -name: Deploy Jekyll site to Pages - -on: - push: - branches: ["main"] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow one concurrent deployment -concurrency: - group: "pages" - cancel-in-progress: true - -jobs: - # Build job - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.1' # Not needed with a .ruby-version file - bundler-cache: true # runs 'bundle install' and caches installed gems automatically - cache-version: 0 # Increment this number if you need to re-download cached gems - - name: Setup Pages - id: pages - uses: actions/configure-pages@v2 - - name: Build with Jekyll - # Outputs to the './_site' directory by default - run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" - env: - JEKYLL_ENV: production - - name: Upload artifact - # Automatically uploads an artifact from the './_site' directory by default - uses: actions/upload-pages-artifact@v1 - - # Deployment job - deploy: - environment: - name: github-pages - url: "${{ steps.deployment.outputs.page_url }}" - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v1 From 0bb1f997e522a01e0d5dd465ebe44df72c05d7e7 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Tue, 29 Oct 2024 14:44:57 +0200 Subject: [PATCH 02/34] commit workflow --- .github/workflows/first-workflow.yml | 35 ++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/first-workflow.yml diff --git a/.github/workflows/first-workflow.yml b/.github/workflows/first-workflow.yml new file mode 100644 index 00000000..80a91d1a --- /dev/null +++ b/.github/workflows/first-workflow.yml @@ -0,0 +1,35 @@ +name: Manual Trigger Workflow + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Run a simple script + run: echo "This workflow was manually triggered!" + + job1: + runs-on: ubuntu-latest + + steps: + - name: Step 1 + run: echo "Step 1 complete!" + + - name: Step 2 + run: echo "Step 2 complete!" + + job2: + runs-on: ubuntu-latest + + steps: + - name: Cowsays Action + uses: peter-evans/cowsay@v1 + with: + text: "Ready for prod–ship it!" + color: magenta \ No newline at end of file From 86727d2a6175287dc816914b396acf2cafb0f5db Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Tue, 29 Oct 2024 14:48:51 +0200 Subject: [PATCH 03/34] removed build step, fixed the cowsway --- .github/workflows/first-workflow.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.github/workflows/first-workflow.yml b/.github/workflows/first-workflow.yml index 80a91d1a..e70cb091 100644 --- a/.github/workflows/first-workflow.yml +++ b/.github/workflows/first-workflow.yml @@ -4,16 +4,7 @@ on: workflow_dispatch: jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Run a simple script - run: echo "This workflow was manually triggered!" - + job1: runs-on: ubuntu-latest @@ -29,7 +20,7 @@ jobs: steps: - name: Cowsays Action - uses: peter-evans/cowsay@v1 + uses: peter-evans/cowsay-action@v1 with: text: "Ready for prod–ship it!" color: magenta \ No newline at end of file From ebe5f6faa051115a7c4ebfe9d595803341f32649 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Tue, 29 Oct 2024 14:50:54 +0200 Subject: [PATCH 04/34] fix action --- .github/workflows/first-workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/first-workflow.yml b/.github/workflows/first-workflow.yml index e70cb091..1b1839a8 100644 --- a/.github/workflows/first-workflow.yml +++ b/.github/workflows/first-workflow.yml @@ -20,7 +20,7 @@ jobs: steps: - name: Cowsays Action - uses: peter-evans/cowsay-action@v1 + uses: mscoutermarsh/cowsays-action@master with: text: "Ready for prod–ship it!" color: magenta \ No newline at end of file From c092ae85dcc08236f0ef8b0ac58dae557d1a5c3a Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Tue, 29 Oct 2024 14:54:09 +0200 Subject: [PATCH 05/34] setup dependancy --- .github/workflows/first-workflow.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/first-workflow.yml b/.github/workflows/first-workflow.yml index 1b1839a8..1b20e23f 100644 --- a/.github/workflows/first-workflow.yml +++ b/.github/workflows/first-workflow.yml @@ -16,6 +16,7 @@ jobs: run: echo "Step 2 complete!" job2: + needs: job1 runs-on: ubuntu-latest steps: From f172d5bbac663ed6e03d33e91ad8b3fa91185f59 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Tue, 29 Oct 2024 14:55:11 +0200 Subject: [PATCH 06/34] trigger on issue opened --- .github/workflows/first-workflow.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/first-workflow.yml b/.github/workflows/first-workflow.yml index 1b20e23f..e1675e19 100644 --- a/.github/workflows/first-workflow.yml +++ b/.github/workflows/first-workflow.yml @@ -2,6 +2,8 @@ name: Manual Trigger Workflow on: workflow_dispatch: + issues: + types: [opened] jobs: From 7f50528ce84c6b39168a47948b6f656fc806b517 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Tue, 29 Oct 2024 15:15:13 +0200 Subject: [PATCH 07/34] Refactor message entity to include text length validation. resolves #7 --- .../src/RazorPagesTestSample/Data/Message.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Application/src/RazorPagesTestSample/Data/Message.cs b/src/Application/src/RazorPagesTestSample/Data/Message.cs index ea99cbd6..2a6d93aa 100644 --- a/src/Application/src/RazorPagesTestSample/Data/Message.cs +++ b/src/Application/src/RazorPagesTestSample/Data/Message.cs @@ -1,16 +1,24 @@ -using System.ComponentModel.DataAnnotations; - namespace RazorPagesTestSample.Data { #region snippet1 + /// + /// Represents a message entity with a maximum length of 250 characters. + /// public class Message { + /// + /// Gets or sets the unique identifier for the message. + /// public int Id { get; set; } + /// + /// Gets or sets the text of the message. + /// The text is required and has a maximum length of 250 characters. + /// [Required] [DataType(DataType.Text)] - [StringLength(200, ErrorMessage = "There's a 200 character limit on messages. Please shorten your message.")] + [StringLength(250, ErrorMessage = "There's a 250 character limit on messages. Please shorten your message.")] public string Text { get; set; } } #endregion -} +} \ No newline at end of file From 95d156073c68dc4058b444a2a899d105afc5365b Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Tue, 29 Oct 2024 15:36:51 +0200 Subject: [PATCH 08/34] bicep code --- src/InfrastructureAsCode/main.bicep | 95 ++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 1 deletion(-) diff --git a/src/InfrastructureAsCode/main.bicep b/src/InfrastructureAsCode/main.bicep index 6dc69618..cdd9f13b 100644 --- a/src/InfrastructureAsCode/main.bicep +++ b/src/InfrastructureAsCode/main.bicep @@ -14,4 +14,97 @@ var registrySku = 'Standard' var imageName = 'techexcel/dotnetcoreapp' var startupCommand = '' -// TODO: complete this script +// Create Log Analytics Workspace +resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2021-06-01' = { + name: logAnalyticsName + location: location + properties: { + sku: { + name: 'PerGB2018' + } + retentionInDays: 30 + } +} + +// Create Application Insights +resource appInsights 'Microsoft.Insights/components@2020-02-02' = { + name: appInsightsName + location: location + kind: 'web' + properties: { + Application_Type: 'web' + WorkspaceResourceId: logAnalytics.id + } +} + +// Create Azure Container Registry +resource containerRegistry 'Microsoft.ContainerRegistry/registries@2021-06-01-preview' = { + name: registryName + location: location + sku: { + name: registrySku + } + properties: { + adminUserEnabled: true + } +} + +// Create App Service Plan +resource appServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = { + name: appServicePlanName + location: location + sku: { + name: sku + tier: 'Standard' + } + properties: { + reserved: true // This property is required for Linux + } +} + +// Create Web App +resource webApp 'Microsoft.Web/sites@2021-02-01' = { + name: webAppName + location: location + properties: { + serverFarmId: appServicePlan.id + siteConfig: { + linuxFxVersion: 'DOCKER|${imageName}' + appSettings: [ + { + name: 'DOCKER_REGISTRY_SERVER_URL' + value: 'https://${registryName}.azurecr.io' + } + { + name: 'DOCKER_REGISTRY_SERVER_USERNAME' + value: containerRegistry.properties.adminUserEnabled ? listCredentials(containerRegistry.id, '2021-06-01-preview').username : '' + } + { + name: 'DOCKER_REGISTRY_SERVER_PASSWORD' + value: containerRegistry.properties.adminUserEnabled ? listCredentials(containerRegistry.id, '2021-06-01-preview').passwords[0].value : '' + } + { + name: 'APPINSIGHTS_INSTRUMENTATIONKEY' + value: appInsights.properties.InstrumentationKey + } + { + name: 'APPLICATIONINSIGHTS_CONNECTION_STRING' + value: appInsights.properties.ConnectionString + } + { + name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE' + value: 'false' + } + { + name: 'WEBSITES_PORT' + value: '80' // Default port for your application + } + ] + } + } +} + +// Outputs +output appServiceName string = webApp.name +output appServiceUrl string = 'https://${webAppName}.azurewebsites.net' +output containerRegistryName string = containerRegistry.name From 7b9b6d6f8dd99d94f7b1cc90e5a7f5cbe0fb9ae4 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Tue, 29 Oct 2024 16:01:48 +0200 Subject: [PATCH 09/34] deploy yaml --- .github/workflows/deploy.yml | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..0134f87f --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,39 @@ +name: Deploy Azure Resources + +on: + workflow_dispatch: + inputs: + environment: + description: 'Environment to deploy to' + required: true + default: 'dev' + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Set up Azure CLI + uses: azure/login@v2 + with: + enable-AzPSSession: true + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + federated-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Deploy Bicep file + run: | + az deployment group create \ + --resource-group ${{ secrets.AZURE_RG }} \ + --template-file src/Application/main.bicep \ + --parameters environment=${{ github.event.inputs.environment }} + + - name: Output results + run: | + echo "App Service Name: $(az deployment group show --resource-group ${{ secrets.AZURE_RG }} --name --query properties.outputs.appServiceName.value -o tsv)" + echo "App Service URL: $(az deployment group show --resource-group ${{ secrets.AZURE_RG }} --name --query properties.outputs.appServiceUrl.value -o tsv)" + echo "Container Registry Name: $(az deployment group show --resource-group ${{ secrets.AZURE_RG }} --name --query properties.outputs.containerRegistryName.value -o tsv)" \ No newline at end of file From 6ec4729365370587ded6f49e8506205aa2969297 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Tue, 29 Oct 2024 16:03:49 +0200 Subject: [PATCH 10/34] Refactor deploy.yml to remove unused federated token --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0134f87f..b6659894 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,7 +23,7 @@ jobs: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - federated-token: ${{ secrets.GITHUB_TOKEN }} + - name: Deploy Bicep file run: | From bed8d16f7ed3c259cfe7a46ed94dd4a53b7370cd Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Tue, 29 Oct 2024 16:05:45 +0200 Subject: [PATCH 11/34] Refactor deploy.yml to update permissions --- .github/workflows/deploy.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b6659894..f5a80a93 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,7 +7,9 @@ on: description: 'Environment to deploy to' required: true default: 'dev' - +permissions: + id-token: write + contents: read jobs: deploy: runs-on: ubuntu-latest From 43520d458f8edff141d31ffc91fe73f0445c9fcf Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Tue, 29 Oct 2024 16:09:04 +0200 Subject: [PATCH 12/34] Refactor deploy.yml to update template file path --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f5a80a93..88109eff 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -31,7 +31,7 @@ jobs: run: | az deployment group create \ --resource-group ${{ secrets.AZURE_RG }} \ - --template-file src/Application/main.bicep \ + --template-file src/InfrastructureAsCode/main.bicep \ --parameters environment=${{ github.event.inputs.environment }} - name: Output results From a2f589dd88c03535e776a14c51b5b2d44110103b Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Tue, 29 Oct 2024 16:16:00 +0200 Subject: [PATCH 13/34] Refactor deploy.yml to update template file path, permissions, and remove unused federated token --- .github/workflows/deploy.yml | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 88109eff..6468245a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -7,9 +7,7 @@ on: description: 'Environment to deploy to' required: true default: 'dev' -permissions: - id-token: write - contents: read + jobs: deploy: runs-on: ubuntu-latest @@ -21,21 +19,25 @@ jobs: - name: Set up Azure CLI uses: azure/login@v2 with: - enable-AzPSSession: true client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - + enable-AzPSSession: true + + - name: Set deployment name + id: set-deployment-name + run: echo "##[set-output name=deployment_name;]deployment-$(date +%s)" - name: Deploy Bicep file run: | az deployment group create \ --resource-group ${{ secrets.AZURE_RG }} \ + --name ${{ steps.set-deployment-name.outputs.deployment_name }} \ --template-file src/InfrastructureAsCode/main.bicep \ --parameters environment=${{ github.event.inputs.environment }} - name: Output results run: | - echo "App Service Name: $(az deployment group show --resource-group ${{ secrets.AZURE_RG }} --name --query properties.outputs.appServiceName.value -o tsv)" - echo "App Service URL: $(az deployment group show --resource-group ${{ secrets.AZURE_RG }} --name --query properties.outputs.appServiceUrl.value -o tsv)" - echo "Container Registry Name: $(az deployment group show --resource-group ${{ secrets.AZURE_RG }} --name --query properties.outputs.containerRegistryName.value -o tsv)" \ No newline at end of file + echo "App Service Name: $(az deployment group show --resource-group ${{ secrets.AZURE_RG }} --name ${{ steps.set-deployment-name.outputs.deployment_name }} --query properties.outputs.appServiceName.value -o tsv)" + echo "App Service URL: $(az deployment group show --resource-group ${{ secrets.AZURE_RG }} --name ${{ steps.set-deployment-name.outputs.deployment_name }} --query properties.outputs.appServiceUrl.value -o tsv)" + echo "Container Registry Name: $(az deployment group show --resource-group ${{ secrets.AZURE_RG }} --name ${{ steps.set-deployment-name.outputs.deployment_name }} --query properties.outputs.containerRegistryName.value -o tsv)" \ No newline at end of file From aa4e0df8cbc846866daa030a5c606b1a2ba47b7b Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Tue, 29 Oct 2024 16:17:56 +0200 Subject: [PATCH 14/34] Refactor deploy.yml to update template file path, permissions, and remove unused federated token --- .github/workflows/deploy.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6468245a..b6222667 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,6 +8,10 @@ on: required: true default: 'dev' +permissions: + id-token: write + contents: read + jobs: deploy: runs-on: ubuntu-latest From 1a5f0086fbc1b8c4dc9e33370b307c023092e4f2 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee <37135205+ahmedsza@users.noreply.github.com> Date: Wed, 30 Oct 2024 09:19:07 +0200 Subject: [PATCH 15/34] Create dotnet.yml --- .github/workflows/dotnet.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/dotnet.yml diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml new file mode 100644 index 00000000..217f7cbe --- /dev/null +++ b/.github/workflows/dotnet.yml @@ -0,0 +1,28 @@ +# This workflow will build a .NET project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net + +name: .NET + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Setup .NET + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.0.x + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + - name: Test + run: dotnet test --no-build --verbosity normal From 76eea4d0497c8da9dfd2974f765c3ba8f3e06ece Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 09:22:15 +0200 Subject: [PATCH 16/34] Refactor dotnet.yml to include specific paths for push and pull_request events --- .github/workflows/dotnet.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 217f7cbe..3561ccf0 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -6,8 +6,12 @@ name: .NET on: push: branches: [ "main" ] + paths: + - 'src/Application/**' pull_request: branches: [ "main" ] + paths: + - 'src/Application/**' jobs: build: From 0ed3c39420f51513ef73b97a1597e43ceb4222d4 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 09:25:26 +0200 Subject: [PATCH 17/34] Refactor dotnet.yml to include specific paths for push and pull_request events --- .github/workflows/dotnet.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 3561ccf0..a6e1b443 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -25,8 +25,8 @@ jobs: with: dotnet-version: 8.0.x - name: Restore dependencies - run: dotnet restore + run: dotnet restore src/Application/Application.csproj - name: Build - run: dotnet build --no-restore + run: dotnet build src/Application/Application.csproj --no-restore - name: Test - run: dotnet test --no-build --verbosity normal + run: dotnet test src/Application.Tests/Application.Tests.csproj --no-build --verbosity normal \ No newline at end of file From 45e431038ce4db14eb7de7c330caa63c45179a4c Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 09:28:04 +0200 Subject: [PATCH 18/34] Refactor dotnet.yml to include specific paths for push and pull_request events --- .github/workflows/dotnet.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index a6e1b443..19ec1f5f 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -12,6 +12,8 @@ on: branches: [ "main" ] paths: - 'src/Application/**' + workflow_dispatch: + jobs: build: From 704e8c3cb9739122a3d32406c8c8073dcfbe52fc Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 10:17:38 +0200 Subject: [PATCH 19/34] Refactor dotnet.yml to include specific paths for push and pull_request events --- .github/workflows/dotnet.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 19ec1f5f..1b1d783b 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -27,8 +27,8 @@ jobs: with: dotnet-version: 8.0.x - name: Restore dependencies - run: dotnet restore src/Application/Application.csproj + run: dotnet restore src/Application/src/RazorPagesTestSample.csproj - name: Build - run: dotnet build src/Application/Application.csproj --no-restore + run: dotnet build src/Application/src/RazorPagesTestSample.csproj --no-restore - name: Test - run: dotnet test src/Application.Tests/Application.Tests.csproj --no-build --verbosity normal \ No newline at end of file + run: dotnet test src/Application/tests/RazorPagesTestSample.Tests.csproj --no-build --verbosity normal \ No newline at end of file From 96949df2ef62339f374e4b3b53e70680cc5c03a7 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 10:22:50 +0200 Subject: [PATCH 20/34] Refactor dotnet.yml to include specific paths for push and pull_request events --- .github/workflows/dotnet.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 1b1d783b..c9a24212 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -27,8 +27,8 @@ jobs: with: dotnet-version: 8.0.x - name: Restore dependencies - run: dotnet restore src/Application/src/RazorPagesTestSample.csproj + run: dotnet restore src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj - name: Build - run: dotnet build src/Application/src/RazorPagesTestSample.csproj --no-restore + run: dotnet build src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj --no-restore - name: Test - run: dotnet test src/Application/tests/RazorPagesTestSample.Tests.csproj --no-build --verbosity normal \ No newline at end of file + run: dotnet test src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj --no-build --verbosity normal \ No newline at end of file From dfee3735b152d94baab2bc1d6bd04c44f027c8e2 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 10:30:49 +0200 Subject: [PATCH 21/34] Refactor dotnet.yml to include specific paths for push and pull_request events --- src/Application/src/RazorPagesTestSample/Data/Message.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Application/src/RazorPagesTestSample/Data/Message.cs b/src/Application/src/RazorPagesTestSample/Data/Message.cs index 2a6d93aa..979252d8 100644 --- a/src/Application/src/RazorPagesTestSample/Data/Message.cs +++ b/src/Application/src/RazorPagesTestSample/Data/Message.cs @@ -1,3 +1,5 @@ +using System.ComponentModel.DataAnnotations; + namespace RazorPagesTestSample.Data { #region snippet1 From 4be1e38b5aa8d52eaa7eb3a822d2f9300cc4cb03 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 11:18:37 +0200 Subject: [PATCH 22/34] Refactor dotnet.yml to include specific paths for push and pull_request events and update Dockerfile for .NET 8 --- .github/workflows/dotnet.yml | 22 ++++++++++++++++++- .../src/RazorPagesTestSample/Dockerfile | 22 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/Application/src/RazorPagesTestSample/Dockerfile diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index c9a24212..0284878e 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -15,6 +15,12 @@ on: workflow_dispatch: +env: + registryName: "q3zpru2gmy754mpnpreg.azurecr.io" # Replace registryName with the name of your registry + repositoryName: "techexcel/dotnetcoreapp" + dockerFolderPath: "src/Application/src/RazorPagesTestSample" + tag: ${{ github.run_number }} + jobs: build: @@ -31,4 +37,18 @@ jobs: - name: Build run: dotnet build src/Application/src/RazorPagesTestSample/RazorPagesTestSample.csproj --no-restore - name: Test - run: dotnet test src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj --no-build --verbosity normal \ No newline at end of file + run: dotnet test src/Application/tests/RazorPagesTestSample.Tests/RazorPagesTestSample.Tests.csproj --no-build --verbosity normal + + buildacr: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Login to Azure Container Registry + run: echo "${{ secrets.ACR_PASSWORD }}" | docker login ${{ env.registryName }} -u ${{ secrets.ACR_USERNAME }} --password-stdin + + - name: Build and push Docker image + run: | + docker build ${{ env.dockerFolderPath }} -t ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} + docker push ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} \ No newline at end of file diff --git a/src/Application/src/RazorPagesTestSample/Dockerfile b/src/Application/src/RazorPagesTestSample/Dockerfile new file mode 100644 index 00000000..c4bd664c --- /dev/null +++ b/src/Application/src/RazorPagesTestSample/Dockerfile @@ -0,0 +1,22 @@ +# Update the base and SDK images to .NET 8 +FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base +WORKDIR /app +EXPOSE 8080 +EXPOSE 8081 + + +FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build +WORKDIR /src +COPY ["RazorPagesTestSample.csproj", "./"] +RUN dotnet restore "./RazorPagesTestSample.csproj" +COPY . . +WORKDIR "/src/." +RUN dotnet build "RazorPagesTestSample.csproj" -c Release -o /app/build + +FROM build AS publish +RUN dotnet publish "RazorPagesTestSample.csproj" -c Release -o /app/publish + +FROM base AS final +WORKDIR /app +COPY --from=publish /app/publish . +ENTRYPOINT ["dotnet", "RazorPagesTestSample.dll"] \ No newline at end of file From e21d4377d9aff693f0345b19c59eaa13778fb095 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 11:26:09 +0200 Subject: [PATCH 23/34] Refactor dotnet.yml to include specific paths for push and pull_request events and add deployment to Azure Web App --- .github/workflows/dotnet.yml | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 0284878e..c6f85b4f 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -51,4 +51,32 @@ jobs: - name: Build and push Docker image run: | docker build ${{ env.dockerFolderPath }} -t ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} - docker push ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} \ No newline at end of file + docker push ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} + + deploytodev: + runs-on: ubuntu-latest + needs: buildacr + environment: dev + + steps: + - uses: actions/checkout@v4 + + - name: Azure Login + uses: azure/login@v1 + with: + client-id: ${{ secrets.AZURE_CLIENT_ID }} + tenant-id: ${{ secrets.AZURE_TENANT_ID }} + subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} + enable-AzPSSession: true + + + + - name: Deploy to Azure Web App + run: | + az webapp config container set \ + --name q3zpru2gmy754-dev \ + --resource-group ${{ secrets.AZURE_RG }} \ + --docker-custom-image-name ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} \ + --docker-registry-server-url https://${{ env.registryName }} \ + --docker-registry-server-user ${{ secrets.ACR_USERNAME }} \ + --docker-registry-server-password ${{ secrets.ACR_PASSWORD }} \ No newline at end of file From 78671f49f90262697c9b6f3f7d8417b89dc72ddd Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 11:32:01 +0200 Subject: [PATCH 24/34] Refactor dotnet.yml to include specific paths for push and pull_request events and update permissions for id-token and contents --- .github/workflows/dotnet.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index c6f85b4f..42697f30 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -15,6 +15,10 @@ on: workflow_dispatch: +permissions: + id-token: write + contents: read + env: registryName: "q3zpru2gmy754mpnpreg.azurecr.io" # Replace registryName with the name of your registry repositoryName: "techexcel/dotnetcoreapp" From ac714f269dc30088d2d9307bb69cb9757cfce041 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 11:35:21 +0200 Subject: [PATCH 25/34] Refactor dotnet.yml to update Azure Login action to use version 2 --- .github/workflows/dotnet.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 42697f30..1c8e1a7b 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -66,7 +66,7 @@ jobs: - uses: actions/checkout@v4 - name: Azure Login - uses: azure/login@v1 + uses: azure/login@v2 with: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} From a05aa3029f88cd835dfa0404ebf1489d44d481a1 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 12:00:08 +0200 Subject: [PATCH 26/34] Refactor dotnet.yml to update Azure Login action to use version 2 and use Azure credentials for authentication --- .github/workflows/dotnet.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 1c8e1a7b..3638fb93 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -68,11 +68,7 @@ jobs: - name: Azure Login uses: azure/login@v2 with: - client-id: ${{ secrets.AZURE_CLIENT_ID }} - tenant-id: ${{ secrets.AZURE_TENANT_ID }} - subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - enable-AzPSSession: true - + creds: ${{ secrets.AZURE_CREDENTIALS }} - name: Deploy to Azure Web App From c32da3165e755cdcb18244551a5caa1dcdfd2f3c Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 12:21:32 +0200 Subject: [PATCH 27/34] Refactor dotnet.yml to update Azure Login action to use version 2 and use Azure credentials for authentication, include specific paths for push and pull_request events, and update Dockerfile for .NET 8 --- .github/workflows/dotnet.yml | 72 +++++++++++++++++++ .../src/RazorPagesTestSample/Dockerfile | 4 +- 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 3638fb93..de606083 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -79,4 +79,76 @@ jobs: --docker-custom-image-name ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} \ --docker-registry-server-url https://${{ env.registryName }} \ --docker-registry-server-user ${{ secrets.ACR_USERNAME }} \ + --docker-registry-server-password ${{ secrets.ACR_PASSWORD }} + + deploytodev: + runs-on: ubuntu-latest + needs: buildacr + environment: dev + + steps: + - uses: actions/checkout@v4 + + - name: Azure Login + uses: azure/login@v2 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + + - name: Deploy to Azure Web App + run: | + az webapp config container set \ + --name q3zpru2gmy754-dev \ + --resource-group ${{ secrets.AZURE_RG }} \ + --docker-custom-image-name ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} \ + --docker-registry-server-url https://${{ env.registryName }} \ + --docker-registry-server-user ${{ secrets.ACR_USERNAME }} \ + --docker-registry-server-password ${{ secrets.ACR_PASSWORD }} + + deploytotest: + runs-on: ubuntu-latest + needs: deploytodev + environment: test + + steps: + - uses: actions/checkout@v4 + + - name: Azure Login + uses: azure/login@v2 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + + - name: Deploy to Azure Web App + run: | + az webapp config container set \ + --name q3zpru2gmy754-test \ + --resource-group ${{ secrets.AZURE_RG }} \ + --docker-custom-image-name ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} \ + --docker-registry-server-url https://${{ env.registryName }} \ + --docker-registry-server-user ${{ secrets.ACR_USERNAME }} \ + --docker-registry-server-password ${{ secrets.ACR_PASSWORD }} + + deploytoprod: + runs-on: ubuntu-latest + needs: deploytotest + environment: prod + + steps: + - uses: actions/checkout@v4 + + - name: Azure Login + uses: azure/login@v2 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + + - name: Deploy to Azure Web App + run: | + az webapp config container set \ + --name q3zpru2gmy754-prod \ + --resource-group ${{ secrets.AZURE_RG }} \ + --docker-custom-image-name ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} \ + --docker-registry-server-url https://${{ env.registryName }} \ + --docker-registry-server-user ${{ secrets.ACR_USERNAME }} \ --docker-registry-server-password ${{ secrets.ACR_PASSWORD }} \ No newline at end of file diff --git a/src/Application/src/RazorPagesTestSample/Dockerfile b/src/Application/src/RazorPagesTestSample/Dockerfile index c4bd664c..30b11996 100644 --- a/src/Application/src/RazorPagesTestSample/Dockerfile +++ b/src/Application/src/RazorPagesTestSample/Dockerfile @@ -1,8 +1,8 @@ # Update the base and SDK images to .NET 8 FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base WORKDIR /app -EXPOSE 8080 -EXPOSE 8081 +EXPOSE 80 +ENV ASPNETCORE_URLS=http://+:80 FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build From 85723ad772801cff289c82dcb50dcc826a850ba6 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 12:25:17 +0200 Subject: [PATCH 28/34] Refactor dotnet.yml to remove deployment to Azure Web App and update Azure Login action to use version 2 and use Azure credentials for authentication, include specific paths for push and pull_request events, and update Dockerfile for .NET 8 --- .github/workflows/dotnet.yml | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index de606083..a15c9126 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -81,30 +81,7 @@ jobs: --docker-registry-server-user ${{ secrets.ACR_USERNAME }} \ --docker-registry-server-password ${{ secrets.ACR_PASSWORD }} - deploytodev: - runs-on: ubuntu-latest - needs: buildacr - environment: dev - - steps: - - uses: actions/checkout@v4 - - - name: Azure Login - uses: azure/login@v2 - with: - creds: ${{ secrets.AZURE_CREDENTIALS }} - - - - name: Deploy to Azure Web App - run: | - az webapp config container set \ - --name q3zpru2gmy754-dev \ - --resource-group ${{ secrets.AZURE_RG }} \ - --docker-custom-image-name ${{ env.registryName }}/${{ env.repositoryName }}:${{ env.tag }} \ - --docker-registry-server-url https://${{ env.registryName }} \ - --docker-registry-server-user ${{ secrets.ACR_USERNAME }} \ - --docker-registry-server-password ${{ secrets.ACR_PASSWORD }} - + deploytotest: runs-on: ubuntu-latest needs: deploytodev From de6cb96737ea1c7566fe9ee963cfb4c5252aab22 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 12:28:30 +0200 Subject: [PATCH 29/34] Refactor dotnet.yml to include dependency on 'buildacr' job --- .github/workflows/dotnet.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index a15c9126..a42a3929 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -29,7 +29,6 @@ jobs: build: runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 - name: Setup .NET @@ -45,7 +44,7 @@ jobs: buildacr: runs-on: ubuntu-latest - + needs: build steps: - uses: actions/checkout@v4 From 20ced96ac19ccb6990c45ea96a8098933ec66436 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 12:47:19 +0200 Subject: [PATCH 30/34] Add CODEOWNERS file with default code owner --- src/Application/CODEOWNERS | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/Application/CODEOWNERS diff --git a/src/Application/CODEOWNERS b/src/Application/CODEOWNERS new file mode 100644 index 00000000..a89a9d99 --- /dev/null +++ b/src/Application/CODEOWNERS @@ -0,0 +1,5 @@ +# This is a comment +# Each line is a file pattern followed by one or more owners + +# Specify a default code owner for the entire repository +* @ahmedsza From 3a2d59cf11c43acd978d5c8634feffa278b86a21 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 12:48:09 +0200 Subject: [PATCH 31/34] Update title in Index.cshtml to include PR for Munson's Pickles and Preserves Team Messaging System --- src/Application/src/RazorPagesTestSample/Pages/Index.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Application/src/RazorPagesTestSample/Pages/Index.cshtml b/src/Application/src/RazorPagesTestSample/Pages/Index.cshtml index f7645733..ba4d74c0 100644 --- a/src/Application/src/RazorPagesTestSample/Pages/Index.cshtml +++ b/src/Application/src/RazorPagesTestSample/Pages/Index.cshtml @@ -1,7 +1,7 @@ @page @model IndexModel @{ - ViewData["Title"] = "Munson's Pickles and Preserves Team Messaging System"; + ViewData["Title"] = "Munson's Pickles and Preserves Team Messaging System with PR"; }

@ViewData["Title"]

From a72f17dff4166ef52e2f3b903cd182770f1c132e Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 13:16:16 +0200 Subject: [PATCH 32/34] Add security policy to SECURITY.md --- SECURITY.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/SECURITY.md b/SECURITY.md index b3c89efc..04c20a6f 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -39,3 +39,33 @@ We prefer all communications to be in English. Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd). +# Security Policy + +## Supported Versions + +We release patches for security vulnerabilities. Which versions are eligible for receiving such patches depends on the CVSS v3.0 Rating: + +| Version | Supported | +| ------- | ------------------ | +| 1.0.x | :white_check_mark: | +| < 1.0 | :x: | + +## Reporting a Vulnerability + +If you discover a security vulnerability, please follow these steps: + +1. **Do not open an issue**: This ensures that the vulnerability is not publicly disclosed before a fix is available. +2. **Send an email to [security@example.com](mailto:security@example.com)**: Provide as much detail as possible about the vulnerability and how it can be exploited. +3. **Expect a response within 48 hours**: We will acknowledge the receipt of your report and provide a timeline for a fix. + +## Security Updates + +We will notify users about security updates through: + +- GitHub Releases +- Email notifications (if subscribed) + +## Security Resources + +- [OWASP Top Ten](https://owasp.org/www-project-top-ten/) +- [CWE/SANS Top 25](https://cwe.mitre.org/top25/archive/2020/2020_cwe_top25.html) \ No newline at end of file From 7369364398b61b5fec3b78df8b0d10eac827deae Mon Sep 17 00:00:00 2001 From: Ahmed Salijee <37135205+ahmedsza@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:55:46 +0200 Subject: [PATCH 33/34] Create codeql.yml --- .github/workflows/codeql.yml | 94 ++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 00000000..48f938d2 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,94 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL Advanced" + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + schedule: + - cron: '38 1 * * 5' + +jobs: + analyze: + name: Analyze (${{ matrix.language }}) + # Runner size impacts CodeQL analysis time. To learn more, please see: + # - https://gh.io/recommended-hardware-resources-for-running-codeql + # - https://gh.io/supported-runners-and-hardware-resources + # - https://gh.io/using-larger-runners (GitHub.com only) + # Consider using larger runners or machines with greater resources for possible analysis time improvements. + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + permissions: + # required for all workflows + security-events: write + + # required to fetch internal or private CodeQL packs + packages: read + + # only required for workflows in private repositories + actions: read + contents: read + + strategy: + fail-fast: false + matrix: + include: + - language: csharp + build-mode: none + - language: ruby + build-mode: none + # CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' + # Use `c-cpp` to analyze code written in C, C++ or both + # Use 'java-kotlin' to analyze code written in Java, Kotlin or both + # Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both + # To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, + # see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. + # If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how + # your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + build-mode: ${{ matrix.build-mode }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + # If the analyze step fails for one of the languages you are analyzing with + # "We were unable to automatically build your code", modify the matrix above + # to set the build mode to "manual" for that language. Then modify this step + # to build your code. + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + - if: matrix.build-mode == 'manual' + shell: bash + run: | + echo 'If you are using a "manual" build mode for one or more of the' \ + 'languages you are analyzing, replace this with the commands to build' \ + 'your code, for example:' + echo ' make bootstrap' + echo ' make release' + exit 1 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" From 58b46ac47a866dd955e615a377e5f3e34d95c4d6 Mon Sep 17 00:00:00 2001 From: Ahmed Salijee Date: Wed, 30 Oct 2024 15:16:16 +0200 Subject: [PATCH 34/34] Refactor performance loop in Index.cshtml.cs --- .../src/RazorPagesTestSample/Pages/Index.cshtml.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Application/src/RazorPagesTestSample/Pages/Index.cshtml.cs b/src/Application/src/RazorPagesTestSample/Pages/Index.cshtml.cs index 2e6d94bb..04ba785e 100644 --- a/src/Application/src/RazorPagesTestSample/Pages/Index.cshtml.cs +++ b/src/Application/src/RazorPagesTestSample/Pages/Index.cshtml.cs @@ -74,9 +74,9 @@ public async Task OnPostAnalyzeMessagesAsync() { // Speed loop. Lower this number once every quarter so we // get our performance improvement quarterly bonus. - for (int i = 0; i < 3000; i++) { - Thread.Sleep(1); - } + // for (int i = 0; i < 3000; i++) { + // Thread.Sleep(1); + // } var wordCount = 0;