Skip to content

CI

CI #176

Workflow file for this run

name: CI
on:
push:
branches:
- 'main'
paths-ignore:
- 'docs/**'
- README.md
- CHANGELOG.md
pull_request:
branches: [ "main" ]
workflow_dispatch:
inputs:
configuration:
description: 'Build Configuration'
required: true
default: 'Release'
type: choice
options:
- Debug
- Release
production_release:
description: 'If the build produces a production package (resets version prefix)'
type: boolean
default: false
required: true
version_suffix:
description: 'Suffix for the NuGet packages (without leading -). Build ID will be appended.'
default: manual
required: false
permissions:
checks: write
jobs:
build:
runs-on: windows-latest
outputs:
product_version_suffix: ${{ steps.versions.outputs.product_version_suffix }}
product_build_number: ${{ steps.versions.outputs.product_build_number }}
product_configuration: ${{ steps.versions.outputs.product_configuration }}
build_params: ${{ steps.versions.outputs.build_params }}
test_params: ${{ steps.versions.outputs.test_params }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- id: versions
name: Calculate versions
shell: pwsh
env:
APPINSIGHTS_KEY: ${{ secrets.APPINSIGHTS_KEY }}
run: |
$productionReleaseSetting = "${{ inputs.production_release }}"
$productionRelease = $false
if ($productionReleaseSetting -eq 'true') {
$productionRelease = $true
}
Write-Output "Production release: $productionRelease"
$versionSuffix = "${{ inputs.version_suffix }}"
if ($productionRelease) {
$versionSuffix = ''
}
elseif ($versionSuffix -eq "") {
$date = [datetime]::Today
$dateString = $date.ToString('yyyyMMdd')
$versionSuffix = "ci$dateString-${env:GITHUB_RUN_NUMBER}"
}
else {
$versionSuffix = "$versionSuffix-${env:GITHUB_RUN_NUMBER}"
}
Write-Output "product_version_suffix=$versionSuffix" >> $env:GITHUB_OUTPUT
Write-Output "Product Suffix: $versionSuffix"
$buildNumber = ${env:GITHUB_RUN_NUMBER}
Write-Output "product_build_number=$buildNumber" >> $env:GITHUB_OUTPUT
Write-Output "Build Number: $buildNumber"
$productConfig = "${{ inputs.configuration }}"
if ($productConfig -eq "") {
$productConfig = "Release"
}
Write-Output "product_configuration=$productConfig" >> $env:GITHUB_OUTPUT
Write-Output "Product Configuration: $productConfig"
$buildParams = "-p:VersionSuffix=$versionSuffix -property:ReqnrollBuildNumber=$buildNumber"
Write-Output "Build Params: $buildParams"
if ($productionRelease) {
$buildParams = "$buildParams -property:AppInsightsInstrumentationKey=$env:APPINSIGHTS_KEY"
Write-Output "Main Build Params Updated for Production"
}
Write-Output "build_params=$buildParams" >> $env:GITHUB_OUTPUT
$gitHubActionsLoggerSettings = '"GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true;annotations.titleFormat=[@traits.Category] @test;annotations.messageFormat=@error\n@trace"'
$testParams = "--no-build --verbosity normal -c $productConfig --logger trx --logger $gitHubActionsLoggerSettings -- RunConfiguration.CollectSourceInformation=true"
Write-Output "test_params=$testParams" >> $env:GITHUB_OUTPUT
Write-Output "Test Params: $testParams"
- name: Restore dependencies
run: dotnet restore
- name: Build Connectors
shell: pwsh
run: |
cd Connectors
.\build.ps1 -configuration ${{ steps.versions.outputs.product_configuration }} -additionalArgs "${{ steps.versions.outputs.build_params }}"
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- name: Install Test Report Dependencies
run: |
dotnet add ./Tests/Reqnroll.VisualStudio.Specs/Reqnroll.VisualStudio.Specs.csproj package GitHubActionsTestLogger
dotnet add ./Tests/Reqnroll.VisualStudio.Tests/Reqnroll.VisualStudio.Tests.csproj package GitHubActionsTestLogger
dotnet add ./Tests/Connector/Reqnroll.VisualStudio.ReqnrollConnector.Tests/Reqnroll.VisualStudio.ReqnrollConnector.Tests.csproj package GitHubActionsTestLogger
dotnet add ./Tests/Connector/Reqnroll.VisualStudio.ReqnrollConnector.V1.Tests/Reqnroll.VisualStudio.ReqnrollConnector.V1.Tests.csproj package GitHubActionsTestLogger
- name: Build
run: msbuild -property:DeployExtension=false -property:Configuration=${{ steps.versions.outputs.product_configuration }} ${{ steps.versions.outputs.build_params }}
- name: Unit Tests
run: dotnet test ./Tests/Reqnroll.VisualStudio.Tests/Reqnroll.VisualStudio.Tests.csproj ${{ steps.versions.outputs.test_params }}
- name: Upload vsix
uses: actions/upload-artifact@v4
with:
name: vsix
path: "Reqnroll.VisualStudio.Package/**/*.vsix"
- uses: nuget/[email protected]
- name: Prepare Connector Tests
shell: pwsh
run: |
cd Tests/ExternalPackages
./buildExternalPackages.ps1
cd PackagesForTests
nuget install packages.config
- name: Connector Tests
run: dotnet test ./Tests/Connector/Reqnroll.VisualStudio.ReqnrollConnector.Tests/Reqnroll.VisualStudio.ReqnrollConnector.Tests.csproj ${{ steps.versions.outputs.test_params }}
- name: Connector V1 Tests
run: dotnet test ./Tests/Connector/Reqnroll.VisualStudio.ReqnrollConnector.V1.Tests/Reqnroll.VisualStudio.ReqnrollConnector.V1.Tests.csproj ${{ steps.versions.outputs.test_params }}
- name: Specs Tests
run: >
dotnet test ./Tests/Reqnroll.VisualStudio.Specs/Reqnroll.VisualStudio.Specs.csproj
--filter "Category!=quarantaine"
${{ steps.versions.outputs.test_params }}
- name: Upload Test Result TRX Files
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: trx-test-results
path: "**/*.trx"