-
Notifications
You must be signed in to change notification settings - Fork 382
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
Update, simplify, and consolidate build scripts #1082
Update, simplify, and consolidate build scripts #1082
Conversation
Require any 2.1 sdk for building, this way we can build with the same sdk as PowerShell core
To build for core, simply type ./build, to build all flavors and documentation type ./build -all. You can now run tests as well via ./build -Test.
because it's really about the version of PS, not the analyzer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By looking at the code it looks good overall, with one small mistake. Some odd (non-standard and inconsistent) whitespace at the beginning and/or end of a parenthesis.
I will try running and using this locally the next days and then approve.
tools/docker/ubuntu16/Dockerfile
Outdated
|
||
RUN apt update -qq && \ | ||
cd / && \ | ||
git clone https://github.com/JamesWTruher/PSScriptAnalyzer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be?
git clone https://github.com/JamesWTruher/PSScriptAnalyzer | |
git clone https://github.com/PowerShell/PSScriptAnalyzer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed it should :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -123,25 +123,33 @@ Note: the PSScriptAnalyzer Chocolatey package is provided and supported by the c | |||
* Building | |||
|
|||
You can either build using the `Visual Studio` solution `PSScriptAnalyzer.sln` or build using `PowerShell` specifically for your platform as follows: | |||
* Windows PowerShell version 5.0 and greater | |||
* The default build is for PowerShell Core |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for the sake of argument, should the default build be for the current platform the script is being run on? That's possibly an order of magnitude harder to accomplish, but thought I would bring it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for that but I see it as an optional nice to have that could come after this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:) why would anyone be using anything other than core? :)
$testScriptFilePath = CreateTestRunnerScript $testPath | ||
Start-Process powershell -ArgumentList "-NoExit","-File $testScriptFilePath" -Verb runas | ||
# clean up the test file | ||
$setName = $PSCmdlet.ParameterSetName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is used above, maybe it's worth assigning above, below the Import-Module
line?
Build-ScriptAnalyzer -Documentation | ||
} | ||
"BuildOne" { | ||
$buildArgs = @{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: I find I do this a lot in PowerShell as well (pass arguments down through commands). Perhaps it's an antipattern (Law of Demeter violation type of thing), but it would be nice to introduce a simpler way for commands to "inherit" all the common parameters between it and its caller (which haven't been overridden).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i often create a hash earlier in the script and then modify it based on conditions.
[string]$Framework = "core", | ||
|
||
[Parameter(ParameterSetName="BuildOne")] | ||
[ValidateSet("3","4","5")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should "6"
be an option here? I feel like equating 5 with Core might prove confusing. We should probably have a comment to document it at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and we should then remove the $Framework parameter and handle that internally since we know which ps version is core and which is full
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like i've broken the CI - I'm working on a fix, but it's not ready yet
tools/docker/ubuntu16/Dockerfile
Outdated
|
||
RUN apt update -qq && \ | ||
cd / && \ | ||
git clone https://github.com/JamesWTruher/PSScriptAnalyzer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed it should :/
75891d8
to
67ceb40
Compare
67ceb40
to
5c01978
Compare
fcd5f2d
to
14e0fdc
Compare
Add additional verbose statements for debugging
14e0fdc
to
118e0b2
Compare
When simplifying to use only psversion, add back the 'PSV' prolog to configuration
This reverts commit b3018ea.
there's a couple of good suggestions here which I would like to put in a follow-on PR |
@bergmeister - CI problems addressed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some minor comments to be addressed please. What would be good to know is why the pragmas (psv4) needed to be adapted (why was it working before?)
Otherwise it looks good, let;s get it merged after that :-)
$docsPath = Join-Path $projectRoot docs | ||
$markdownDocsPath = Join-Path $docsPath markdown | ||
$outputDocsPath = Join-Path $destinationDir en-US | ||
$requiredVersionOfplatyPS = 0.9 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should update platyPs to 0.12.0 but this can be another PR after that
https://twitter.com/xvorsx/status/1053495983588265991?s=19
$outputDocsPath = Join-Path $destinationDir en-US | ||
$requiredVersionOfplatyPS = 0.9 | ||
#$modInfo = new-object Microsoft.PowerShell.Commands.ModuleSpecification -ArgumentList @{ ModuleName = "platyps"; ModuleVersion = $requiredVersionOfplatyPS} | ||
#if ( $null -eq (Get-Module -ListAvailable -FullyQualifiedName $modInfo)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove commented out code
{ | ||
Write-Verbose -verbose "platyPS not found, installing" | ||
Install-Module -Force -Name platyPS -Scope CurrentUser | ||
# throw "Cannot find required minimum version $requiredVersionOfplatyPS of platyPS. Install via 'Install-Module platyPS'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove commented out code.
try { | ||
$savedModulePath = $env:PSModulePath | ||
$env:PSModulePath = "${testModulePath}{0}${env:PSModulePath}" -f [System.IO.Path]::PathSeparator | ||
$scriptBlock = [scriptblock]::Create("Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -Show Describe") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be OK with showing only the Describe
output but then Pester does not show the summary any more, which we definitely need if we want to avoid scrolling through all test results when running locally. Can we therefore use the Describe,Summary
option please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments to be address please but looks good overall. Can you please comment on why the conditional compilation had to change for WMF4 (why was it working before but not now any more?)?
$outputDocsPath = Join-Path $destinationDir en-US | ||
$requiredVersionOfplatyPS = 0.9 | ||
#$modInfo = new-object Microsoft.PowerShell.Commands.ModuleSpecification -ArgumentList @{ ModuleName = "platyps"; ModuleVersion = $requiredVersionOfplatyPS} | ||
#if ( $null -eq (Get-Module -ListAvailable -FullyQualifiedName $modInfo)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove commented out line
$outputDocsPath = Join-Path $destinationDir en-US | ||
$requiredVersionOfplatyPS = 0.9 | ||
#$modInfo = new-object Microsoft.PowerShell.Commands.ModuleSpecification -ArgumentList @{ ModuleName = "platyps"; ModuleVersion = $requiredVersionOfplatyPS} | ||
#if ( $null -eq (Get-Module -ListAvailable -FullyQualifiedName $modInfo)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove commented out line
{ | ||
Write-Verbose -verbose "platyPS not found, installing" | ||
Install-Module -Force -Name platyPS -Scope CurrentUser | ||
# throw "Cannot find required minimum version $requiredVersionOfplatyPS of platyPS. Install via 'Install-Module platyPS'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove commented out line
try { | ||
$savedModulePath = $env:PSModulePath | ||
$env:PSModulePath = "${testModulePath}{0}${env:PSModulePath}" -f [System.IO.Path]::PathSeparator | ||
$scriptBlock = [scriptblock]::Create("Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -Show Describe") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the Summary
option to -Show
would be useful
$scriptBlock = [scriptblock]::Create("Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -Show Describe") | |
$scriptBlock = [scriptblock]::Create("Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -Show Describe,Summary") |
try { | ||
$savedModulePath = $env:PSModulePath | ||
$env:PSModulePath = "${testModulePath}{0}${env:PSModulePath}" -f [System.IO.Path]::PathSeparator | ||
$scriptBlock = [scriptblock]::Create("Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -Show Describe") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the Describe,Summary
option to -Show
would be useful
$scriptBlock = [scriptblock]::Create("Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -Show Describe") | |
$scriptBlock = [scriptblock]::Create("Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -Show Describe,Summary") |
try { | ||
$savedModulePath = $env:PSModulePath | ||
$env:PSModulePath = "${testModulePath}{0}${env:PSModulePath}" -f [System.IO.Path]::PathSeparator | ||
$scriptBlock = [scriptblock]::Create("Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -Show Describe") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the Describe,Summary
option to -Show
would be useful
$scriptBlock = [scriptblock]::Create("Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -Show Describe") | |
$scriptBlock = [scriptblock]::Create("Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -Show Describe,Summary") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments to be addressed please but looks good overall, GitHub had a glitch, therefore some comments are duplicated. Can you please comment on why the conditional compilation had to change for WMF4 (why was it working before but not now any more?)? After this PR we also need to update ReleaseMaker.psm1
…nalyzer into buildscripts use HEAD due to newer sdk version # Conflicts: # global.json
This is good enough to merge, we plan to have follow up PRs that tweak this and also adapt |
* consolidate build of script analyzer into module Require any 2.1 sdk for building, this way we can build with the same sdk as PowerShell core * Have git ignore vim swap files and the test results file * Only special case linux for the customized rule tests * Update to build scripts. To build for core, simply type ./build, to build all flavors and documentation type ./build -all. You can now run tests as well via ./build -Test. * Modify readme to match new build instructions * Add ubuntu16 docker file to build scripts * change to use psversion rather than analyzerversion because it's really about the version of PS, not the analyzer * Add copyright banners to script and module * Fix repo to point to the official repo * Update appveyor scripts to use new build script * Forcing installation of platyPS if not found when building documentation * Be sure to skip uses of TypeDefinitionAst on both PSV3 and PSV4 * Modified logic to not build full on non-Windows Add additional verbose statements for debugging * fix issue with incorrect build configuration When simplifying to use only psversion, add back the 'PSV' prolog to configuration * reduce build matrix to accellerate CI testing * Revert "reduce build matrix to accellerate CI testing" This reverts commit b3018ea.
PR Summary
In order to actually build script analyzer, you have to run a couple of different scripts if you're going to also build documentation. This PR consolidates everything into a single script
build.ps1
and a modulebuild.psm1
which implements the actions. This is targeting the developer scenario rather than CI usage.The documentation is updated to provide examples of how to use the script.
Additionally, I'm updating the sdk version to 2.1.400 to match PowerShell Core, so you can build both PowerShell Core and Script Analyzer with the same SDK.
PR Checklist
.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
to the beginning of the title and remove the prefix when the PR is ready.