-
Notifications
You must be signed in to change notification settings - Fork 7
146 lines (133 loc) · 5.41 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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
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@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
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
$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 }} -additionalArgs "${{ steps.versions.outputs.build_params }}"
- name: Add msbuild to PATH
uses: microsoft/[email protected]
- 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@v3
with:
name: packages
path: "Reqnroll.VisualStudio.Package/**/*.vsix"
- uses: nuget/setup-nuget@v1
- 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 ${{ 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-results.trx"
- name: Test Report
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Specs
path: "**/specs-results.trx"
reporter: dotnet-trx