Skip to content

Have build script add dependent modules (PSSA & Plaster) #1239

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

Merged
merged 9 commits into from
Mar 23, 2018

Conversation

TylerLeonhardt
Copy link
Member

@TylerLeonhardt TylerLeonhardt commented Mar 21, 2018

This will add PSSA and Plaster to our build so that the vsix AppVeyor spits out should be "release quality"

This vsix is a great example:
https://ci.appveyor.com/project/PowerShell/vscode-powershell/build/artifacts

@TylerLeonhardt TylerLeonhardt changed the title WIP: Have PSSA and Plaster added to build script Have build script add dependent modules (PSSA & Plaster) Mar 21, 2018
Copy link
Contributor

@rkeithhill rkeithhill left a comment

Choose a reason for hiding this comment

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

LGTM

@rkeithhill
Copy link
Contributor

How about the PowerShellEditorServices.Commands? Does it get copied elsewhere?

@TylerLeonhardt
Copy link
Member Author

I don't have that in my 1.6.0 modules folder? Where did you get that from?

@rkeithhill
Copy link
Contributor

OK that is weird. It is another module inside the PowerShellEditorServices folder.

@TylerLeonhardt
Copy link
Member Author

@rkeithhill yeah just checked. That's inside the PowerShellEditorServices folder so it will be included in the vsix that this change generates 😄

@rjmholt
Copy link
Contributor

rjmholt commented Mar 22, 2018

Looks like Save-Module has minimum and maximum version parameters, which is perfect -- so I'm thinking here would be the right place for us to import some json config file and have a project-wide module version specification.

This looks good to go to me!

@TylerLeonhardt
Copy link
Member Author

TylerLeonhardt commented Mar 22, 2018

@rjmholt Added a modules.json file that includes all of our PowerShell module dependencies that we grab with Save-Module.

Note, since PowerShellGet doesn't have a concept of exclusive maximum versions I just put a very high 1.X version to account for any breaking changes that might come in a 2.0.

@rjmholt
Copy link
Contributor

rjmholt commented Mar 22, 2018

Looks like -AllowPrerelease isn't supported by AppVeyor's version of Save-Module

@TylerLeonhardt
Copy link
Member Author

Because their versions of PowerShell don't have latest version of PowerShellGet. :(

@rjmholt
Copy link
Contributor

rjmholt commented Mar 22, 2018

Maybe

$params= @{
   <supportedParams> = <values>
}
if ((Get-Command "Save-Module").Parameters.ContainsKey("AllowPrerelease"))
{
    $params += @{ "AllowPrerelease" = $_.Value.AllowPrerelease }
}

appveyor.yml Outdated

build_script:
- ps: Invoke-Build
- powershell.exe -c "Invoke-Build"
Copy link
Member Author

Choose a reason for hiding this comment

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

have to do this because of updating PowerShellGet

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we be more explicit here? (e.g. -Command instead of -c)

@TylerLeonhardt
Copy link
Member Author

Ok, now the builds will update PowerShellGet and save the modules correctly. Can I get another sign off?

.travis.yml Outdated
- sudo powershell -c "Install-Module PowerShellGet -Force"
- powershell -File build/travis.ps1
Copy link
Contributor

Choose a reason for hiding this comment

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

Does -File correctly report exit codes now? At one time it didn't.

Copy link
Member Author

Choose a reason for hiding this comment

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

hmm not sure, I was just adding the install-module above it. Wasn't really focusing on the travis build script itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just tried pwsh in Windows 10:


Name                           Value
----                           -----
PSVersion                      6.0.1
PSEdition                      Core
GitCommitId                    v6.0.1-289-g18d0a0bcbd436b11611ec13f5b2b4b290e58b542
OS                             Microsoft Windows 10.0.16299
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Writing bad.ps1 as:

throw "Bad!"

Gives:

PS1> pwsh -File .\bad.ps1
Bad!
At C:\Users\roholt\bad.ps1:1 char:1
+ throw "Bad!"
+ ~~~~~~~~~~~~
+ CategoryInfo          : OperationStopped: (Bad!:String) [], RuntimeException
+ FullyQualifiedErrorId : Bad!

PS1> $LASTEXITCODE
1

Changing bad.ps1 to:

exit 1234

gives me:

PS1> pwsh -File .\bad.ps1

PS1> $LASTEXITCODE
1234

Copy link
Member Author

Choose a reason for hiding this comment

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

huh. Interesting.

Copy link
Contributor

Choose a reason for hiding this comment

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

Cool. Looks like it got fixed somewhere along the way. I just tested in 5.1 and it works there too. See Chris Oldwood's comment on this blog post - https://blogs.msdn.microsoft.com/powershell/2006/10/14/windows-powershell-exit-codes/

That is the behavior I remember.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good to know! Thanks for that, @rkeithhill.

@@ -63,6 +65,20 @@ task Restore -If { "Restore" -in $BuildTask -or !(Test-Path "./node_modules") }
exec { & npm install $logLevelParam }
}

task RestorePowerShellModules -If { -not (Test-Path "$PSScriptRoot/modules/Plaster") } {
$modules = Get-Content -Raw "./modules.json" | ConvertFrom-Json
Copy link
Collaborator

Choose a reason for hiding this comment

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

Quotes aren't needed here, but nbd.

Copy link
Member Author

Choose a reason for hiding this comment

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

added $PSScriptRoot

appveyor.yml Outdated

build_script:
- ps: Invoke-Build
- powershell.exe -c "Invoke-Build"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we be more explicit here? (e.g. -Command instead of -c)

@TylerLeonhardt TylerLeonhardt merged commit f1866cc into PowerShell:master Mar 23, 2018
@TylerLeonhardt TylerLeonhardt deleted the appveyor-full-vsix branch March 23, 2018 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants