diff --git a/build-solution.yml b/build-solution.yml new file mode 100644 index 000000000..2b9b375cf --- /dev/null +++ b/build-solution.yml @@ -0,0 +1,30 @@ +parameters: +- name: solution + type: string +- name: configuration + type: string + default: Release + +steps: +- powershell: | + dir + displayName: 'list dir' + +- task: NuGetToolInstaller@1 + +- task: NuGetCommand@2 + displayName: 'Restoring NuGet packages' + inputs: + command: 'restore' + restoreSolution: ${{ parameters.solution }} + +- task: VSBuild@1 + displayName: 'Building project in ${{ parameters.configuration }}' + inputs: + solution: ${{ parameters.solution }} + msbuildArgs: '/p:AppxBundlePlatforms="x64" /p:AppxPackageDir="$(build.artifactStagingDirectory)\AppxPackages" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload /m /nr:false /p:TreatWarningsAsErrors="true"' + platform: 'x64' + configuration: ${{ parameters.configuration }} + clean: true + env: + MSBUILDDISABLENODEREUSE: 1 diff --git a/build-test-deploy.yml b/build-test-deploy.yml index b6a306639..da3cf06a4 100644 --- a/build-test-deploy.yml +++ b/build-test-deploy.yml @@ -1,261 +1,263 @@ -# https://aka.ms/yaml - -trigger: -- main - -variables: - - group: s3PushInstallers - - group: pipeline-tokens - - name: configuration - value: Release - -pool: 'rhino-compute' - -steps: -- powershell: | - Get-ChildItem *.msi -Recurse | Remove-Item - aws s3 cp s3://oasys-installer-store/GSA/latest . --exclude "*" --include *Arup*.msi --recursive - Get-ChildItem *.msi | Rename-Item -NewName gsa.msi - displayName: 'Download GSA latest' - failOnStderr: true - -- powershell: | - $installerPath = $(ls -r $(Pipeline.Workspace)\gsa.msi) - Write-output "Installer Path: ${installerPath}" - Write-output "GSA Version:" - if (!(Test-Path $installerPath.FullName)) { - Write-output "File '{0}' does not exist" -f $installerPath.FullName - } - try { - $WindowsInstaller = New-Object -com WindowsInstaller.Installer - $Database = $WindowsInstaller.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $Null, $WindowsInstaller, @($installerPath.FullName, 0)) - $Query = "SELECT Value FROM Property WHERE Property = 'ProductVersion'" - $View = $database.GetType().InvokeMember("OpenView", "InvokeMethod", $Null, $Database, ($Query)) - $View.GetType().InvokeMember("Execute", "InvokeMethod", $Null, $View, $Null) | Out-Null - $Record = $View.GetType().InvokeMember( "Fetch", "InvokeMethod", $Null, $View, $Null ) - $Version = $Record.GetType().InvokeMember( "StringData", "GetProperty", $Null, $Record, 1 ) - Write-output $Version - } catch { - Write-output "Failed to get MSI file version: {0}." -f $_ - } - $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 GSA' - failOnStderr: true - -- powershell: | - & 'C:\Program Files\Oasys\*\GSA.exe' /Register - displayName: 'Register GSA COM' - failOnStderr: false - -- powershell: | - ./cleanRegistry.ps1 - displayName: 'Run Registry Cleaner' - failOnStderr: true - -- task: NuGetToolInstaller@1 - -- task: NuGetCommand@2 - displayName: 'Restoring NuGet packages' - inputs: - command: 'restore' - restoreSolution: 'GsaGH.sln' - -- task: VSBuild@1 - displayName: 'Building project in $(configuration)' - inputs: - solution: 'GsaGH.sln' - msbuildArgs: '/p:AppxBundlePlatforms="x64" /p:AppxPackageDir="$(build.artifactStagingDirectory)\AppxPackages" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload /m /nr:false /p:TreatWarningsAsErrors="true"' - 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.2\build --results-directory .\results\gsagh .\GsaGHTests\bin\x64\Release\net48\GsaGHTests.dll - dotnet test --collect:"XPlat Code Coverage" /TestAdapterPath:$env:UserProfile\.nuget\packages\coverlet.collector\6.0.2\build --results-directory .\results\integration .\IntegrationTests\bin\x64\Release\net48\IntegrationTests.dll - displayName: dotnet tests - failOnStderr: true - -- 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_gsagh = (Resolve-Path $(System.DefaultWorkingDirectory)/results/gsagh/*/coverage.cobertura.xml).Path - echo $coverage_file_gsagh - $coverage_file_integration = (Resolve-Path $(System.DefaultWorkingDirectory)/results/integration/*/coverage.cobertura.xml).Path - echo $coverage_file_integration - Copy-Item $coverage_file_gsagh $(System.DefaultWorkingDirectory)\results\coverage_gsagh.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_gsagh.xml -F gsagh - .\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 - -- task: PublishCodeCoverageResults@1 - displayName: Create Azure GsaGH CodeCoverage - inputs: - codeCoverageTool: 'cobertura' - summaryFileLocation: '$(System.DefaultWorkingDirectory)/results/gsagh/**/coverage.cobertura.xml' - pathToSources: '$(System.DefaultWorkingDirectory)' - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) - -- task: PublishCodeCoverageResults@1 - displayName: Create Azure IntegrationTest CodeCoverage - inputs: - codeCoverageTool: 'cobertura' - summaryFileLocation: '$(System.DefaultWorkingDirectory)/results/integration/**/coverage.cobertura.xml' - pathToSources: '$(System.DefaultWorkingDirectory)' - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) - -- publish: $(System.DefaultWorkingDirectory)\results\coverage_gsagh.xml - displayName: Publish GsaGHTest xml to Azure - artifact: GsaGHTestsCoverage - continueOnError: true - -- publish: $(System.DefaultWorkingDirectory)\results\coverage_integration.xml - displayName: Publish IntegrationTest xml to Azure - artifact: IntegrationTestsCoverage - continueOnError: true - -- task: PowerShell@2 - displayName: Check for existing tags - inputs: - targetType: 'inline' - script: | - $versionInfo = $(Get-Item .\GsaGH\bin\x64\Release\net48\GsaGH.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 - $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 GsaGH\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: GsaIcon.png' - Add-Content manifest.yml 'keywords:' - Add-Content manifest.yml '- oasys' - Add-Content manifest.yml '- gsa' - Add-Content manifest.yml '- gsagh' - Add-Content manifest.yml '- fe' - Add-Content manifest.yml '- fea' - Add-Content manifest.yml '- fem' - Add-Content manifest.yml '- structural' - Add-Content manifest.yml '- structuralanalysis' - ..\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 GsaGH - & 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\MSBuild.exe' GsaGH.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 NuGet - -- powershell: | - .\DocsGeneration\bin\x64\Debug\net48\DocsGeneration.exe - Compress-Archive -Path .\Output -DestinationPath .\results\$(dotSeparatedTag)-docs.zip -Force - displayName: Generate docs site - failOnStderr: true - -- publish: $(System.DefaultWorkingDirectory)\results\$(dotSeparatedTag)-docs.zip - displayName: Publish Docs artifact - artifact: Docs - continueOnError: false - -- task: GitHubRelease@1 - displayName: 'Publishing assets to Github' - inputs: - gitHubConnection: 'github.com_MJCramp' - repositoryName: 'arup-group/GSA-Grasshopper' - action: 'edit' - target: '$(Build.SourceVersion)' - tag: '$(dotSeparatedTag)' - title: 'GsaGH version $(dotSeparatedTag)' - releaseNotesSource: 'inline' - releaseNotesInline: | - Created from commit https://github.com/arup-group/GSA-Grasshopper/commit/$(Build.SourceVersion) - assets: | - $(System.DefaultWorkingDirectory)/**/*.yak - $(System.DefaultWorkingDirectory)/**/*.nupkg - $(System.DefaultWorkingDirectory)/**/*.snupkg - $(System.DefaultWorkingDirectory)/**/$(dotSeparatedTag)-docs.zip - assetUploadMode: 'replace' - isDraft: true - isPreRelease: false - addChangeLog: false - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), ne(variables.TAG_EXISTS, 'true')) - -- powershell: Remove-Item -Path C:\Users\**\AppData\Roaming\Grasshopper\Libraries\*.ghlink - displayName: 'Delete orphan .ghlink files' - condition: always() - -- powershell: | - $installerPath = $(ls -r $(Pipeline.Workspace)\gsa.msi) - Write-output "Installer Path: ${installerPath}" - $app = Start-Process "msiexec.exe" -ArgumentList "/x ${installerPath} /quiet /passive /norestart /l* msiUninstallLog.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" - ### Success error codes: 0 = ERROR_SUCCESS, 1641 = ERROR_SUCCESS_REBOOT_INITIATED, 3010 = ERROR_SUCCESS_REBOOT_REQUIRED - ### See https://docs.microsoft.com/en-us/windows/win32/msi/error-codes - if (($app.ExitCode -eq 0) -or ($app.ExitCode -eq 1641) -or ($app.ExitCode -eq 3010)) { - Write-Output "Application successfully uninstalled with exit code $($app.ExitCode)" - rm $installerPath - exit(0) - } else { - Write-Error "Application could not be uninstalled. Error code $($app.ExitCode)" - exit(1) - } - condition: always() - displayName: 'Uninstall Application' +# # https://aka.ms/yaml +# +# trigger: +# branches: +# exclude: +# - 'task/GSAGH-555-new-pipeline' +# +# variables: +# - group: s3PushInstallers +# - group: pipeline-tokens +# - name: configuration +# value: Release +# +# pool: 'rhino-compute' +# +# steps: +# - powershell: | +# Get-ChildItem *.msi -Recurse | Remove-Item +# aws s3 cp s3://oasys-installer-store/GSA/latest . --exclude "*" --include *Arup*.msi --recursive +# Get-ChildItem *.msi | Rename-Item -NewName gsa.msi +# displayName: 'Download GSA latest' +# failOnStderr: true +# +# - powershell: | +# $installerPath = $(ls -r $(Pipeline.Workspace)\gsa.msi) +# Write-output "Installer Path: ${installerPath}" +# Write-output "GSA Version:" +# if (!(Test-Path $installerPath.FullName)) { +# Write-output "File '{0}' does not exist" -f $installerPath.FullName +# } +# try { +# $WindowsInstaller = New-Object -com WindowsInstaller.Installer +# $Database = $WindowsInstaller.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $Null, $WindowsInstaller, @($installerPath.FullName, 0)) +# $Query = "SELECT Value FROM Property WHERE Property = 'ProductVersion'" +# $View = $database.GetType().InvokeMember("OpenView", "InvokeMethod", $Null, $Database, ($Query)) +# $View.GetType().InvokeMember("Execute", "InvokeMethod", $Null, $View, $Null) | Out-Null +# $Record = $View.GetType().InvokeMember( "Fetch", "InvokeMethod", $Null, $View, $Null ) +# $Version = $Record.GetType().InvokeMember( "StringData", "GetProperty", $Null, $Record, 1 ) +# Write-output $Version +# } catch { +# Write-output "Failed to get MSI file version: {0}." -f $_ +# } +# $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 GSA' +# failOnStderr: true +# +# - powershell: | +# & 'C:\Program Files\Oasys\*\GSA.exe' /Register +# displayName: 'Register GSA COM' +# failOnStderr: false +# +# - powershell: | +# ./cleanRegistry.ps1 +# displayName: 'Run Registry Cleaner' +# failOnStderr: true +# +# - task: NuGetToolInstaller@1 +# +# - task: NuGetCommand@2 +# displayName: 'Restoring NuGet packages' +# inputs: +# command: 'restore' +# restoreSolution: 'GsaGH.sln' +# +# - task: VSBuild@1 +# displayName: 'Building project in $(configuration)' +# inputs: +# solution: 'GsaGH.sln' +# msbuildArgs: '/p:AppxBundlePlatforms="x64" /p:AppxPackageDir="$(build.artifactStagingDirectory)\AppxPackages" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload /m /nr:false /p:TreatWarningsAsErrors="true"' +# 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.2\build --results-directory .\results\gsagh .\GsaGHTests\bin\x64\Release\net48\GsaGHTests.dll +# dotnet test --collect:"XPlat Code Coverage" /TestAdapterPath:$env:UserProfile\.nuget\packages\coverlet.collector\6.0.2\build --results-directory .\results\integration .\IntegrationTests\bin\x64\Release\net48\IntegrationTests.dll +# displayName: dotnet tests +# failOnStderr: true +# +# - 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_gsagh = (Resolve-Path $(System.DefaultWorkingDirectory)/results/gsagh/*/coverage.cobertura.xml).Path +# echo $coverage_file_gsagh +# $coverage_file_integration = (Resolve-Path $(System.DefaultWorkingDirectory)/results/integration/*/coverage.cobertura.xml).Path +# echo $coverage_file_integration +# Copy-Item $coverage_file_gsagh $(System.DefaultWorkingDirectory)\results\coverage_gsagh.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_gsagh.xml -F gsagh +# .\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 +# +# - task: PublishCodeCoverageResults@1 +# displayName: Create Azure GsaGH CodeCoverage +# inputs: +# codeCoverageTool: 'cobertura' +# summaryFileLocation: '$(System.DefaultWorkingDirectory)/results/gsagh/**/coverage.cobertura.xml' +# pathToSources: '$(System.DefaultWorkingDirectory)' +# condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) +# +# - task: PublishCodeCoverageResults@1 +# displayName: Create Azure IntegrationTest CodeCoverage +# inputs: +# codeCoverageTool: 'cobertura' +# summaryFileLocation: '$(System.DefaultWorkingDirectory)/results/integration/**/coverage.cobertura.xml' +# pathToSources: '$(System.DefaultWorkingDirectory)' +# condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) +# +# - publish: $(System.DefaultWorkingDirectory)\results\coverage_gsagh.xml +# displayName: Publish GsaGHTest xml to Azure +# artifact: GsaGHTestsCoverage +# continueOnError: true +# +# - publish: $(System.DefaultWorkingDirectory)\results\coverage_integration.xml +# displayName: Publish IntegrationTest xml to Azure +# artifact: IntegrationTestsCoverage +# continueOnError: true +# +# - task: PowerShell@2 +# displayName: Check for existing tags +# inputs: +# targetType: 'inline' +# script: | +# $versionInfo = $(Get-Item .\GsaGH\bin\x64\Release\net48\GsaGH.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 +# $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 GsaGH\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: GsaIcon.png' +# Add-Content manifest.yml 'keywords:' +# Add-Content manifest.yml '- oasys' +# Add-Content manifest.yml '- gsa' +# Add-Content manifest.yml '- gsagh' +# Add-Content manifest.yml '- fe' +# Add-Content manifest.yml '- fea' +# Add-Content manifest.yml '- fem' +# Add-Content manifest.yml '- structural' +# Add-Content manifest.yml '- structuralanalysis' +# ..\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 GsaGH +# & 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\MSBuild.exe' GsaGH.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 NuGet +# +# - powershell: | +# .\DocsGeneration\bin\x64\Debug\net48\DocsGeneration.exe +# Compress-Archive -Path .\Output -DestinationPath .\results\$(dotSeparatedTag)-docs.zip -Force +# displayName: Generate docs site +# failOnStderr: true +# +# - publish: $(System.DefaultWorkingDirectory)\results\$(dotSeparatedTag)-docs.zip +# displayName: Publish Docs artifact +# artifact: Docs +# continueOnError: false +# +# - task: GitHubRelease@1 +# displayName: 'Publishing assets to Github' +# inputs: +# gitHubConnection: 'github.com_MJCramp' +# repositoryName: 'arup-group/GSA-Grasshopper' +# action: 'edit' +# target: '$(Build.SourceVersion)' +# tag: '$(dotSeparatedTag)' +# title: 'GsaGH version $(dotSeparatedTag)' +# releaseNotesSource: 'inline' +# releaseNotesInline: | +# Created from commit https://github.com/arup-group/GSA-Grasshopper/commit/$(Build.SourceVersion) +# assets: | +# $(System.DefaultWorkingDirectory)/**/*.yak +# $(System.DefaultWorkingDirectory)/**/*.nupkg +# $(System.DefaultWorkingDirectory)/**/*.snupkg +# $(System.DefaultWorkingDirectory)/**/$(dotSeparatedTag)-docs.zip +# assetUploadMode: 'replace' +# isDraft: true +# isPreRelease: false +# addChangeLog: false +# condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'), ne(variables.TAG_EXISTS, 'true')) +# +# - powershell: Remove-Item -Path C:\Users\**\AppData\Roaming\Grasshopper\Libraries\*.ghlink +# displayName: 'Delete orphan .ghlink files' +# condition: always() +# +# - powershell: | +# $installerPath = $(ls -r $(Pipeline.Workspace)\gsa.msi) +# Write-output "Installer Path: ${installerPath}" +# $app = Start-Process "msiexec.exe" -ArgumentList "/x ${installerPath} /quiet /passive /norestart /l* msiUninstallLog.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" +# ### Success error codes: 0 = ERROR_SUCCESS, 1641 = ERROR_SUCCESS_REBOOT_INITIATED, 3010 = ERROR_SUCCESS_REBOOT_REQUIRED +# ### See https://docs.microsoft.com/en-us/windows/win32/msi/error-codes +# if (($app.ExitCode -eq 0) -or ($app.ExitCode -eq 1641) -or ($app.ExitCode -eq 3010)) { +# Write-Output "Application successfully uninstalled with exit code $($app.ExitCode)" +# rm $installerPath +# exit(0) +# } else { +# Write-Error "Application could not be uninstalled. Error code $($app.ExitCode)" +# exit(1) +# } +# condition: always() +# displayName: 'Uninstall Application' diff --git a/build-test-nightly.yml b/build-test-nightly.yml index bb7758867..3f494fc7b 100644 --- a/build-test-nightly.yml +++ b/build-test-nightly.yml @@ -1,181 +1,181 @@ # https://aka.ms/yaml -trigger: - branches: - include: - - release/* - -variables: - - group: s3PushInstallers - - group: pipeline-tokens - - name: configuration - value: Release - -pool: 'rhino-compute' - -steps: -- powershell: | - Get-ChildItem *.msi -Recurse | Remove-Item - aws s3 cp s3://oasys-installer-store/GSA/nightly . --exclude "*" --include *Arup*.msi --recursive - Get-ChildItem *.msi | Rename-Item -NewName gsa.msi - displayName: 'Download GSA nightly' - failOnStderr: true - -- powershell: | - $installerPath = $(ls -r $(Pipeline.Workspace)\gsa.msi) - Write-output "Installer Path: ${installerPath}" - Write-output "GSA Version:" - if (!(Test-Path $installerPath.FullName)) { - Write-output "File '{0}' does not exist" -f $installerPath.FullName - } - try { - $WindowsInstaller = New-Object -com WindowsInstaller.Installer - $Database = $WindowsInstaller.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $Null, $WindowsInstaller, @($installerPath.FullName, 0)) - $Query = "SELECT Value FROM Property WHERE Property = 'ProductVersion'" - $View = $database.GetType().InvokeMember("OpenView", "InvokeMethod", $Null, $Database, ($Query)) - $View.GetType().InvokeMember("Execute", "InvokeMethod", $Null, $View, $Null) | Out-Null - $Record = $View.GetType().InvokeMember( "Fetch", "InvokeMethod", $Null, $View, $Null ) - $Version = $Record.GetType().InvokeMember( "StringData", "GetProperty", $Null, $Record, 1 ) - Write-output $Version - } catch { - Write-output "Failed to get MSI file version: {0}." -f $_ - } - $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 GSA' - failOnStderr: true - -- powershell: | - & 'C:\Program Files\Oasys\*\GSA.exe' /Register - displayName: 'Register GSA COM' - failOnStderr: false - -- powershell: | - ./cleanRegistry.ps1 - displayName: 'Run Registry Cleaner' - failOnStderr: true - -- task: NuGetToolInstaller@1 - -- task: NuGetCommand@2 - displayName: 'Restoring NuGet packages' - inputs: - command: 'restore' - restoreSolution: 'GsaGH.sln' - -- task: VSBuild@1 - displayName: 'Building project in $(configuration)' - inputs: - solution: 'GsaGH.sln' - msbuildArgs: '/p:AppxBundlePlatforms="x64" /p:AppxPackageDir="$(build.artifactStagingDirectory)\AppxPackages" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload /m /nr:false /p:TreatWarningsAsErrors="true"' - 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.2\build --results-directory .\results\gsagh .\GsaGHTests\bin\x64\Release\net48\GsaGHTests.dll - dotnet test --collect:"XPlat Code Coverage" /TestAdapterPath:$env:UserProfile\.nuget\packages\coverlet.collector\6.0.2\build --results-directory .\results\integration .\IntegrationTests\bin\x64\Release\net48\IntegrationTests.dll - displayName: dotnet tests - failOnStderr: true - -- 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_gsagh = (Resolve-Path $(System.DefaultWorkingDirectory)/results/gsagh/*/coverage.cobertura.xml).Path - echo $coverage_file_gsagh - $coverage_file_integration = (Resolve-Path $(System.DefaultWorkingDirectory)/results/integration/*/coverage.cobertura.xml).Path - echo $coverage_file_integration - Copy-Item $coverage_file_gsagh $(System.DefaultWorkingDirectory)\results\coverage_gsagh.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_gsagh.xml -F gsagh - .\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_gsagh.xml - displayName: Publish GsaGHTest xml to Azure - artifact: GsaGHTestsCoverage - continueOnError: true - -- publish: $(System.DefaultWorkingDirectory)\results\coverage_integration.xml - displayName: Publish IntegrationTest xml to Azure - artifact: IntegrationTestsCoverage - continueOnError: true - -- powershell: | - cd GsaGH\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: GsaIcon.png' - Add-Content manifest.yml 'keywords:' - Add-Content manifest.yml '- oasys' - Add-Content manifest.yml '- gsa' - Add-Content manifest.yml '- gsagh' - Add-Content manifest.yml '- fe' - Add-Content manifest.yml '- fea' - Add-Content manifest.yml '- fem' - Add-Content manifest.yml '- structural' - Add-Content manifest.yml '- structuralanalysis' - ..\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 - New-Item -ItemType Directory -Path $(System.DefaultWorkingDirectory)\results\yak - Copy-Item $yakCurrentVersName $(System.DefaultWorkingDirectory)\results\yak\$yakCurrentVersName - Copy-Item $yakRh7Name $(System.DefaultWorkingDirectory)\results\yak\$yakRh7Name - displayName: Package yak - -- publish: $(System.DefaultWorkingDirectory)\results\yak\ - displayName: Publish Yak Package to Azure - artifact: Yak Package - continueOnError: false - -- powershell: Remove-Item -Path C:\Users\**\AppData\Roaming\Grasshopper\Libraries\*.ghlink - displayName: 'Delete orphan .ghlink files' - condition: always() - -- powershell: | - $installerPath = $(ls -r $(Pipeline.Workspace)\gsa.msi) - Write-output "Installer Path: ${installerPath}" - $app = Start-Process "msiexec.exe" -ArgumentList "/x ${installerPath} /quiet /passive /norestart /l* msiUninstallLog.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" - ### Success error codes: 0 = ERROR_SUCCESS, 1641 = ERROR_SUCCESS_REBOOT_INITIATED, 3010 = ERROR_SUCCESS_REBOOT_REQUIRED - ### See https://docs.microsoft.com/en-us/windows/win32/msi/error-codes - if (($app.ExitCode -eq 0) -or ($app.ExitCode -eq 1641) -or ($app.ExitCode -eq 3010)) { - Write-Output "Application successfully uninstalled with exit code $($app.ExitCode)" - rm $installerPath - exit(0) - } else { - Write-Error "Application could not be uninstalled. Error code $($app.ExitCode)" - exit(1) - } - condition: always() - displayName: 'Uninstall Application' +# trigger: +# branches: +# exclude: +# - 'task/GSAGH-555-new-pipeline' +# +# variables: +# - group: s3PushInstallers +# - group: pipeline-tokens +# - name: configuration +# value: Release +# +# pool: 'rhino-compute' +# +# steps: +# - powershell: | +# Get-ChildItem *.msi -Recurse | Remove-Item +# aws s3 cp s3://oasys-installer-store/GSA/nightly . --exclude "*" --include *Arup*.msi --recursive +# Get-ChildItem *.msi | Rename-Item -NewName gsa.msi +# displayName: 'Download GSA nightly' +# failOnStderr: true +# +# - powershell: | +# $installerPath = $(ls -r $(Pipeline.Workspace)\gsa.msi) +# Write-output "Installer Path: ${installerPath}" +# Write-output "GSA Version:" +# if (!(Test-Path $installerPath.FullName)) { +# Write-output "File '{0}' does not exist" -f $installerPath.FullName +# } +# try { +# $WindowsInstaller = New-Object -com WindowsInstaller.Installer +# $Database = $WindowsInstaller.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $Null, $WindowsInstaller, @($installerPath.FullName, 0)) +# $Query = "SELECT Value FROM Property WHERE Property = 'ProductVersion'" +# $View = $database.GetType().InvokeMember("OpenView", "InvokeMethod", $Null, $Database, ($Query)) +# $View.GetType().InvokeMember("Execute", "InvokeMethod", $Null, $View, $Null) | Out-Null +# $Record = $View.GetType().InvokeMember( "Fetch", "InvokeMethod", $Null, $View, $Null ) +# $Version = $Record.GetType().InvokeMember( "StringData", "GetProperty", $Null, $Record, 1 ) +# Write-output $Version +# } catch { +# Write-output "Failed to get MSI file version: {0}." -f $_ +# } +# $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 GSA' +# failOnStderr: true +# +# - powershell: | +# & 'C:\Program Files\Oasys\*\GSA.exe' /Register +# displayName: 'Register GSA COM' +# failOnStderr: false +# +# - powershell: | +# ./cleanRegistry.ps1 +# displayName: 'Run Registry Cleaner' +# failOnStderr: true +# +# - task: NuGetToolInstaller@1 +# +# - task: NuGetCommand@2 +# displayName: 'Restoring NuGet packages' +# inputs: +# command: 'restore' +# restoreSolution: 'GsaGH.sln' +# +# - task: VSBuild@1 +# displayName: 'Building project in $(configuration)' +# inputs: +# solution: 'GsaGH.sln' +# msbuildArgs: '/p:AppxBundlePlatforms="x64" /p:AppxPackageDir="$(build.artifactStagingDirectory)\AppxPackages" /p:AppxBundle=Always /p:UapAppxPackageBuildMode=StoreUpload /m /nr:false /p:TreatWarningsAsErrors="true"' +# 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.2\build --results-directory .\results\gsagh .\GsaGHTests\bin\x64\Release\net48\GsaGHTests.dll +# dotnet test --collect:"XPlat Code Coverage" /TestAdapterPath:$env:UserProfile\.nuget\packages\coverlet.collector\6.0.2\build --results-directory .\results\integration .\IntegrationTests\bin\x64\Release\net48\IntegrationTests.dll +# displayName: dotnet tests +# failOnStderr: true +# +# - 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_gsagh = (Resolve-Path $(System.DefaultWorkingDirectory)/results/gsagh/*/coverage.cobertura.xml).Path +# echo $coverage_file_gsagh +# $coverage_file_integration = (Resolve-Path $(System.DefaultWorkingDirectory)/results/integration/*/coverage.cobertura.xml).Path +# echo $coverage_file_integration +# Copy-Item $coverage_file_gsagh $(System.DefaultWorkingDirectory)\results\coverage_gsagh.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_gsagh.xml -F gsagh +# .\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_gsagh.xml +# displayName: Publish GsaGHTest xml to Azure +# artifact: GsaGHTestsCoverage +# continueOnError: true +# +# - publish: $(System.DefaultWorkingDirectory)\results\coverage_integration.xml +# displayName: Publish IntegrationTest xml to Azure +# artifact: IntegrationTestsCoverage +# continueOnError: true +# +# - powershell: | +# cd GsaGH\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: GsaIcon.png' +# Add-Content manifest.yml 'keywords:' +# Add-Content manifest.yml '- oasys' +# Add-Content manifest.yml '- gsa' +# Add-Content manifest.yml '- gsagh' +# Add-Content manifest.yml '- fe' +# Add-Content manifest.yml '- fea' +# Add-Content manifest.yml '- fem' +# Add-Content manifest.yml '- structural' +# Add-Content manifest.yml '- structuralanalysis' +# ..\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 +# New-Item -ItemType Directory -Path $(System.DefaultWorkingDirectory)\results\yak +# Copy-Item $yakCurrentVersName $(System.DefaultWorkingDirectory)\results\yak\$yakCurrentVersName +# Copy-Item $yakRh7Name $(System.DefaultWorkingDirectory)\results\yak\$yakRh7Name +# displayName: Package yak +# +# - publish: $(System.DefaultWorkingDirectory)\results\yak\ +# displayName: Publish Yak Package to Azure +# artifact: Yak Package +# continueOnError: false +# +# - powershell: Remove-Item -Path C:\Users\**\AppData\Roaming\Grasshopper\Libraries\*.ghlink +# displayName: 'Delete orphan .ghlink files' +# condition: always() +# +# - powershell: | +# $installerPath = $(ls -r $(Pipeline.Workspace)\gsa.msi) +# Write-output "Installer Path: ${installerPath}" +# $app = Start-Process "msiexec.exe" -ArgumentList "/x ${installerPath} /quiet /passive /norestart /l* msiUninstallLog.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" +# ### Success error codes: 0 = ERROR_SUCCESS, 1641 = ERROR_SUCCESS_REBOOT_INITIATED, 3010 = ERROR_SUCCESS_REBOOT_REQUIRED +# ### See https://docs.microsoft.com/en-us/windows/win32/msi/error-codes +# if (($app.ExitCode -eq 0) -or ($app.ExitCode -eq 1641) -or ($app.ExitCode -eq 3010)) { +# Write-Output "Application successfully uninstalled with exit code $($app.ExitCode)" +# rm $installerPath +# exit(0) +# } else { +# Write-Error "Application could not be uninstalled. Error code $($app.ExitCode)" +# exit(1) +# } +# condition: always() +# displayName: 'Uninstall Application' diff --git a/dotnet-tests-with-coverage.yml b/dotnet-tests-with-coverage.yml new file mode 100644 index 000000000..0a5348bd1 --- /dev/null +++ b/dotnet-tests-with-coverage.yml @@ -0,0 +1,59 @@ +parameters: + - name: dllName + type: string + default: 'GsaGHTests' + - name: configuration + type: string + default: Release + +steps: + - powershell: | + $name = "${{ parameters.dllName }}" + displayName: 'Simplify name' + - powershell: | + $dllFile = (ls -r "$(System.DefaultWorkingDirectory)\${{ parameters.dllName }}\bin\**\${{ parameters.configuration }}\${{ parameters.dllName }}.dll").FullName + Write-Output This is the file $dllFile + displayName: 'Find dll file' + + - powershell: | + dotnet test --collect:"XPlat Code Coverage" /TestAdapterPath:$env:UserProfile\.nuget\packages\coverlet.collector\6.0.2\build --results-directory .\results\${{ parameters.dllName }} $dllFile + displayName: 'dotnet tests' + failOnStderr: true + + - 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_gsagh = (Resolve-Path $(System.DefaultWorkingDirectory)/results/gsagh/*/coverage.cobertura.xml).Path + echo $coverage_file_gsagh + Copy-Item $coverage_file_gsagh $(System.DefaultWorkingDirectory)\results\coverage_${{ parameters.dllName }}.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_${{ parameters.dllName }}.xml -F ${{ parameters.dllName }} + env: + CODECOV_TOKEN: $(CODECOV_TOKEN) + displayName: Upload Code Coverage to codecovio + failOnStderr: true + + - task: PublishCodeCoverageResults@1 + displayName: Create Azure ${{ parameters.dllName }} CodeCoverage + inputs: + codeCoverageTool: 'cobertura' + summaryFileLocation: '$(System.DefaultWorkingDirectory)/results/${{ parameters.dllName }}/**/coverage.cobertura.xml' + pathToSources: '$(System.DefaultWorkingDirectory)' + condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main')) + + - publish: $(System.DefaultWorkingDirectory)\results\coverage_${{ parameters.dllName }}.xml + displayName: Publish GsaGHTest xml to Azure + artifact: $nameTestsCoverage + continueOnError: true diff --git a/impact-testing.yml b/impact-testing.yml new file mode 100644 index 000000000..a05fc919e --- /dev/null +++ b/impact-testing.yml @@ -0,0 +1,143 @@ +trigger: + branches: + include: + - 'release/*' + +variables: + - group: s3PushInstallers + - group: pipeline-tokens + +pool: 'rhino-compute' + +stages: +- stage: CheckRepoChanges + displayName: 'Check Repository Changes' + pool: + vmImage: 'windows-latest' + jobs: + - job: CheckChanges + displayName: 'Check for Changes in GsaGH and IntegrationTests' + steps: + + - checkout: none + + - powershell: | + Write-Output "Minimal checkout of repository...Branch:$(System.PullRequest.SourceBranch)" + git clone --branch $(System.PullRequest.SourceBranch) --depth 100 --sparse https://$(GITHUB_TOKEN)@github.com/arup-group/GSA-Grasshopper.git . + displayName: 'Minimal Checkout' + env: + GITHUB_TOKEN: $(GITHUB_TOKEN) + + - powershell: | + Write-Output "Checking for changes in GsaGH/** and IntegrationTests/**..." + git fetch origin + git status + + $targetBranch = $(System.PullRequest.TargetBranch) + $gitChanges = git diff --name-only HEAD..$targetBranch + $unitTestsChanged = $false + $integrationTestsChanged = $false + + foreach ($file in $gitChanges) { + Write-Output "Checking file: $file" + # both need to run + if ($file -like 'GsaGH/*') { + $unitTestsChanged = $true + $integrationTestsChanged = $true + } + if ($file -like 'IntegrationTests/*') { + $integrationTestsChanged = $true + } + if ($file -like 'GsaGHTests/*') { + $unitTestsChanged = $true + } + } + + Write-Output "Setting pipeline variables based on changes detected..." + Write-Output "UnitTests=$unitTestsChanged" + echo "##vso[task.setvariable variable=UnitTests]$unitTestsChanged" + Write-Output "Integration=$integrationTestsChanged" + echo "##vso[task.setvariable variable=Integration]$integrationTestsChanged" + displayName: 'Detect Changes in Repo' + +- stage: ImpactTestingUnit + displayName: 'Impact Testing (Unit)' + dependsOn: CheckRepoChanges + condition: always() + # condition: eq(variables['UnitTests'], 'true') + jobs: + - job: UnitTests + displayName: 'Run Unit Tests' + steps: + - checkout: self + - powershell: | + Write-Output "Running Unit Tests..." + displayName: 'Run Unit Tests' + + - template: install-gsa.yml + parameters: + version: latest + + - template: build-solution.yml + parameters: + solution: 'GsaGH.sln' + configuration: 'Debug' + + #- task: VisualStudioTestPlatformInstaller@1 + # displayName: 'Install Test Platform' + # inputs: + # packageFeedSelector: 'nugetOrg' + # versionSelector: 'specificVersion' + # testPlatformVersion: '16.11.0' + + #- task: VSTest@2 + # inputs: + # testSelector: 'testAssemblies' # Enables Test Impact Analysis + # testAssemblyVer2: | + # GsaGHTests\bin\x64\Debug\net48\GsaGHTests.dll + # searchFolder: '$(System.DefaultWorkingDirectory)' + # runOnlyImpactedTests: true + # runInParallel: true + # failOnStderr: true + # codeCoverageEnabled: true + # testFiltercriteria: "FullyQualifiedName~GsaGHTests.Components.Analysis.CreateAnalysisTaskTests" + + #- powershell: | + # $coverage_file = (Resolve-Path $(Agent.TempDirectory)/TestResults/*.trx).Path + # echo $coverage_file + # displayName: 'Find TRX File' + + #- task: PublishBuildArtifacts@1 + # condition: always() + # inputs: + # PathtoPublish: '$(Agent.TempDirectory)\TestResults' + # ArtifactName: 'Tests Results' + # publishLocation: 'Container' + + # Publish code coverage results v2 + # Publish any of the code coverage results from a build. + # - task: PublishCodeCoverageResults@2 + # condition: always() + # inputs: + # codeCoverageTool: 'Cobertura' # 'JaCoCo' + # summaryFileLocation: $coverage_file + #pathToSources: # string. Path to Source files. + #failIfCoverageEmpty: false # boolean. Fail if code coverage results are missing. Default: false. + + - template: dotnet-tests-with-coverage.yml + parameters: + configuration: 'Debug' + + - template: uninstall-gsa.yml + +- stage: ImpactTestingIntegration + displayName: 'Impact Testing (Integration)' + dependsOn: CheckRepoChanges + condition: eq(variables['Integration'], 'true') + jobs: + - job: IntegrationTests + displayName: 'Run Integration Tests' + steps: + - powershell: | + Write-Output "Running Integration Tests..." + displayName: 'Run Integration Tests' diff --git a/install-gsa.yml b/install-gsa.yml new file mode 100644 index 000000000..80bac466b --- /dev/null +++ b/install-gsa.yml @@ -0,0 +1,47 @@ +parameters: +- name: version + type: string + default: 'nightly' + +steps: + - powershell: | + Get-ChildItem *.msi -Recurse | Remove-Item + aws s3 cp s3://oasys-installer-store/GSA/${{ parameters.version }} . --exclude "*" --include *Arup*.msi --recursive + Get-ChildItem *.msi | Rename-Item -NewName gsa.msi + displayName: 'Download GSA nightly' + failOnStderr: true + + - powershell: | + $installerPath = $(ls -r $(Pipeline.Workspace)\gsa.msi) + Write-output "Installer Path: ${installerPath}" + Write-output "GSA Version:" + if (!(Test-Path $installerPath.FullName)) { + Write-output "File '{0}' does not exist" -f $installerPath.FullName + } + try { + $WindowsInstaller = New-Object -com WindowsInstaller.Installer + $Database = $WindowsInstaller.GetType().InvokeMember("OpenDatabase", "InvokeMethod", $Null, $WindowsInstaller, @($installerPath.FullName, 0)) + $Query = "SELECT Value FROM Property WHERE Property = 'ProductVersion'" + $View = $database.GetType().InvokeMember("OpenView", "InvokeMethod", $Null, $Database, ($Query)) + $View.GetType().InvokeMember("Execute", "InvokeMethod", $Null, $View, $Null) | Out-Null + $Record = $View.GetType().InvokeMember( "Fetch", "InvokeMethod", $Null, $View, $Null ) + $Version = $Record.GetType().InvokeMember( "StringData", "GetProperty", $Null, $Record, 1 ) + Write-output $Version + } catch { + Write-output "Failed to get MSI file version: {0}." -f $_ + } + $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 GSA' + failOnStderr: true + + - powershell: | + & 'C:\Program Files\Oasys\*\GSA.exe' /Register + displayName: 'Register GSA COM' + failOnStderr: false diff --git a/uninstall-gsa.yml b/uninstall-gsa.yml new file mode 100644 index 000000000..a61fe673a --- /dev/null +++ b/uninstall-gsa.yml @@ -0,0 +1,20 @@ + +steps: + - powershell: | + $installerPath = $(ls -r $(Pipeline.Workspace)\gsa.msi) + Write-output "Installer Path: ${installerPath}" + $app = Start-Process "msiexec.exe" -ArgumentList "/x ${installerPath} /quiet /passive /norestart /l* msiUninstallLog.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 -eq 0) -or ($app.ExitCode -eq 1641) -or ($app.ExitCode -eq 3010)) { + Write-Output "Application successfully uninstalled with exit code $($app.ExitCode)" + rm $installerPath + exit(0) + } else { + Write-Error "Application could not be uninstalled. Error code $($app.ExitCode)" + exit(1) + } + condition: always() + displayName: 'Uninstall Application'