Skip to content

Build

Build #1562

Workflow file for this run

name: Build
on:
schedule:
- cron: "13 23 * * *"
push:
branches:
- main
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
override:
description: 'Version Number'
required: true
default: '0.0.0'
jobs:
waitOld:
name: Wait For Older Runs To Complete
runs-on: ubuntu-latest
steps:
- name: Wait
id: wait
shell: pwsh
run: |
$runID = ${{ github.run_id }}
$endPoint = "https://api.github.com/repos/${{github.repository}}/actions/runs"
$timeout = New-TimeSpan -Minutes 60
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
do {
$result = Invoke-RestMethod -Uri $endPoint
$builds = $result.workflow_runs | Where-Object {$_.name -eq "Build" -and ($_.status -eq "in_progress" -or $_.status -eq "queued") -and $_.id -lt $runID}
# Check if there were any older build runs still going, if not we waited long enough
if (!$builds)
{
Write-Host "Are now top of the run queue"
return
}
Start-Sleep -s 60
Write-Host "Waited so far $($stopwatch.elapsed)"
} while ($stopwatch.elapsed -lt $timeout)
Write-Host "Waited more than an hour for earlier runs to complete, continuing action pipeline"
draftRelease:
name: Draft release
needs: waitOld
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "main"
- uses: release-drafter/release-drafter@v5
if: github.event_name == 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
getVersion:
name: Get package version
runs-on: ubuntu-latest
needs: draftRelease
outputs:
buildNumber: ${{ steps.ver.outputs.BUILD_NUMBER }}
steps:
- name: GetVersion
id: ver
shell: pwsh
run: |
if ("${{github.event.inputs.override}}")
{
Write-Host "Using manually entered override version"
$version = "${{ github.event.inputs.override}}"
}
else
{
$header = @{Authorization = 'Bearer ${{ secrets.GITHUB_TOKEN }}' }
$endPoint = "https://api.github.com/repos/${{github.repository}}/releases"
$info = Invoke-RestMethod -Uri $endPoint -Headers $header
$version = $info.name[0].ToString().Trim("v")
}
Write-Host "::set-output name=BUILD_NUMBER::$($version)"
test-untils:
name: Utils
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- id: builder
env:
GlobalMaqs:ConfigJsonEnvRunOverride: ENV
GlobalMaqs:ConfigJsonEnvRun: ENV
GlobalMaqs:ConfigJsonEnv: ENV
GlobalMaqs:EnvOnly: ENV
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/UtilitiesUnitTests/UtilitiesUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/untils/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/untils/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: untilResults
path: |
artifactTests/untils/**/*.xml
artifactTests/untils/testResults/
test-winapp:
name: WinApp
needs: waitOld
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- name: Configure Windows for automation
uses: ./.github/actions/setup-winapp
- name: Install Appium
run: |
npm install -g appium
appium driver install --source=npm appium-windows-driver
- name: Run Appium
run: invoke-expression 'cmd /c start appium'
shell: pwsh
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/AppiumUnitTests/AppiumUnitTests.csproj --settings Framework/Parallel.RunSettings --filter FullyQualifiedName~AppiumWinAppUnitTests --logger trx --results-directory "${{github.workspace}}/artifactTests/winapp/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/winapp/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: winappResults
path: |
artifactTests/winapp/**/*.xml
artifactTests/winapp/testResults/
test-appium:
name: Appium
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- name: 'BrowserStack Env Setup'
uses: 'browserstack/github-actions/setup-env@master'
with:
username: ${{ secrets.BROWSERSTACK_USERNAME }}
access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/AppiumUnitTests/AppiumUnitTests.csproj --settings Framework/BrowserStack.RunSettings --filter FullyQualifiedName!~AppiumWinAppUnitTests --logger trx --results-directory "${{github.workspace}}/artifactTests/appium/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/appium/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover -- ''TestRunParameters.Parameter(name="AppiumCapsMaqs:bstack:options:accessKey",value="${{ secrets.BROWSERSTACK_ACCESS_KEY }}")'''
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: appiumResults
path: |
artifactTests/appium/**/*.xml
artifactTests/appium/testResults/
test-base:
name: Base
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/BaseTestUnitTests/BaseTestUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/base/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/base/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: baseResults
path: |
artifactTests/base/**/*.xml
artifactTests/base/testResults/
test-webservice:
name: WebService
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- name: Start test service
run: Start-Process -FilePath "dotnet" -ArgumentList "run --project Docker/MAQSService/MainTestService/MainTestService.csproj"
shell: pwsh
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/WebServiceUnitTests/WebServiceUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/webservice/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/webservice/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: webserviceResults
path: |
artifactTests/webservice/**/*.xml
artifactTests/webservice/testResults/
test-playwright:
name: Playwright
needs: waitOld
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install Playwright
run: |
dotnet build Framework/PlaywrightUnitTests/PlaywrightUnitTests.csproj -o Framework/PlaywrightUnitTests/build
pwsh Framework/PlaywrightUnitTests/build/playwright.ps1 install-deps
pwsh Framework/PlaywrightUnitTests/build/playwright.ps1 install
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/PlaywrightUnitTests/PlaywrightUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/Playwright/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/Playwright/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
artifact-name: 'playwright'
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: playwrightResults
path: |
artifactTests/Playwright/**/*.xml
artifactTests/Playwright/testResults/
test-mongo:
name: Mongo
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- name: Build the docker-compose stack
run: docker compose -f Docker/MAQSMongoDB/docker-compose.yml -p openmaqs_maqs-dotnet up -d
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/MongoDBUnitTests/MongoDBUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/mongo/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/mongo/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
artifact-name: 'mongo'
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: mongoResults
path: |
artifactTests/mongo/**/*.xml
artifactTests/mongo/testResults/
test-database:
name: Database
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- name: Build the docker-compose stack
run: docker compose -f Docker/MAQSSQLServer/docker-compose.yml -p openmaqs_maqs-dotnet up -d
- name: Wait for DB to come online
run: sleep 10s
shell: bash
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/DatabaseUnitTests/DatabaseUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/database/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/database/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
artifact-name: 'database'
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: databaseResults
path: |
artifactTests/database/**/*.xml
artifactTests/database/testResults/
test-email:
name: Email
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- name: Build the docker-compose stack
run: docker compose -f Docker/MAQSEmail/docker-compose.yml -p openmaqs_maqs-dotnet up -d
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/EmailUnitTests/EmailUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/email/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/email/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
artifact-name: 'email'
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: emailResults
path: |
artifactTests/email/**/*.xml
artifactTests/email/testResults/
test-framework:
name: Framework
needs: waitOld
runs-on: windows-2022
steps:
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- uses: actions/checkout@v4
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install Playwright
run: |
npx playwright install-deps
npx playwright install
dotnet build Framework/FrameworkUnitTests/FrameworkUnitTests.csproj -o Framework/FrameworkUnitTests/build
pwsh Framework/FrameworkUnitTests/build/playwright.ps1 install
- run: dotnet restore Framework/FrameworkUnitTests/FrameworkUnitTests.csproj
shell: pwsh
- id: browserupdate
uses: ./.github/workflows/setupwinbrowser-action
- id: testframework
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/FrameworkUnitTests/FrameworkUnitTests.csproj -f net471 --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/framework/testResults/"'
- id: testcore
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/FrameworkUnitTests/FrameworkUnitTests.csproj -f netcoreapp3.1 --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/framework/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/framework/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: frameworkResults
path: |
artifactTests/framework/**/*.xml
artifactTests/framework/testResults/
test-specflow:
name: SpecFlow
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- id: browserupdate
uses: ./.github/workflows/setuplinbrowser-action
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/SpecFlowExtensionUnitTests/SpecFlowExtensionUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/specflow/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/specflow/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: specflowResults
path: |
artifactTests/specflow/**/*.xml
artifactTests/specflow/testResults/
test-composite:
name: Composite
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- id: browserupdate
uses: ./.github/workflows/setuplinbrowser-action
- name: Build the docker-compose mongo stack
run: docker compose -f Docker/MAQSMongoDB/docker-compose.yml -p openmaqs_maqs-dotnet up -d
- name: Build the docker-compose email stack
run: docker compose -f Docker/MAQSEmail/docker-compose.yml -p openmaqs_maqs-dotnet up -d
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/CompositeUnitTests/CompositeUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/composite/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/composite/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: compositeResults
path: |
artifactTests/composite/**/*.xml
artifactTests/composite/testResults/
test-specflownunit:
name: SpecFlow NUnit
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- id: browserupdate
uses: ./.github/workflows/setuplinbrowser-action
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/SpecFlowExtensionNUnitTests/SpecFlowExtensionNUnitTests.csproj --settings Framework/Parallel.RunSettings --logger trx --results-directory "${{github.workspace}}/artifactTests/specflownunit/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/specflownunit/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: specflownunitResults
path: |
artifactTests/specflownunit/**/*.xml
artifactTests/specflownunit/testResults/
test-selenpomlazy:
name: Selenium POM and Lazy
needs: waitOld
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- id: browserupdate
uses: ./.github/workflows/setuplinbrowser-action
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/SeleniumUnitTests/SeleniumUnitTests.csproj --settings Framework/Parallel.RunSettings --filter "(FullyQualifiedName~SeleniumUnitTests.LazyElementUnitTests)|(FullyQualifiedName~SeleniumPageObjectUnitTest)|(FullyQualifiedName~SeleniumWebElementTest)|(FullyQualifiedName~Proxy)" --logger trx --results-directory "${{github.workspace}}/artifactTests/selenpomlazy/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/selenpomlazy/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: pomlazyResults
path: |
artifactTests/selenpomlazy/**/*.xml
artifactTests/selenpomlazy/testResults/
test-selenutil:
name: Selenium Utils
needs: waitOld
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- run: dotnet restore Framework/Base.sln
shell: pwsh
- run: choco upgrade firefox
shell: pwsh
- id: browserupdate
uses: ./.github/workflows/setupwinbrowser-action
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/SeleniumUnitTests/SeleniumUnitTests.csproj --settings Framework/Parallel.RunSettings --filter "(FullyQualifiedName~SeleniumUnitTests.SeleniumNUnitTest)|(FullyQualifiedName~SeleniumUnitTests.SeleniumUnitTest)|(FullyQualifiedName~SeleniumUnitTests.SeleniumUtilsTest)|(FullyQualifiedName~SeleniumUnitTests.SeleniumConfigTests)" --logger trx --results-directory "${{github.workspace}}/artifactTests/selenutil/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/selenutil/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: selenutilResults
path: |
artifactTests/selenutil/**/*.xml
artifactTests/selenutil/testResults/
test-selengen:
name: Selenium General
needs: waitOld
runs-on: windows-2022
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- id: browserupdate
uses: ./.github/workflows/setupwinbrowser-action
- name: 'BrowserStack Env Setup'
uses: 'browserstack/github-actions/setup-env@master'
with:
username: ${{ secrets.BROWSERSTACK_USERNAME }}
access-key: ${{ secrets.BROWSERSTACK_ACCESS_KEY }}
- id: builder
uses: ./.github/workflows/buildtest-action
with:
bt-param: 'Framework/SeleniumUnitTests/SeleniumUnitTests.csproj --settings Framework/Parallel.RunSettings --filter "(FullyQualifiedName!~SeleniumNUnitTest)&(FullyQualifiedName!~Proxy)&(FullyQualifiedName!~SeleniumConfigTests)&(FullyQualifiedName!~SeleniumPageObjectUnitTest)&(FullyQualifiedName!~LazyElementUnitTests)&(FullyQualifiedName!~SeleniumUnitTests.SeleniumUnitTest)&(FullyQualifiedName!~SeleniumWebElementTest)&(FullyQualifiedName!~SeleniumUtilsTest)" --logger trx --results-directory "${{github.workspace}}/artifactTests/selengen/testResults/" /p:CoverletOutput="${{github.workspace}}/artifactTests/selengen/" /p:CollectCoverage=true /p:CoverletOutputFormat=opencover -- ''TestRunParameters.Parameter(name="RemoteSeleniumCapsMaqs:bstack:options:accessKey",value="${{ secrets.BROWSERSTACK_ACCESS_KEY }}")'' ''TestRunParameters.Parameter(name="SeleniumMaqs:RunOnBrowserStack",value="NO")'''
- uses: actions/upload-artifact@v4
if: always()
name: "Upload test artifact"
with:
name: selengenResults
path: |
artifactTests/selengen/**/*.xml
artifactTests/selengen/testResults/
sonar:
name: Sonar
runs-on: windows-2022
needs: [test-appium, test-winapp, test-untils, test-mongo, test-database, test-webservice, test-base, test-playwright, test-email, test-framework, test-specflow, test-specflownunit, test-composite, test-selenpomlazy, test-selenutil, test-selengen, getVersion]
steps:
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/Results
- name: Update coverage mappings
shell: pwsh
run: |
$rootPath = "${{ github.workspace }}/Results"
$sourcePath = "${{ github.workspace }}"
Write-Host "Start updating relative paths"
Function Replace($path, $pattern, $replace)
{
$text = (Get-Content $path) -join "`n"
[System.Text.RegularExpressions.Regex]::Replace($text, $pattern, $replace) | Out-File -encoding ASCII $path
}
$files = Get-ChildItem -Path $rootPath -Recurse -Include *.xml
foreach ($file in $files)
{
Write-Host "Updating" $file
Replace $file.FullName '(?<=fullPath=")(([-\w\d\s/\\:]+)(?=[\\/][Ff]ramework))' $sourcePath
Replace $file.FullName '(?<=fullPath="[-\w\d\s/.\\:]+)((/)(?=[-\w\d\s/.]+"))' "\"
}
$files = Get-ChildItem -Path $rootPath -Recurse -Include *.trx
foreach ($file in $files)
{
Write-Host "Updating" $file
Replace $file.FullName '(?<=codeBase=")(([-\w\d\s/\\:]+)(?=[\\/][Ff]ramework))' $sourcePath
Replace $file.FullName '(?<=codeBase="[-\w\d\s/.\\:]+)((/)(?=[-\w\d\s/.]+"))' "\"
Replace $file.FullName '(?<=storage=")(([-\w\d\s/\\:]+)(?=[\\/][Ff]ramework))' $sourcePath.ToLower()
Replace $file.FullName '(?<=storage="[-\w\d\s/.\\:]+)((/)(?=[-\w\d\s/.]+"))' "\"
}
Write-Host "Finished updating relative paths"
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v3
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Build and analyze
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"OpenMAQS_openmaqs-dotnet" /o:"openmaqs" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:projectVersion="${{ needs.getVersion.outputs.buildNumber }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.opencover.reportsPaths=${{ github.workspace }}\Results\**\coverage*.opencover.xml /d:sonar.cs.dotcover.reportsPaths=${{ github.workspace }}\Results\**\*.coverage
dotnet build Framework/Base.sln -p:Version=${{ needs.getVersion.outputs.buildNumber }}
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
report:
name: Report
runs-on: ubuntu-latest
needs: [test-appium, test-selengen, test-winapp, test-untils, test-mongo, test-database, test-webservice, test-base, test-playwright, test-email, test-framework, test-specflow, test-specflownunit, test-composite, test-selenpomlazy, test-selenutil, getVersion]
if: always()
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: ${{ github.workspace }}/Results
- name: Test Report
uses: dorny/test-reporter@v1
continue-on-error: true
with:
name: ReportResults
path: ${{ github.workspace }}/Results/**/*.trx # Path to test results
reporter: dotnet-trx
createNugetPacakges:
name: Create NuGet packages
runs-on: windows-2022
needs: [getVersion]
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- name: Install dependencies
run: dotnet restore Framework/Base.sln
- name: Build
run: |
dotnet build Framework/Base.sln --no-restore --configuration Release -p:Version=${{needs.getVersion.outputs.buildNumber}} -p:BaseOutputPath="${{github.workspace}}/artifactTests/packages/"
- uses: actions/upload-artifact@v4
if: always()
name: "Upload NuGet packages artifact"
with:
name: packages
path: |
artifactTests/packages/**/*.nupkg
artifactTests/packages/**/*.snupkg
publish:
name: Publish NuGet - v${{ needs.getVersion.outputs.buildNumber }}
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && github.event_name != 'schedule'
needs: [getVersion, createNugetPacakges, sonar]
runs-on: windows-2022
environment: nuget
steps:
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.x.x
- uses: actions/download-artifact@v4
with:
name: 'packages'
path: ${{ github.workspace }}/packages
- name: Deploy to nuget
run: dotnet nuget push ${{ github.workspace }}/packages/**/*.nupkg --api-key ${{ secrets.APIKEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Publish GitHub release v${{ needs.getVersion.outputs.buildNumber }}
uses: actions/github-script@v4
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const result = await github.repos.listReleases({
owner: context.repo.owner,
repo: context.repo.repo
})
var id = "NA"
var data = result.data
for(var key in data){
if(data[key].tag_name == "v${{ needs.getVersion.outputs.buildNumber }}" && data[key].draft == true)
{
github.repos.updateRelease({
release_id: data[key].id,
"draft": false,
owner: context.repo.owner,
repo: context.repo.repo });
return;
}
}
console.error("Failed to find related draft release");