Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: get Linux build to upload build artifacts #1293

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion PSCompatibilityCollector/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ function Invoke-CrossCompatibilityModuleBuild
Push-Location $script:BinModSrcDir
try
{
dotnet publish -f $Framework -c $Configuration
if ( test-path "$HOME/.dotnet/dotnet" ) {
$dotnet = "$HOME/.dotnet/dotnet"
}
else {
$dotnet = "dotnet"
}
& $dotnet publish -f $Framework -c $Configuration
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this the fix for the premature build abortion

}
finally
{
Expand Down
16 changes: 8 additions & 8 deletions Tests/Engine/CustomizedRule.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ Describe "Test importing correct customized rules" {
It "will show the custom rules when given a glob" {
# needs fixing for Linux
$expectedNumRules = 4
if ($IsLinux)
{
$expectedNumRules = 3
}
#if ($IsLinux)
#{
# $expectedNumRules = 3
#}
$customizedRulePath = Get-ScriptAnalyzerRule -CustomizedRulePath $directory\samplerule\samplerule* | Where-Object {$_.RuleName -match $measure}
$customizedRulePath.Count | Should -Be $expectedNumRules
}
Expand All @@ -113,10 +113,10 @@ Describe "Test importing correct customized rules" {
It "will show the custom rules when given glob with recurse switch" {
# needs fixing for Linux
$expectedNumRules = 5
if ($IsLinux)
{
$expectedNumRules = 4
}
#if ($IsLinux)
#{
# $expectedNumRules = 4
#}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should just delete those commented out code lines now that it works without a special case (not sure why, I guess some upstream dependency received a fix)

$customizedRulePath = Get-ScriptAnalyzerRule -RecurseCustomRulePath -CustomizedRulePath $directory\samplerule\samplerule* | Where-Object {$_.RuleName -eq $measure}
$customizedRulePath.Count | Should -Be $expectedNumRules
}
Expand Down
16 changes: 9 additions & 7 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ environment:
BuildConfiguration: Release
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true # For faster CI builds
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
PowerShellEdition: PowerShellCore
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
PowerShellEdition: WindowsPowerShell
- APPVEYOR_BUILD_WORKER_IMAGE: WMF 4
PowerShellEdition: WindowsPowerShell
PSVersion: 4
- APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu
PowerShellEdition: PowerShellCore
# - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
# PowerShellEdition: PowerShellCore
# - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
# PowerShellEdition: WindowsPowerShell
# - APPVEYOR_BUILD_WORKER_IMAGE: WMF 4
# PowerShellEdition: WindowsPowerShell
# PSVersion: 4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please uncomment again before the merge


# cache Nuget packages and dotnet CLI cache
cache:
Expand All @@ -34,7 +34,9 @@ build_script:
- pwsh: |
if ($env:PowerShellEdition -eq 'PowerShellCore') {
Set-Location $env:APPVEYOR_BUILD_FOLDER
Write-Verbose -Verbose "calling build.ps1"
./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 6
Write-Verbose -Verbose "calling PSCompatibility/build.ps1"
./PSCompatibilityCollector/build.ps1 -Configuration "$env:BuildConfiguration" -Framework 'netstandard2.0'
}

Expand Down
21 changes: 19 additions & 2 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,11 @@ function Start-ScriptAnalyzerBuild
)

BEGIN {
Write-Verbose -Verbose "Start-ScriptAnalyzerBuild BEGIN"
# don't allow the build to be started unless we have the proper Cli version
# this will not actually install dotnet if it's already present, but it will
# install the proper version
Install-Dotnet
Install-Dotnet -Verbose
if ( -not (Test-SuitableDotnet) ) {
$requiredVersion = Get-GlobalJsonSdkVersion
$foundVersion = Get-InstalledCLIVersion
Expand All @@ -168,6 +169,7 @@ function Start-ScriptAnalyzerBuild
}
END {

Write-Verbose -Verbose "Start-ScriptAnalyzerBuild END"
# Build docs either when -Documentation switch is being specified or the first time in a clean repo
$documentationFileExists = Test-Path (Join-Path $PSScriptRoot 'out\PSScriptAnalyzer\en-us\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml')
if ( $Documentation -or -not $documentationFileExists )
Expand Down Expand Up @@ -246,11 +248,15 @@ function Start-ScriptAnalyzerBuild
try {
Push-Location $projectRoot/Rules
Write-Progress "Building ScriptAnalyzer for PSVersion '$PSVersion' using framework '$framework' and configuration '$Configuration'"
Write-Verbose -verbose "Building ScriptAnalyzer for PSVersion '$PSVersion' using framework '$framework' and configuration '$Configuration'"
if ( -not $script:DotnetExe ) {
$script:DotnetExe = Get-DotnetExe
}
$buildOutput = & $script:DotnetExe build --framework $framework --configuration "$config" 2>&1
if ( $LASTEXITCODE -ne 0 ) { throw "$buildOutput" }
if ( $LASTEXITCODE -ne 0 ) {
$buildOutput | Write-Verbose -Verbose
throw "$buildOutput"
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation of closing brace is 1 level too much

}
catch {
Write-Warning $_
Expand All @@ -261,6 +267,7 @@ function Start-ScriptAnalyzerBuild
Pop-Location
}

Write-Verbose -Verbose "Publish-File to ${script:destinationDir}"
Publish-File $itemsToCopyCommon $script:destinationDir

$itemsToCopyBinaries = @(
Expand Down Expand Up @@ -390,16 +397,19 @@ function Install-Dotnet
Push-Location $PSScriptRoot
$installScriptPath = Receive-DotnetInstallScript
$installScriptName = [System.IO.Path]::GetFileName($installScriptPath)
Write-Verbose -Verbose "installscript is $installScriptPath"
If ( $PSCmdlet.ShouldProcess("$installScriptName for $version")) {
& "${installScriptPath}" -c release -version $version
}
# this may be the first time that dotnet has been installed,
# set up the executable variable
if ( -not $script:DotnetExe ) {
$script:DotnetExe = Get-DotnetExe
Write-Verbose -Verbose "Setting DotnetExe variable to ${script:DotnetExe}"
}
}
catch {
Write-Warning "Failure build.psm1 line 407"
throw $_
}
finally {
Expand Down Expand Up @@ -543,6 +553,7 @@ function Get-InstalledCLIVersion {
}
}
catch {
Write-Warning "${script:DotnetExe} --list-sdks"
Write-Verbose -Verbose "$_"
$installedVersions = & $script:DotnetExe --version 2>$null
}
Expand Down Expand Up @@ -607,7 +618,9 @@ function Receive-DotnetInstallScript
}
$uri = "https://dot.net/v1/${installScriptName}"

Write-Verbose -Verbose "downloading $urt"
$installScript = Receive-File -Uri $uri
Write-Verbose -Verbose "InstallScript is $installScript"
return $installScript.FullName
}

Expand Down Expand Up @@ -640,9 +653,13 @@ function Get-DotnetExe
$dotnetHuntPath = "$HOME/.dotnet/dotnet"
Write-Verbose -Verbose "checking non-Windows $dotnetHuntPath"
if ( test-path $dotnetHuntPath ) {
Write-Verbose -Verbose "$dotnetHuntPath found"
$script:DotnetExe = $dotnetHuntPath
return $dotnetHuntPath
}
else {
Write-Verbose -Verbose "$dotnetHuntPath not found"
}
}

Write-Warning "Could not find dotnet executable"
Expand Down
35 changes: 25 additions & 10 deletions tools/appveyor.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,17 @@ function Invoke-AppVeyorInstall {

# the build script sorts out the problems of WMF4 and earlier versions of dotnet CLI
Write-Verbose -Verbose "Installing required .Net CORE SDK"
Write-Verbose "& $buildScriptDir/build.ps1 -bootstrap"
$buildScriptDir = (Resolve-Path "$PSScriptRoot/..").Path
& "$buildScriptDir/build.ps1" -bootstrap
Write-Verbose -Verbose "& $buildScriptDir/build.ps1 -bootstrap"
try {
& "$buildScriptDir/build.ps1" -bootstrap
Write-Verbose -Verbose "exiting Invoke-AppVeyorInstall ($LASTEXITCODE)"
$GLOBAL:LASTEXITCODE = $LASTEXITCODE = 0
Write-Verbose -Verbose "bootstrap complete: $(get-date)"
}
catch {
Write-Warning "error in invocation of build.ps1 from Invoke-AppVeyorInstall"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why catch the error and not let it error out?

}
}

# Implements AppVeyor 'test_script' step
Expand Down Expand Up @@ -95,12 +103,19 @@ function Invoke-AppveyorTest {
function Invoke-AppveyorFinish {
$stagingDirectory = (Resolve-Path ..).Path
$zipFile = Join-Path $stagingDirectory "$(Split-Path $pwd -Leaf).zip"
Add-Type -AssemblyName 'System.IO.Compression.FileSystem'
[System.IO.Compression.ZipFile]::CreateFromDirectory((Join-Path $pwd 'out'), $zipFile)
@(
# add test results as an artifact
(Get-ChildItem TestResults.xml)
# You can add other artifacts here
(Get-ChildItem $zipFile)
) | ForEach-Object { Push-AppveyorArtifact $_.FullName }
$targetDir = Join-Path $pwd out
if ( ! ( test-path $targetDir ) ) {
# provide some additional data to help with debugging
Get-ChildItem $PWD | Write-Verbose -Verbose
}
else {
Add-Type -AssemblyName 'System.IO.Compression.FileSystem'
[System.IO.Compression.ZipFile]::CreateFromDirectory($targetDir, $zipFile)
@(
# add test results as an artifact
(Get-ChildItem TestResults.xml)
# You can add other artifacts here
(Get-ChildItem $zipFile)
) | ForEach-Object { Push-AppveyorArtifact $_.FullName }
}
}