Add CI build #2
Workflow file for this run
This file contains 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 | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
inputs: | |
configuration: | |
description: 'Build Configuration' | |
required: true | |
default: 'Release' | |
type: choice | |
options: | |
- Debug | |
- Release | |
version_suffix: | |
description: 'Suffix for the NuGet packages (without leading -). Build ID will be appended.' | |
required: false | |
permissions: | |
checks: write | |
jobs: | |
build: | |
runs-on: windows-latest | |
outputs: | |
product_version_suffix: ${{ steps.versions.outputs.product_version_suffix }} | |
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@v3 | |
with: | |
fetch-depth: 0 # avoid shallow clone so nbgv can do its work. | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
- id: versions | |
name: Calculate versions | |
shell: pwsh | |
run: | | |
$versionSuffix = "${{ inputs.version_suffix }}" | |
if ($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" | |
$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 -c $productConfig" | |
Write-Output "build_params=$buildParams" >> $env:GITHUB_OUTPUT | |
Write-Output "Build Params: $buildParams" | |
$testParams = "--no-build --verbosity normal -c $productConfig" | |
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 }} | |
- name: Add msbuild to PATH | |
uses: microsoft/setup-msbuild@v1.1 | |
- name: Build | |
run: msbuild -property:DeployExtension=false -property:Configuration=${{ steps.versions.outputs.product_configuration }} | |
- 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@v3 | |
with: | |
name: packages | |
path: "Reqnroll.VisualStudio.Package/**/*.vsix" | |
- name: Connector Tests | |
shell: pwsh | |
run: | | |
cd Tests/ExternalPackages | |
./buildExternalPackages.ps1 | |
cd .. | |
dotnet test ./Tests/Connector/Reqnroll.VisualStudio.ReqnrollConnector.Tests/Reqnroll.VisualStudio.ReqnrollConnector.Tests.csproj ${{ steps.versions.outputs.test_params }} | |
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 ${{ steps.versions.outputs.test_params }} --logger "trx;LogFileName=specs-results.trx" | |
- uses: actions/upload-artifact@v3 | |
if: success() || failure() | |
with: | |
name: specs-results | |
path: "**/specs-mstest-results.trx" | |
- uses: actions/upload-artifact@v3 | |
if: success() || failure() | |
with: | |
name: specs-results | |
path: "**/specs-results.trx" | |
- name: Test Report | |
uses: dorny/test-reporter@v1 | |
if: success() || failure() | |
with: | |
name: Specs | |
path: "**/specs-results.trx" | |
reporter: dotnet-trx | |