-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-test.yml
221 lines (193 loc) · 10.1 KB
/
build-test.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# https://aka.ms/yaml
trigger:
- main
variables:
- group: s3PushInstallers
- group: pipeline-tokens
- name: configuration
value: Release
pool: 'rhino-compute'
steps:
- powershell: Remove-Item -Path C:\Users\**\AppData\Roaming\Grasshopper\Libraries\*.ghlink
displayName: 'Delete orphan .ghlink files'
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
displayName: 'Restoring NuGet packages'
inputs:
command: 'restore'
restoreSolution: 'ComposGH.sln'
- powershell: aws s3 cp s3://oasys-installer-store/Compos/compos.msi .\compos.msi
displayName: 'Download Compos'
failOnStderr: true
- powershell: |
$installerPath = $(ls -r $(Pipeline.Workspace)\compos.msi)
Write-output "Installer Path: ${installerPath}"
$app = Start-Process ${installerPath} -ArgumentList '/passive /quiet /l* msiLog.txt' -PassThru -Wait
$app.WaitForExit()
Write-Output "Exit code: $($app.ExitCode)"
Write-Output "Exit time: $($app.ExitTime.ToUniversalTime().ToString('yyyy-MM-dd HH:mm:ss')) UTC"
if ($app.ExitCode -ne 0) {
Write-Error "Application could not be installed. Error code $($app.ExitCode)"
exit(1)
}
displayName: 'Install Compos'
failOnStderr: true
- task: VSBuild@1
displayName: 'Building project in $(configuration)'
inputs:
solution: 'ComposGH.sln'
msbuildArgs: '/p:AppxBundlePlatforms="x64" /p:AppxPackageDir="$(build.artifactStagingDirectory)\AppxPackages" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload /m /nr:false'
platform: 'x64'
configuration: '$(configuration)'
clean: true
env:
MSBUILDDISABLENODEREUSE: 1
- powershell: |
dotnet test --collect:"XPlat Code Coverage" /TestAdapterPath:$env:UserProfile\.nuget\packages\coverlet.collector\6.0.0\build --results-directory .\results\composapi .\ComposTests\bin\x64\Release\net48\ComposAPITests.dll
dotnet test --collect:"XPlat Code Coverage" /TestAdapterPath:$env:UserProfile\.nuget\packages\coverlet.collector\6.0.0\build --results-directory .\results\composgh .\ComposGHTests\bin\x64\Release\net48\ComposGHTests.dll
dotnet test --collect:"XPlat Code Coverage" /TestAdapterPath:$env:UserProfile\.nuget\packages\coverlet.collector\6.0.0\build --results-directory .\results\integration .\IntegrationTests\bin\x64\Release\net48\IntegrationTests.dll
# dotnet test --collect:"XPlat Code Coverage" /TestAdapterPath:$env:UserProfile\.nuget\packages\coverlet.collector\6.0.0\build --results-directory .\results\3 --no-restore --logger trx .\ConverterTests\bin\x64\Release\net48\ConverterTests.dll
displayName: dotnet test
failOnStderr: true
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/results/composapi/**/coverage.cobertura.xml'
pathToSources: '$(System.DefaultWorkingDirectory)'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/results/composgh/**/coverage.cobertura.xml'
pathToSources: '$(System.DefaultWorkingDirectory)'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: '$(System.DefaultWorkingDirectory)/results/integration/**/coverage.cobertura.xml'
pathToSources: '$(System.DefaultWorkingDirectory)'
- powershell: |
if (200 -ne (Invoke-WebRequest -Uri https://codecov.io/validate -Body (Get-Content -Raw -LiteralPath .\codecov.yml) -Method post | Select-Object StatusCode).StatusCode) {
Write-Output "codecov.yml is invalid"
Invoke-WebRequest -Uri https://codecov.io/validate -Body (Get-Content -Raw -LiteralPath .\codecov.yml) -Method post
exit(1)
} else {
Write-Output "codecov.yml is valid"
}
displayName: Validate codecov.yml
failOnStderr: true
- powershell: |
$coverage_file_composapi = (Resolve-Path $(System.DefaultWorkingDirectory)/results/composapi/*/coverage.cobertura.xml).Path
echo $coverage_file_composapi
$coverage_file_composgh = (Resolve-Path $(System.DefaultWorkingDirectory)/results/composgh/*/coverage.cobertura.xml).Path
echo $coverage_file_composgh
$coverage_file_integration = (Resolve-Path $(System.DefaultWorkingDirectory)/results/integration/*/coverage.cobertura.xml).Path
echo $coverage_file_integration
Copy-Item $coverage_file_composapi $(System.DefaultWorkingDirectory)\results\coverage_composapi.xml
Copy-Item $coverage_file_composgh $(System.DefaultWorkingDirectory)\results\coverage_composgh.xml
Copy-Item $coverage_file_integration $(System.DefaultWorkingDirectory)\results\coverage_integration.xml
$ProgressPreference = 'SilentlyContinue'
Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe
ls $(System.DefaultWorkingDirectory)\
cd $(System.DefaultWorkingDirectory)\
.\codecov -t $env:CODECOV_TOKEN --dir $(System.DefaultWorkingDirectory)\results --file coverage_composapi.xml -F composapi
.\codecov -t $env:CODECOV_TOKEN --dir $(System.DefaultWorkingDirectory)\results --file coverage_composgh.xml -F composgh
.\codecov -t $env:CODECOV_TOKEN --dir $(System.DefaultWorkingDirectory)\results --file coverage_integration.xml -F integration
env:
CODECOV_TOKEN: $(CODECOV_TOKEN)
displayName: Upload Code Coverage to codecovio
failOnStderr: true
- publish: $(System.DefaultWorkingDirectory)\results\coverage_composapi.xml
artifact: ComposTestsCoverage
continueOnError: true
- publish: $(System.DefaultWorkingDirectory)\results\coverage_composgh.xml
artifact: ComposGHTestsCoverage
continueOnError: true
- publish: $(System.DefaultWorkingDirectory)\results\coverage_integration.xml
artifact: IntegrationTestsCoverage
continueOnError: true
- task: PowerShell@2
displayName: Check for existing tags
inputs:
targetType: 'inline'
script: |
$versionInfo = $(Get-Item .\ComposGH\bin\x64\Release\net48\ComposGH.dll).VersionInfo
echo $versionInfo
$fullVersion = [array]${versionInfo}.FileVersion.split('.')
$currentTime = $(Get-Date -Format "dddd MM/dd/yyyy HH:mm")
$majorVersion = [string]$fullVersion[0]
$minorVersion = [string]$fullVersion[1]
$spVersion = [string]$fullVersion[2]
$buildNumber = [string]$fullVersion[3]
$tag = [array]@($exeName,$majorVersion,$minorVersion,$spVersion,$buildNumber)
$tagNumbersOnly = [array]@($majorVersion,$minorVersion,$spVersion,$buildNumber)
$dotSeparatedTag = $majorVersion + "." + $minorVersion + "." + $spVersion + "-beta"
$underscoreSeparatedTag = $majorVersion + "_" + $minorVersion + "_" + $spVersion + "_" + $buildNumber
$tagNumbersOnlyUnderscore = $majorVersion + "_" + $minorVersion + "_" + $spVersion + "_" + $buildNumber
$tagNumbersOnlydot = $majorVersion + "." + $minorVersion + "." + $spVersion + "." + $buildNumber
Write-Host ("##vso[task.setvariable variable=dotSeparatedTag]$dotSeparatedTag")
git rev-parse $dotSeparatedTag
if($lastExitCode -eq 0){Write-Host ("##vso[task.setvariable variable=TAG_EXISTS]true")}
if($lastExitCode -eq 0){
$tagExists = 'true'
echo $tagExists
}
errorActionPreference: 'continue'
workingDirectory: '$(System.DefaultWorkingDirectory)'
ignoreLASTEXITCODE: true
- powershell: |
cd ComposGH\bin\x64\Release
curl https://files.mcneel.com/yak/tools/latest/yak.exe -o yak.exe
.\yak version
cd net48
..\yak spec
Add-Content manifest.yml 'icon: ComposIcon.png'
Add-Content manifest.yml 'keywords:'
Add-Content manifest.yml '- oasys'
Add-Content manifest.yml '- compos'
Add-Content manifest.yml '- composgh'
Add-Content manifest.yml '- composite'
Add-Content manifest.yml '- sectiondesign'
Add-Content manifest.yml '- sectionanalysis'
Add-Content manifest.yml '- compositedesign'
Add-Content manifest.yml '- compositeanalysis'
Add-Content manifest.yml '- structural'
..\yak build --platform win
$yakCurrentVersName = Get-ChildItem -Path . -Filter "*.yak"
$yakRh7Name = $yakCurrentVersName -Replace "rh6_27", "rh7_0"
Rename-Item -Path $yakCurrentVersName -NewName $yakRh7Name
..\yak build --platform win
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), ne(variables.TAG_EXISTS, 'true'))
displayName: Package yak
- powershell: |
cd ComposGH
& 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\MSBuild.exe' ComposGH.csproj /t:pack /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:DebugType=portable /property:Configuration=Debug
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), ne(variables.TAG_EXISTS, 'true'))
displayName: Package ComposGH NuGet
- powershell: |
cd Compos
& 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\MSBuild.exe' ComposAPI.csproj /t:pack /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg /p:DebugType=portable /property:Configuration=Debug
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), ne(variables.TAG_EXISTS, 'true'))
displayName: Package ComposAPI NuGet
- task: GitHubRelease@1
inputs:
gitHubConnection: 'github.com_MJCramp'
repositoryName: 'arup-group/Compos-Grasshopper'
action: 'edit'
target: '$(Build.SourceVersion)'
tag: '$(dotSeparatedTag)'
title: 'ComposGH version $(dotSeparatedTag)'
releaseNotesSource: 'inline'
releaseNotesInline: |
Created from commit https://github.com/arup-group/Compos-Grasshopper/commit/$(Build.SourceVersion)
assets: |
$(System.DefaultWorkingDirectory)/**/*.yak
$(System.DefaultWorkingDirectory)/**/*.nupkg
$(System.DefaultWorkingDirectory)/**/*.snupkg
assetUploadMode: 'replace'
isDraft: true
isPreRelease: true
addChangeLog: false
condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), ne(variables.TAG_EXISTS, 'true'))
displayName: 'Publishing assets to Github'
- powershell: Remove-Item -Path C:\Users\**\AppData\Roaming\Grasshopper\Libraries\*.ghlink
displayName: 'Delete orphan .ghlink files'
condition: always()