Bump the tests group across 1 directory with 12 updates #2166
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: 'CI/CD' | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| merge_group: | |
| workflow_dispatch: | |
| env: | |
| dotNetVersion: net9.0 | |
| dotNetConfiguration: Release | |
| runtimeTarget: win-x64 | |
| permissions: | |
| id-token: write | |
| jobs: | |
| build: | |
| name: Build web service | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install .NET SDK | |
| uses: actions/setup-dotnet@v4.3.0 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Publish web projects | |
| run: | | |
| dotnet nuget add source "https://nuget.pkg.github.com/SamSmithNZ-dotcom/index.json" --name "githubfeed" --username "samsmithnz@gmail.com" --password "${{ secrets.PackagesReadPAT_Token }}" --store-password-in-clear-text | |
| dotnet restore src/SamSmithNZ.Service/SamSmithNZ.Service.csproj | |
| dotnet publish src/SamSmithNZ.Service/SamSmithNZ.Service.csproj --configuration ${{ env.dotNetConfiguration }} --output ${{ github.workspace }}/service #--runtime ${{env.runtimeTarget}} | |
| #dotnet publish src/SamSmithNZ.Web/SamSmithNZ.Web.csproj --configuration ${{ env.dotNetConfiguration }} --output ${{ github.workspace }}/web -p:Version='${{ steps.gitversion.outputs.SemVer }}' #--runtime ${{env.runtimeTarget}} | |
| # - name: Build utility dotnet projects | |
| # run: | | |
| # dotnet build src/SamSmithNZ.WorldCupGoals.WPF/SamSmithNZ.WorldCupGoals.WPF.csproj --configuration Release --output ${{ github.workspace }} --runtime win-x64 | |
| # dotnet build src/SamSmithNZ.FFLSetlistScraper.WinForms/SamSmithNZ.FFLSetlistScraper.WinForms.csproj --configuration Release --output ${{ github.workspace }} --runtime win-x64 | |
| #Publish all artifacts | |
| - name: Publish webapi Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: service | |
| path: ${{ github.workspace }}/service | |
| buildWebsite: | |
| name: Build website | |
| runs-on: windows-latest | |
| outputs: # https://stackoverflow.com/questions/59175332/using-output-from-a-previous-job-in-a-new-one-in-a-github-action | |
| Version: ${{ steps.gitversion.outputs.SemVer }} | |
| CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 #fetch-depth is needed for GitVersion | |
| #Install and calculate the new version with GitVersion | |
| - name: Install GitVersion | |
| uses: gittools/actions/gitversion/setup@v3.1.11 | |
| with: | |
| versionSpec: 5.x | |
| - name: Determine Version | |
| uses: gittools/actions/gitversion/execute@v3.1.11 | |
| id: gitversion # step id used as reference for output values | |
| - name: Display GitVersion outputs | |
| run: | | |
| echo "Version: ${{ steps.gitversion.outputs.SemVer }}" | |
| echo "CommitsSinceVersionSource: ${{ steps.gitversion.outputs.CommitsSinceVersionSource }}" | |
| - name: Install .NET SDK | |
| uses: actions/setup-dotnet@v4.3.0 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Publish web projects | |
| run: | | |
| dotnet nuget add source "https://nuget.pkg.github.com/SamSmithNZ-dotcom/index.json" --name "githubfeed" --username "samsmithnz@gmail.com" --password "${{ secrets.PackagesReadPAT_Token }}" --store-password-in-clear-text | |
| dotnet publish src/SamSmithNZ.Web/SamSmithNZ.Web.csproj --configuration ${{ env.dotNetConfiguration }} --output ${{ github.workspace }}/web -p:Version=${{ steps.gitversion.outputs.SemVer }} | |
| - name: Publish web Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: web | |
| path: ${{ github.workspace }}/web | |
| buildFunctionalTests: | |
| name: Build functional tests | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install .NET SDK | |
| uses: actions/setup-dotnet@v4.3.0 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Publish functional tests project | |
| run: | | |
| dotnet nuget add source "https://nuget.pkg.github.com/SamSmithNZ-dotcom/index.json" --name "githubfeed" --username "samsmithnz@gmail.com" --password "${{ secrets.PackagesReadPAT_Token }}" --store-password-in-clear-text | |
| dotnet publish src/SamSmithNZ.FunctionalTests/SamSmithNZ.FunctionalTests.csproj --configuration Release --output ${{ github.workspace }}/FunctionalTests --runtime win-x64 --no-self-contained | |
| - name: 'Copy Selenium Files to artifacts folder' | |
| run: Copy 'src/SamSmithNZ.FunctionalTests/bin/Release/net9.0/*chromedriver.exe*' '${{ github.workspace }}/FunctionalTests/SamSmithNZ.FunctionalTests' | |
| - name: Publish web Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: functionalTests | |
| path: ${{ github.workspace }}/FunctionalTests | |
| buildDatabase: | |
| name: Build database | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download the build artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: Add msbuild to PATH | |
| uses: microsoft/setup-msbuild@v2.0.0 | |
| - name: Build database project | |
| run: msbuild 'src/SamSmithNZ.Database/SamSmithNZ.Database.sqlproj' /p:configuration='Release' /p:platform='Any CPU' | |
| - name: check directory | |
| run: dir "${{ github.workspace }}\src\SamSmithNZ.Database\bin\Output" | |
| - name: 'Copy database files to artifacts folder' | |
| run: | | |
| mkdir "${{ github.workspace }}\Database" | |
| Copy-Item -Path "${{ github.workspace }}\src\SamSmithNZ.Database\bin\Output\SamSmithNZ.Database.dacpac" -Destination "${{ github.workspace }}\Database" | |
| - name: check directory | |
| run: dir "${{ github.workspace }}/Database" | |
| - name: Publish database objects | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: database | |
| path: ${{ github.workspace }}/Database | |
| testDotNet: | |
| name: Run automated tests | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
| - name: Install .NET SDK | |
| uses: actions/setup-dotnet@v4.3.0 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Variable Substitution appsettings file for tests | |
| uses: microsoft/variable-substitution@v1 | |
| with: | |
| files: 'src/SamSmithNZ.Tests/appsettings.json' | |
| env: | |
| ConnectionStrings.DefaultConnectionString: "${{ secrets.SQL_CONNECTIONSTRING }}" | |
| CacheConnection: "${{ secrets.REDIS_CONNECTIONSTRING }}" | |
| - name: Test projects | |
| run: | | |
| dotnet nuget add source "https://nuget.pkg.github.com/SamSmithNZ-dotcom/index.json" --name "githubfeed" --username "samsmithnz@gmail.com" --password "${{ secrets.PackagesReadPAT_Token }}" --store-password-in-clear-text | |
| dotnet restore src/SamSmithNZ.Tests/SamSmithNZ.Tests.csproj | |
| dotnet test src/SamSmithNZ.Tests/SamSmithNZ.Tests.csproj --configuration debug --nologo -e:CollectCoverage=true -e:CoverletOutput=TestResults/ -e:CoverletOutputFormat=lcov #-l:"trx;LogFileName=${{ github.workspace }}/TestOutput.xml" | |
| - name: Publish coverage report to coveralls.io | |
| uses: coverallsapp/github-action@master | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| path-to-lcov: src/SamSmithNZ.Tests/TestResults/coverage.info | |
| - uses: samsmithnz/DotNetTestResults@0.1.12 | |
| if: false | |
| with: | |
| fileName: ${{ github.workspace }}/TestOutput.xml | |
| sonarCloud: | |
| name: Run SonarCloud analysis | |
| runs-on: windows-latest | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: 17 | |
| distribution: 'zulu' # Alternative distribution options are available. | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
| - name: Install .NET SDK | |
| uses: actions/setup-dotnet@v4.3.0 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Cache SonarCloud packages | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/sonar/cache | |
| key: ${{ runner.os }}-sonar | |
| restore-keys: ${{ runner.os }}-sonar | |
| - name: Cache SonarCloud scanner | |
| id: cache-sonar-scanner | |
| uses: actions/cache@v4 | |
| with: | |
| path: ./.sonar/scanner | |
| key: ${{ runner.os }}-sonar-scanner | |
| restore-keys: ${{ runner.os }}-sonar-scanner | |
| - name: Install SonarCloud scanner | |
| if: steps.cache-sonar-scanner.outputs.cache-hit != 'true' | |
| shell: pwsh | |
| run: | | |
| New-Item -Path ./.sonar/scanner -ItemType Directory | |
| dotnet tool update dotnet-sonarscanner --tool-path ./.sonar/scanner | |
| - name: Build and analyze | |
| shell: pwsh | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any | |
| run: | | |
| ./.sonar/scanner/dotnet-sonarscanner begin /k:"samsmithnz_SamSmithNZ.com" /o:"samsmithnz-github" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" | |
| dotnet nuget add source "https://nuget.pkg.github.com/SamSmithNZ-dotcom/index.json" --name "githubfeed" --username "samsmithnz@gmail.com" --password "${{ secrets.PackagesReadPAT_Token }}" | |
| dotnet restore src/SamSmithNZ.Service/SamSmithNZ.Service.csproj | |
| dotnet build src/SamSmithNZ.Service/SamSmithNZ.Service.csproj | |
| dotnet build src/SamSmithNZ.Web/SamSmithNZ.Web.csproj | |
| dotnet build src/SamSmithNZ.Tests/SamSmithNZ.Tests.csproj | |
| dotnet build src/SamSmithNZ.FunctionalTests/SamSmithNZ.FunctionalTests.csproj | |
| dotnet build src/SamSmithNZ.WorldCupGoals.WPF/SamSmithNZ.WorldCupGoals.WPF.csproj | |
| dotnet build src/SamSmithNZ.FFLSetlistScraper.WinForms/SamSmithNZ.FFLSetlistScraper.WinForms.csproj | |
| dotnet build src/SamSmithNZ.ExportGuitarTab.Console/SamSmithNZ.ExportGuitarTab.Console.csproj | |
| ./.sonar/scanner/dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" | |
| deployWebAppsToSlots: | |
| name: Deploy web apps | |
| runs-on: ubuntu-latest | |
| permissions: write-all | |
| needs: | |
| - build | |
| - buildWebsite | |
| - buildFunctionalTests | |
| - buildDatabase | |
| - testDotNet | |
| #- sonarCloud | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Azure Login | |
| uses: azure/login@v2 | |
| with: | |
| creds: ${{ secrets.ORG_AZURE_SP }} | |
| - name: Download the build artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: deploy website infrastructure as code | |
| uses: azure/arm-deploy@v2 | |
| with: | |
| resourceGroupName: SamSmithNZ.com | |
| template: src/SamSmithNZ.IaC/azuredeploy.json | |
| #parameters: src/SamSmithNZ.IaC/azuredeploy.parameters.json servers_ssnzdbserver_name="ssnzdbserver" | |
| - name: 'App Service Deploy: SamSmithNZ web service' | |
| uses: Azure/webapps-deploy@v3 | |
| with: | |
| app-name: ssnz-prod-eu-service | |
| package: service | |
| slot-name: production #staging | |
| - name: Set service secrets #--slot staging | |
| run: az webapp config appsettings set --name "ssnz-prod-eu-service" --resource-group "SamSmithNZ.com" --settings "ConnectionStrings:DefaultConnectionString=${{ secrets.SQL_CONNECTIONSTRING }}" "CacheConnection=${{ secrets.REDIS_CONNECTIONSTRING }}" | |
| - name: 'App Service Deploy: SamSmithNZ website' | |
| uses: Azure/webapps-deploy@v3 | |
| with: | |
| app-name: ssnz-prod-eu-web | |
| package: web | |
| slot-name: production #staging | |
| - name: Display GitVersion outputs | |
| run: | | |
| echo "Version: ${{ needs.buildWebsite.outputs.Version }}" | |
| echo "CommitsSinceVersionSource: ${{ needs.buildWebsite.outputs.CommitsSinceVersionSource }}" | |
| - name: Create Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| if: github.ref == 'refs/heads/main' && needs.buildWebsite.outputs.CommitsSinceVersionSource > 0 #Only create a release if there has been a commit/version change | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token | |
| with: | |
| tag_name: ${{ needs.buildWebsite.outputs.Version }} | |
| release_name: Release ${{ needs.buildWebsite.outputs.Version }} | |
| deploySQLDB: | |
| name: Deploy SQL database | |
| runs-on: windows-latest | |
| needs: | |
| - build | |
| - buildWebsite | |
| - buildFunctionalTests | |
| - buildDatabase | |
| - testDotNet | |
| #- sonarCloud | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download the build artifacts | |
| uses: actions/download-artifact@v4 | |
| - name: Azure Login | |
| uses: azure/login@v2 | |
| with: | |
| creds: ${{ secrets.ORG_AZURE_SP }} | |
| - name: deploy database infrastructure as code | |
| uses: azure/arm-deploy@v2 | |
| with: | |
| resourceGroupName: SamSmithNZ.com | |
| template: src/SamSmithNZ.IaC/azuredeployDB.json | |
| parameters: src/SamSmithNZ.IaC/azuredeployDB.parameters.json servers_ssnzdbserver_name="ssnzdbserver" | |
| - name: Azure SQL dacpac publish | |
| uses: azure/sql-action@v2 | |
| with: | |
| connection-string: ${{ secrets.AZURE_SQL_CONNECTION_STRING }} | |
| path: Database/SamSmithNZ.Database.dacpac | |
| action: Publish | |
| arguments: /p:BlockOnPossibleDataLoss=true | |
| runSmokeTests: | |
| name: Run smoke tests on staging slots | |
| runs-on: windows-2022 | |
| needs: | |
| - deployWebAppsToSlots | |
| - deploySQLDB | |
| if: github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download the build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: functionalTests | |
| path: ${{ github.workspace }} | |
| - name: Install .NET SDK | |
| uses: actions/setup-dotnet@v4.3.0 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Run functional smoke tests on website and web service | |
| run: | | |
| $vsTestConsoleExe = "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\Common7\\IDE\\Extensions\\TestPlatform\\vstest.console.exe" | |
| $targetTestDll = "**\SamSmithNZ.FunctionalTests.dll" | |
| $testRunSettings = "/Settings:`"test.runsettings`" " | |
| #$parameters = " -- ServiceUrl=""https://ssnz-prod-eu-service-staging.azurewebsites.net/"" WebsiteUrl=""https://www.samsmithnz.com/"" " | |
| $parameters = " -- ServiceUrl=""https://ssnz-prod-eu-service.azurewebsites.net/"" WebsiteUrl=""https://www.samsmithnz.com/"" " | |
| #Note that the `" is an escape character to quote strings, and the `& is needed to start the command | |
| $command = "`& `"$vsTestConsoleExe`" `"$targetTestDll`" $testRunSettings $parameters " | |
| Write-Host "$command" | |
| Invoke-Expression $command | |
| shell: powershell | |
| swapStagingSlotsToProd: | |
| name: Swap staging slots to prod | |
| runs-on: ubuntu-latest | |
| if: 0 == 1 | |
| #if: github.ref == 'refs/heads/main' | |
| needs: | |
| - runSmokeTests | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Azure Login | |
| uses: azure/login@v2 | |
| with: | |
| creds: ${{ secrets.ORG_AZURE_SP }} | |
| - name: 'Swap Slots: web service' | |
| uses: Azure/cli@v2.1.0 | |
| with: | |
| inlineScript: az webapp deployment slot swap --resource-group SamSmithNZ.com --name ssnz-prod-eu-service --slot staging --target-slot production | |
| - name: 'Swap Slots: web' | |
| uses: Azure/cli@v2.1.0 | |
| with: | |
| inlineScript: az webapp deployment slot swap --resource-group SamSmithNZ.com --name ssnz-prod-eu-web --slot staging --target-slot production | |