Running our pulumi/pulumi examples on Windows (#3656)

Running our pulumi/pulumi examples on Windows
This commit is contained in:
Paul Stack 2020-01-27 22:54:24 +03:00 committed by GitHub
commit eddbbaf5cd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 351 additions and 156 deletions

View file

@ -1,15 +1,13 @@
version: 1.0.{build}
image: Visual Studio 2017
image: Visual Studio 2019
configuration: Release
platform: x64
clone_folder: '%USERPROFILE%\go\src\github.com\pulumi\pulumi'
branches:
only:
- master
- /release\/.*/
- /v\d*\.\d*\.\d*/
init:
- ps: Install-Product node 8.10 x64
skip_tags: true
environment:
PULUMI_API: https://api.pulumi-staging.io
PULUMI_ACCESS_TOKEN:
@ -18,6 +16,13 @@ environment:
secure: eB7Gfl1GHhz60tH2EEASI7IFsWHDd5SV+kponXwaCSo=
AWS_SECRET_ACCESS_KEY:
secure: T19RJk7Uv3trAChRRDB82OAUDI8k2q9PaSetU7yDFu4aC+MshdwAhTTN/TaPkwl/
AWS_REGION: us-west-2
ARM_LOCATION: "West US 2"
ARM_ENVIRONMENT: public
matrix:
- nodejs_version: "10.15.3"
init:
- ps: Install-Product node $env:nodejs_version x64
install:
- rmdir C:\go /s /q
- appveyor DownloadFile https://dl.google.com/go/go1.13.4.windows-amd64.zip
@ -27,6 +32,8 @@ install:
set PATH=C:\go\bin;%PATH%;%GOPATH%\bin
set PATH=%PATH%;%USERPROFILE%\.yarn\bin
set PulumiRoot=C:\Pulumi
set PATH=%PulumiRoot%\bin;%PATH%
@ -34,9 +41,29 @@ install:
go version
git clone https://github.com/pulumi/scripts.git "%USERPROFILE%\go\src\github.com\pulumi\scripts"
set PATH=%PATH%;C:\Python37-x64\Scripts
pip3 install pyenv-win --target %USERPROFILE%/.pyenv
set PYENV=%USERPROFILE%\.pyenv\pyenv-win
set PATH=%PATH%;%PYENV%\bin;%PYENV%\shims
pip3 install pipenv
set PULUMI_LOCAL_NUGET=C:\Pulumi\nuget
set PULUMI_TEST_OWNER=moolumi
- ps: >-
New-Item -Type Directory "$env:USERPROFILE\go\bin"
build_script:
- cmd: >-
if defined APPVEYOR_PULL_REQUEST_NUMBER ( msbuild /t:AppVeyorPullRequest /v:Detailed build.proj ) else ( msbuild /t:AppVeyorPush /v:Detailed build.proj )
set GO111MODULE=on
go mod tidy
go mod vendor
dotnet msbuild /t:CIBuild /v:Detailed build.proj
test: off

View file

@ -4,139 +4,288 @@
<RepoRootDirectory>$(MSBuildThisFileDirectory)</RepoRootDirectory>
<SdkDirectory>$(RepoRootDirectory)\sdk\</SdkDirectory>
<NodeJSSdkDirectory>$(SdkDirectory)\nodejs\</NodeJSSdkDirectory>
<TestParallelism>10</TestParallelism>
<MSVSVersion>2017</MSVSVersion>
<DotNetSdkDirectory>$(SdkDirectory)\dotnet\</DotNetSdkDirectory>
<PythonSdkDirectory>$(SdkDirectory)\python\</PythonSdkDirectory>
<TestParallelism>20</TestParallelism>
<MSVSVersion>2019</MSVSVersion>
<PulumiRoot Condition="'$(PulumiRoot)' == ''">C:\Pulumi\</PulumiRoot>
<PulumiBin>$(PulumiRoot)\bin</PulumiBin>
</PropertyGroup>
<Target Name="EnsureGoDependencies">
<Exec Command="dep ensure -v"
Condition="Exists('Gopkg.toml')"
WorkingDirectory="$(RepoRootDirectory)" />
<Exec Command="(set GO111MODULE=on) &amp; go mod vendor"
Condition="Exists('go.mod')"
WorkingDirectory="$(RepoRootDirectory)" />
<UsingTask TaskName="ReplaceFileText" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<InputFilename ParameterType="System.String" Required="true" />
<OutputFilename ParameterType="System.String" Required="true" />
<MatchExpression ParameterType="System.String" Required="true" />
<ReplacementText ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
File.WriteAllText(
OutputFilename,
Regex.Replace(File.ReadAllText(InputFilename), MatchExpression, ReplacementText)
);
]]>
</Code>
</Task>
</UsingTask>
<!-- Conventions
Each of the SDKs have their own section in this file and follow the format:
* BuildLanguageSdk
The BuildLangaugeSDK then dependes on a number of subtargets that differ based on the langage we are building. They follow
the structure:
* LanguageDependencies
* LanguageBuild (Required)
* LanguageInstallPackage (Required)
* LanguageInstallPlugin
There may be an additional step for copying packages around.
-->
<!-- This section is where we build and package the DotNet SDK -->
<Target Name="BuildDotNetSDK"
DependsOnTargets="DotNetBuild;DotNetInstallPlugin;CopyNugetPackages">
</Target>
<Target Name="EnsureNodeDependencies">
<Target Name="DotNetBuild">
<Exec Command="&quot;$(MSBuildThisFileDirectory)\scripts\get-version.cmd&quot;" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<PropertyGroup>
<VersionPart>$(Version.Split("-")[0])</VersionPart>
<VersionPrefix>$(VersionPart.Replace("v",""))</VersionPrefix>
</PropertyGroup>
<Exec Command="dotnet build dotnet.sln /p:VersionPrefix=$(VersionPrefix) /p:VersionSuffix=preview"
WorkingDirectory="$(DotNetSdkDirectory)" />
<ItemGroup>
<DotNetPackagesToBuild Include="github.com/pulumi/pulumi/sdk/dotnet/cmd/pulumi-language-dotnet" />
</ItemGroup>
<Exec Command="go install -ldflags &quot;-X github.com/pulumi/pulumi/pkg/version.Version=$(Version)&quot; %(DotNetPackagesToBuild.Identity)" />
</Target>
<Target Name="DotNetInstallPlugin">
<ItemGroup>
<DotNetPackagesToBuild Include="github.com/pulumi/pulumi/sdk/dotnet/cmd/pulumi-language-dotnet" />
</ItemGroup>
<Exec Command="&quot;$(MSBuildThisFileDirectory)\scripts\get-version.cmd&quot;" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags &quot;-X github.com/pulumi/pulumi/pkg/version.Version=$(Version)&quot; %(DotNetPackagesToBuild.Identity)"
EnvironmentVariables="GOBIN=$(PulumiBin)"/>
</Target>
<Target Name="CopyNugetPackages">
<ItemGroup>
<DotNetNupkgFile Include="$(DotNetSdkDirectory)\**\*.nupkg" />
</ItemGroup>
<Copy SourceFiles="@(DotNetNupkgFile)"
DestinationFolder="$(PulumiRoot)\nuget" />
</Target>
<!-- This is where we build and install the Go SDK -->
<Target Name="BuildGoSDK"
DependsOnTargets="GoBuild;GoInstallPlugin">
</Target>
<Target Name="GoBuild">
<Exec Command="&quot;$(MSBuildThisFileDirectory)\scripts\get-version.cmd&quot;" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<ItemGroup>
<GoPackagesToBuild Include="github.com/pulumi/pulumi/sdk/go/pulumi-language-go" />
</ItemGroup>
<Exec Command="go install -ldflags &quot;-X github.com/pulumi/pulumi/pkg/version.Version=$(Version)&quot; %(GoPackagesToBuild.Identity)" />
</Target>
<Target Name="GoInstallPlugin">
<ItemGroup>
<GoPackagesToBuild Include="github.com/pulumi/pulumi/sdk/go/pulumi-language-go" />
</ItemGroup>
<Exec Command="&quot;$(MSBuildThisFileDirectory)\scripts\get-version.cmd&quot;" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags &quot;-X github.com/pulumi/pulumi/pkg/version.Version=$(Version)&quot; %(GoPackagesToBuild.Identity)"
EnvironmentVariables="GOBIN=$(PulumiBin)"/>
</Target>
<!-- This is where we build and install the NodeJS SDK -->
<Target Name="BuildNodeJSSDK"
DependsOnTargets="NodeJSDependencies;NodeJSBuild;NodeJSInstallPlugin;CopyNodeJSPackages">
</Target>
<Target Name="NodeJSDependencies">
<Exec Command="yarn install"
WorkingDirectory="$(NodeJSSdkDirectory)" />
</Target>
<Target Name="TypeScriptCompileNodeSdk">
<Exec Command="&quot;$(MSBuildThisFileDirectory)\scripts\get-version.cmd&quot;" ConsoleToMSBuild="true" Condition="'$(Version)' == ''">
<Target Name="NodeJSBuild">
<Exec Command="&quot;$(MSBuildThisFileDirectory)\scripts\get-version.cmd&quot;" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="yarn run tsc" WorkingDirectory="$(NodeJSSdkDirectory)" />
<Copy SourceFiles="$(NodeJSSdkDirectory)\package.json" DestinationFiles="$(NodeJSSdkDirectory)\bin\package.json" />
<Exec Command="node &quot;$(RepoRootDirectory)\scripts\reversion.js&quot; &quot;$(NodeJSSdkDirectory)\bin\package.json&quot; $(Version)" />
<Exec Command="node &quot;$(RepoRootDirectory)\scripts\reversion.js&quot; &quot;$(NodeJSSdkDirectory)\bin\version.js&quot; $(Version)" />
</Target>
<Target Name="GoCompileNodeSdk">
<ItemGroup>
<GoPackagesToBuild Include="github.com/pulumi/pulumi/sdk/nodejs/cmd/pulumi-language-nodejs" />
</ItemGroup>
<Exec Command="&quot;$(MSBuildThisFileDirectory)\scripts\get-version.cmd&quot;" ConsoleToMSBuild="true" Condition="'$(Version)' == ''">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags &quot;-X github.com/pulumi/pulumi/pkg/version.Version=$(Version)&quot; %(GoPackagesToBuild.Identity)"
EnvironmentVariables="GOBIN=$(PulumiBin)"/>
</Target>
<Target Name="BinplaceNodeSdkProtos">
<!-- Copy Protos -->
<ItemGroup>
<NodeSdkProtos Include="$(NodeJSSdkDirectory)\proto\*.js" />
</ItemGroup>
<Copy SourceFiles="@(NodeSdkProtos)"
DestinationFolder="$(NodeJSSdkDirectory)\bin\proto" />
</Target>
<Target Name="BinPlaceNodeSdkTestData">
<!-- Copy Language Cases -->
<ItemGroup>
<NodeSdkTestDataFiles Include="$(NodeJSSdkDirectory)\tests\runtime\langhost\cases\**\*" />
</ItemGroup>
<Copy SourceFiles="@(NodeSdkTestDataFiles)"
DestinationFolder="$(NodeJSSdkDirectory)\bin\tests\runtime\langhost\cases" />
</Target>
<Target Name="YarnLinkSdk">
<Exec Command="yarn link"
WorkingDirectory="$(NodeJSSdkDirectory)\bin" />
</Target>
<Target Name="BinPlaceNodeSdk"
DependsOnTargets="BinPlaceNodeSdkProtos;BinPlaceNodeSdkTestData;YarnLinkSdk">
<Copy SourceFiles="$(NodeJSSdkDirectory)\dist\pulumi-resource-pulumi-nodejs.cmd" DestinationFolder="$(PulumiBin)" />
</Target>
<Target Name="BuildNodeSdk"
DependsOnTargets="TypeScriptCompileNodeSdk;GoCompileNodeSdk;BinPlaceNodeSdk">
</Target>
<Target Name="BuildGoCmds">
<ItemGroup>
<GoCmdsToBuild Include="github.com/pulumi/pulumi" />
<NodeJSPackagesToBuild Include="github.com/pulumi/pulumi/sdk/nodejs/cmd/pulumi-language-nodejs" />
</ItemGroup>
<Exec Command="go install -ldflags &quot;-X github.com/pulumi/pulumi/pkg/version.Version=$(Version)&quot; %(NodeJSPackagesToBuild.Identity)" />
</Target>
<Target Name="NodeJSInstallPlugin">
<ItemGroup>
<NodeJSDistFiles Include="$(NodeJSSdkDirectory)\dist\*.cmd" />
</ItemGroup>
<Copy SourceFiles="@(NodeJSDistFiles)"
DestinationFolder="$(PulumiBin)\" />
<ItemGroup>
<NodeJSPackagesToBuild Include="github.com/pulumi/pulumi/sdk/nodejs/cmd/pulumi-language-nodejs" />
</ItemGroup>
<Exec Command="&quot;$(MSBuildThisFileDirectory)\scripts\get-version.cmd&quot;" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags &quot;-X github.com/pulumi/pulumi/pkg/version.Version=$(Version)&quot; %(NodeJSPackagesToBuild.Identity)"
EnvironmentVariables="GOBIN=$(PulumiBin)"/>
</Target>
<Target Name="CopyNodeJSPackages">
<MakeDir Directories="$(PulumiRoot)\node_modules\@pulumi\pulumi"/>
<ItemGroup>
<BinFiles Include="$(NodeJSSdkDirectory)\bin\**\*.*" />
</ItemGroup>
<Copy
SourceFiles="@(BinFiles)"
DestinationFiles="@(BinFiles->'$(PulumiRoot)\node_modules\@pulumi\pulumi\%(RecursiveDir)%(Filename)%(Extension)')" />
<ItemGroup>
<YarnFile Include="$(NodeJSSdkDirectory)\yarn.lock" />
</ItemGroup>
<Copy SourceFiles="@(YarnFile)"
DestinationFolder="$(PulumiRoot)\node_modules\@pulumi\pulumi" />
<RemoveDir Directories="$(PulumiRoot)\node_modules\@pulumi\pulumi\node_modules" />
<Exec Command="yarn install --prefer-offline --production &amp;&amp; (yarn unlink > NUL || true) &amp;&amp; yarn link"
WorkingDirectory="$(PulumiRoot)\node_modules\@pulumi\pulumi" />
</Target>
<!-- This is where we build and install the Python SDK -->
<Target Name="BuildPythonSDK"
DependsOnTargets="PythonDependencies;PythonBuild;PythonInstallPlugin">
</Target>
<Target Name="PythonDependencies">
<MakeDir Directories="$(PythonSdkDirectory)\env\src"/>
<Exec Command="pipenv install"
WorkingDirectory="$(PythonSdkDirectory)\env\src" />
</Target>
<Target Name="PythonBuild">
<Exec Command="&quot;$(MSBuildThisFileDirectory)\scripts\get-version.cmd&quot;" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<ItemGroup>
<PythonLibFiles Include="$(PythonSdkDirectory)\lib\**\*.*" />
</ItemGroup>
<Copy
SourceFiles="@(PythonLibFiles)"
DestinationFiles="@(PythonLibFiles->'$(PythonSdkDirectory)\env\src\%(RecursiveDir)%(Filename)%(Extension)')" />
<ReplaceFileText
InputFilename="$(PythonSdkDirectory)\env\src\setup.py"
OutputFilename="$(PythonSdkDirectory)\env\src\setup.py"
MatchExpression="\$\{VERSION\}"
ReplacementText="$(VERSION)" />
<ItemGroup>
<ReadMeFile Include="$(RepoRootDirectory)\README.md" />
</ItemGroup>
<Copy SourceFiles="@(ReadMeFile)"
DestinationFolder="$(PythonSdkDirectory)\env\src" />
<Exec Command="pipenv run python setup.py build bdist_wheel --universal"
WorkingDirectory="$(PythonSdkDirectory)\env\src" />
<ItemGroup>
<PythonPackagesToBuild Include="github.com/pulumi/pulumi/sdk/python/cmd/pulumi-language-python" />
</ItemGroup>
<Exec Command="go install -ldflags &quot;-X github.com/pulumi/pulumi/pkg/version.Version=$(Version)&quot; %(PythonPackagesToBuild.Identity)" />
</Target>
<Target Name="PythonInstallPlugin">
<ItemGroup>
<PythonLanguageExecFiles Include="$(PythonSdkDirectory)\cmd\pulumi-language-python-exec" />
</ItemGroup>
<Copy SourceFiles="@(PythonLanguageExecFiles)"
DestinationFolder="$(PulumiBin)\" />
<ItemGroup>
<PythonDistFiles Include="$(PythonSdkDirectory)\dist\pulumi-resource-pulumi-python.cmd" />
</ItemGroup>
<Copy SourceFiles="@(PythonDistFiles)"
DestinationFolder="$(PulumiBin)\" />
<ItemGroup>
<PythonPackagesToBuild Include="github.com/pulumi/pulumi/sdk/python/cmd/pulumi-language-python" />
</ItemGroup>
<Exec Command="&quot;$(MSBuildThisFileDirectory)\scripts\get-version.cmd&quot;" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags &quot;-X github.com/pulumi/pulumi/pkg/version.Version=$(Version)&quot; %(PythonPackagesToBuild.Identity)"
EnvironmentVariables="GOBIN=$(PulumiBin)"/>
</Target>
<!-- Install the Pulumi SDK -->
<Target Name="InstallPulumiPlugin">
<ItemGroup>
<PulumiPackagesToBuild Include="github.com/pulumi/pulumi" />
</ItemGroup>
<Exec Command="&quot;$(MSBuildThisFileDirectory)\scripts\get-version.cmd&quot;" ConsoleToMSBuild="true" Condition="'$(Version)' == ''">
<Exec Command="&quot;$(MSBuildThisFileDirectory)\scripts\get-version.cmd&quot;" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags &quot;-X github.com/pulumi/pulumi/pkg/version.Version=$(Version)&quot; %(GoCmdsToBuild.Identity)"
EnvironmentVariables="GOBIN=$(PulumiBin)"/>
<Exec Command="go install -ldflags &quot;-X github.com/pulumi/pulumi/pkg/version.Version=$(Version)&quot; %(PulumiPackagesToBuild.Identity)"
EnvironmentVariables="GOBIN=$(PulumiBin)"/>
</Target>
<!-- Build -->
<Target Name="Build"
DependsOnTargets="EnsureGoDependencies;EnsureNodeDependencies;BuildNodeSdk;BuildGoCmds">
DependsOnTargets="BuildDotNetSDK;BuildGoSDK;BuildNodeJSSDK;BuildPythonSDK;InstallPulumiPlugin">
</Target>
<Target Name="IntegrationTest">
<Exec Command="where pulumi-language-nodejs"
IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="WhereLangHostExitCode" />
</Exec>
<Exec Command="where pulumi-resource-pulumi-nodejs.cmd"
IgnoreExitCode="true">
<Output TaskParameter="ExitCode" PropertyName="WhereDynamicProviderExitCode" />
</Exec>
<Error Text="Please add &quot;$(PulumiRoot)\bin&quot; to your path before running integration tests."
Condition="$(WhereLangHostExitCode) != 0 Or $(WhereDynamicProviderExitCode) != 0"/>
<!-- Ignore the exit code (but retain it) so we can kill all the lingering node processes even when go test
fails. Otherwise, the AppVeyor job would hang until it reached the timeout -->
<Exec Command="go test -count=1 -timeout 10m -cover -parallel $(TestParallelism) .\examples"
<!-- Tests -->
<Target Name="Tests">
<Exec Command="go test -v -timeout 40m -cover -parallel $(TestParallelism) .\examples"
IgnoreExitCode="true"
WorkingDirectory="$(RepoRootDirectory)">
<Output TaskParameter="ExitCode" PropertyName="GoTestExitCode" />
<Output TaskParameter="ExitCode" PropertyName="ExamplesTestExitCode" />
</Exec>
<!-- Work around pulumi/pulumi#371 by killing all lingering node.exe processes. Yes, in the limit
this may kill too much, but we assume for now folks hacking on pulumi on windows are not running
additional node.exe processes -->
<Exec Command="taskkill /f /im node.exe"
IgnoreStandardErrorWarningFormat="true"
IgnoreExitCode="true" />
<Error Text="examples tests (.\examples) failed"
Condition="$(ExamplesTestExitCode) != 0"/>
<Error Text="go test failed, exit code: $(GoTestExitCode)"
Condition="'$(GoTestExitCode)' != '0'"/>
<Exec Command="go test -v -timeout 40m -cover -parallel $(TestParallelism) .\tests\integration"
IgnoreExitCode="true"
WorkingDirectory="$(RepoRootDirectory)">
<Output TaskParameter="ExitCode" PropertyName="IntegrationTestExitCode" />
</Exec>
<Error Text="integration tests (.\tests\integration) failed"
Condition="$(IntegrationTestExitCode) != 0"/>
</Target>
<Target Name="Publish">
<Exec Command="&quot;$(RepoRootDirectory)\scripts\publish.cmd" />
</Target>
<Target Name="AppVeyorPush"
DependsOnTargets="Build;Publish;IntegrationTest" />
<Target Name="AppVeyorPullRequest"
DependsOnTargets="Build;IntegrationTest" />
<Target Name="CIBuild"
DependsOnTargets="Build;Tests" />
</Project>

View file

@ -6,7 +6,7 @@ import (
"bytes"
"os"
"os/exec"
"path"
"path/filepath"
"strings"
"testing"
@ -23,7 +23,7 @@ import (
func TestAccMinimal(t *testing.T) {
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "minimal"),
Dir: filepath.Join(getCwd(t), "minimal"),
Config: map[string]string{
"name": "Pulumi",
},
@ -43,7 +43,7 @@ func TestAccMinimal(t *testing.T) {
func TestAccMinimal_withLocalState(t *testing.T) {
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "minimal"),
Dir: filepath.Join(getCwd(t), "minimal"),
Config: map[string]string{
"name": "Pulumi",
},
@ -64,7 +64,7 @@ func TestAccMinimal_withLocalState(t *testing.T) {
func TestAccDynamicProviderSimple(t *testing.T) {
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "dynamic-provider/simple"),
Dir: filepath.Join(getCwd(t), "dynamic-provider/simple"),
Config: map[string]string{
"simple:config:w": "1",
"simple:config:x": "1",
@ -78,7 +78,7 @@ func TestAccDynamicProviderSimple(t *testing.T) {
func TestAccDynamicProviderSimple_withLocalState(t *testing.T) {
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "dynamic-provider/simple"),
Dir: filepath.Join(getCwd(t), "dynamic-provider/simple"),
Config: map[string]string{
"simple:config:w": "1",
"simple:config:x": "1",
@ -93,7 +93,7 @@ func TestAccDynamicProviderSimple_withLocalState(t *testing.T) {
func TestAccDynamicProviderClassWithComments(t *testing.T) {
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "dynamic-provider/class-with-comments"),
Dir: filepath.Join(getCwd(t), "dynamic-provider/class-with-comments"),
})
integration.ProgramTest(t, &test)
@ -102,7 +102,7 @@ func TestAccDynamicProviderClassWithComments(t *testing.T) {
func TestAccDynamicProviderClassWithComments_withLocalState(t *testing.T) {
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "dynamic-provider/class-with-comments"),
Dir: filepath.Join(getCwd(t), "dynamic-provider/class-with-comments"),
CloudURL: "file://~",
})
@ -112,7 +112,7 @@ func TestAccDynamicProviderClassWithComments_withLocalState(t *testing.T) {
func TestAccDynamicProviderMultipleTurns(t *testing.T) {
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "dynamic-provider/multiple-turns"),
Dir: filepath.Join(getCwd(t), "dynamic-provider/multiple-turns"),
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
for _, res := range stackInfo.Deployment.Resources {
if !providers.IsProviderType(res.Type) && res.Parent == "" {
@ -129,7 +129,7 @@ func TestAccDynamicProviderMultipleTurns(t *testing.T) {
func TestAccDynamicProviderMultipleTurns_withLocalState(t *testing.T) {
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "dynamic-provider/multiple-turns"),
Dir: filepath.Join(getCwd(t), "dynamic-provider/multiple-turns"),
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
for _, res := range stackInfo.Deployment.Resources {
if !providers.IsProviderType(res.Type) && res.Parent == "" {
@ -147,7 +147,7 @@ func TestAccDynamicProviderMultipleTurns_withLocalState(t *testing.T) {
func TestAccDynamicProviderMultipleTurns2(t *testing.T) {
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "dynamic-provider/multiple-turns-2"),
Dir: filepath.Join(getCwd(t), "dynamic-provider/multiple-turns-2"),
})
integration.ProgramTest(t, &test)
@ -156,7 +156,7 @@ func TestAccDynamicProviderMultipleTurns2(t *testing.T) {
func TestAccDynamicProviderMultipleTurns2_withLocalState(t *testing.T) {
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "dynamic-provider/multiple-turns-2"),
Dir: filepath.Join(getCwd(t), "dynamic-provider/multiple-turns-2"),
CloudURL: "file://~",
})
@ -166,7 +166,7 @@ func TestAccDynamicProviderMultipleTurns2_withLocalState(t *testing.T) {
func TestAccDynamicProviderDerivedInputs(t *testing.T) {
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "dynamic-provider/derived-inputs"),
Dir: filepath.Join(getCwd(t), "dynamic-provider/derived-inputs"),
})
integration.ProgramTest(t, &test)
@ -175,7 +175,7 @@ func TestAccDynamicProviderDerivedInputs(t *testing.T) {
func TestAccDynamicProviderDerivedInputs_withLocalState(t *testing.T) {
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "dynamic-provider/derived-inputs"),
Dir: filepath.Join(getCwd(t), "dynamic-provider/derived-inputs"),
CloudURL: "file://~",
})
@ -186,7 +186,7 @@ func TestAccFormattable(t *testing.T) {
var formattableStdout, formattableStderr bytes.Buffer
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "formattable"),
Dir: filepath.Join(getCwd(t), "formattable"),
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
// Note that we're abusing this hook to validate stdout. We don't actually care about the checkpoint.
stdout := formattableStdout.String()
@ -203,7 +203,7 @@ func TestAccFormattable_withLocalState(t *testing.T) {
var formattableStdout, formattableStderr bytes.Buffer
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "formattable"),
Dir: filepath.Join(getCwd(t), "formattable"),
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
// Note that we're abusing this hook to validate stdout. We don't actually care about the checkpoint.
stdout := formattableStdout.String()
@ -220,7 +220,7 @@ func TestAccFormattable_withLocalState(t *testing.T) {
func TestAccSecrets(t *testing.T) {
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "secrets"),
Dir: filepath.Join(getCwd(t), "secrets"),
Config: map[string]string{
"message": "plaintext message",
},
@ -310,7 +310,7 @@ func TestAccNodeCompatTests(t *testing.T) {
skipIfNotNode610(t)
test := getBaseOptions().
With(integration.ProgramTestOptions{
Dir: path.Join(getCwd(t), "compat/v0.10.0/minimal"),
Dir: filepath.Join(getCwd(t), "compat/v0.10.0/minimal"),
Config: map[string]string{
"name": "Pulumi",
},

View file

@ -51,13 +51,13 @@ func getPwdMain(root, main string) (string, string, error) {
main = "."
} else {
// The path must be relative from the package root.
if filepath.IsAbs(main) {
if path.IsAbs(main) {
return "", "", errors.New("project 'main' must be a relative path")
}
// Check that main is a subdirectory.
cleanPwd := filepath.Clean(pwd)
main = filepath.Clean(path.Join(cleanPwd, main))
main = filepath.Clean(filepath.Join(cleanPwd, main))
if !strings.HasPrefix(main, cleanPwd) {
return "", "", errors.New("project 'main' must be a subfolder")
}

View file

@ -26,7 +26,6 @@ import (
"os"
"os/exec"
"os/user"
"path"
"path/filepath"
"regexp"
"strconv"
@ -609,7 +608,7 @@ func newProgramTester(t *testing.T, opts *ProgramTestOptions) *programTester {
return &programTester{
t: t,
opts: opts,
eventLog: path.Join(os.TempDir(), string(stackName)+"-events.json"),
eventLog: filepath.Join(os.TempDir(), string(stackName)+"-events.json"),
maxStepTries: maxStepTries,
}
}
@ -906,7 +905,7 @@ func (pt *programTester) testLifeCycleInitialize(dir string) error {
// If RelativeWorkDir is specified, apply that relative to the temp folder for use as working directory during tests.
if pt.opts.RelativeWorkDir != "" {
dir = path.Join(dir, pt.opts.RelativeWorkDir)
dir = filepath.Join(dir, pt.opts.RelativeWorkDir)
}
// Set the default target Pulumi API if not overridden in options.
@ -1280,7 +1279,7 @@ func (pt *programTester) performExtraRuntimeValidation(
if err != nil {
return err
}
fileName := path.Join(tempDir, "stack.json")
fileName := filepath.Join(tempDir, "stack.json")
// Invoke `pulumi stack export`
if err = pt.runPulumiCommand("pulumi-export",
@ -1599,7 +1598,7 @@ func (pt *programTester) installPipPackageDeps(cwd string) error {
for _, dep := range pt.opts.Dependencies {
// If the given filepath isn't absolute, make it absolute. We're about to pass it to pipenv and pipenv is
// operating inside of a random folder in /tmp.
if !path.IsAbs(dep) {
if !filepath.IsAbs(dep) {
dep, err = filepath.Abs(dep)
if err != nil {
return err

View file

@ -3,7 +3,6 @@
package ints
import (
"path"
"path/filepath"
"testing"
@ -22,15 +21,15 @@ var dirs = []string{
// pointing to the old URN to ensure the resource is preserved across the update.
func TestNodejsAliases(t *testing.T) {
for _, dir := range dirs {
d := path.Join("nodejs", dir)
d := filepath.Join("nodejs", dir)
t.Run(d, func(t *testing.T) {
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: path.Join(d, "step1"),
Dir: filepath.Join(d, "step1"),
Dependencies: []string{"@pulumi/pulumi"},
Quick: true,
EditDirs: []integration.EditDir{
{
Dir: path.Join(d, "step2"),
Dir: filepath.Join(d, "step2"),
Additive: true,
ExpectNoChanges: true,
},
@ -42,17 +41,17 @@ func TestNodejsAliases(t *testing.T) {
func TestPythonAliases(t *testing.T) {
for _, dir := range dirs {
d := path.Join("python", dir)
d := filepath.Join("python", dir)
t.Run(d, func(t *testing.T) {
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: path.Join(d, "step1"),
Dir: filepath.Join(d, "step1"),
Dependencies: []string{
filepath.Join("..", "..", "..", "sdk", "python", "env", "src"),
},
Quick: true,
EditDirs: []integration.EditDir{
{
Dir: path.Join(d, "step2"),
Dir: filepath.Join(d, "step2"),
Additive: true,
ExpectNoChanges: true,
},
@ -64,15 +63,15 @@ func TestPythonAliases(t *testing.T) {
func TestDotNetAliases(t *testing.T) {
for _, dir := range dirs {
d := path.Join("dotnet", dir)
d := filepath.Join("dotnet", dir)
t.Run(d, func(t *testing.T) {
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: path.Join(d, "step1"),
Dir: filepath.Join(d, "step1"),
Dependencies: []string{"Pulumi"},
Quick: true,
EditDirs: []integration.EditDir{
{
Dir: path.Join(d, "step2"),
Dir: filepath.Join(d, "step2"),
Additive: true,
ExpectNoChanges: true,
},

View file

@ -5,8 +5,7 @@ import * as crypto from "crypto";
import * as os from "os";
import * as fs from "fs";
import * as path from "path";
import { Config } from "@pulumi/pulumi";
import { serializeFunction } from "@pulumi/pulumi/runtime"
import * as pulumi from "@pulumi/pulumi";
function tempDirName(prefix: string) {
const b = crypto.randomBytes(4);
@ -15,15 +14,15 @@ function tempDirName(prefix: string) {
(async function() {
// Just test that basic config works.
const config = new Config();
const config = new pulumi.Config();
const outsideCapture = await serializeFunction(() => {
const outsideCapture = await pulumi.runtime.serializeFunction(() => {
assert("it works" == config.require("value"));
console.log("outside capture works")
});
const insideCapture = await serializeFunction(() => {
const config = new Config();
const insideCapture = await pulumi.runtime.serializeFunction(() => {
const config = new pulumi.Config();
assert("it works" == config.require("value"));
console.log("inside capture works")
});
@ -43,4 +42,4 @@ function tempDirName(prefix: string) {
require(outsideDir).handler();
require(insideDir).handler();
})()
})()

View file

@ -6,14 +6,13 @@ import (
"bytes"
"fmt"
"os"
"path"
"path/filepath"
"runtime"
"strings"
"testing"
"time"
"github.com/pulumi/pulumi/pkg/util/contract"
"github.com/stretchr/testify/assert"
"github.com/pulumi/pulumi/pkg/apitype"
@ -26,6 +25,8 @@ import (
"github.com/pulumi/pulumi/pkg/workspace"
)
const WindowsOS = "windows"
// assertPerfBenchmark implements the integration.TestStatsReporter interface, and reports test
// failures when a scenario exceeds the provided threshold.
type assertPerfBenchmark struct {
@ -70,7 +71,7 @@ func TestEmptyPython(t *testing.T) {
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: filepath.Join("empty", "python"),
Dependencies: []string{
path.Join("..", "..", "sdk", "python", "env", "src"),
filepath.Join("..", "..", "sdk", "python", "env", "src"),
},
Quick: true,
})
@ -79,9 +80,8 @@ func TestEmptyPython(t *testing.T) {
// TestEmptyGo simply tests that we can build and run an empty Go project.
func TestEmptyGo(t *testing.T) {
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: filepath.Join("empty", "go"),
Quick: true,
RunBuild: true,
Dir: filepath.Join("empty", "go"),
Quick: true,
})
}
@ -248,7 +248,7 @@ func TestStackTagValidation(t *testing.T) {
prefix = prefix + prefix + prefix + prefix // 416 + the current Pulumi.yaml's description
// Change the contents of the Description property of Pulumi.yaml.
yamlPath := path.Join(e.CWD, "Pulumi.yaml")
yamlPath := filepath.Join(e.CWD, "Pulumi.yaml")
err := integration.ReplaceInFile("description: ", "description: "+prefix, yamlPath)
assert.NoError(t, err)
@ -926,6 +926,9 @@ func TestConfigBasicNodeJS(t *testing.T) {
}
func TestConfigCaptureNodeJS(t *testing.T) {
if runtime.GOOS == WindowsOS {
t.Skip("Temporarily skipping test on Windows - pulumi/pulumi#3811")
}
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: filepath.Join("config_capture_e2e", "nodejs"),
Dependencies: []string{"@pulumi/pulumi"},
@ -950,7 +953,7 @@ func TestConfigBasicPython(t *testing.T) {
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: filepath.Join("config_basic", "python"),
Dependencies: []string{
path.Join("..", "..", "sdk", "python", "env", "src"),
filepath.Join("..", "..", "sdk", "python", "env", "src"),
},
Quick: true,
Config: map[string]string{
@ -999,7 +1002,6 @@ func TestConfigBasicGo(t *testing.T) {
{Key: "tokens[0]", Value: "shh", Path: true, Secret: true},
{Key: "foo.bar", Value: "don't tell", Path: true, Secret: true},
},
RunBuild: true,
})
}
@ -1096,6 +1098,9 @@ func TestGetCreated(t *testing.T) {
// Tests that stack references work in Node.
func TestStackReferenceNodeJS(t *testing.T) {
if runtime.GOOS == WindowsOS {
t.Skip("Temporarily skipping test on Windows - pulumi/pulumi#3811")
}
if owner := os.Getenv("PULUMI_TEST_OWNER"); owner == "" {
t.Skipf("Skipping: PULUMI_TEST_OWNER is not set")
}
@ -1122,6 +1127,9 @@ func TestStackReferenceNodeJS(t *testing.T) {
}
func TestStackReferencePython(t *testing.T) {
if runtime.GOOS == WindowsOS {
t.Skip("Temporarily skipping test on Windows - pulumi/pulumi#3811")
}
if owner := os.Getenv("PULUMI_TEST_OWNER"); owner == "" {
t.Skipf("Skipping: PULUMI_TEST_OWNER is not set")
}
@ -1141,6 +1149,9 @@ func TestStackReferencePython(t *testing.T) {
// Tests that stack references work in .NET.
func TestStackReferenceDotnet(t *testing.T) {
if runtime.GOOS == WindowsOS {
t.Skip("Temporarily skipping test on Windows - pulumi/pulumi#3811")
}
if owner := os.Getenv("PULUMI_TEST_OWNER"); owner == "" {
t.Skipf("Skipping: PULUMI_TEST_OWNER is not set")
}
@ -1175,9 +1186,9 @@ func TestPython3NotInstalled(t *testing.T) {
"error: Failed to locate any of %q on your PATH. Have you installed Python 3.6 or greater?",
[]string{badPython})
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: path.Join("empty", "python"),
Dir: filepath.Join("empty", "python"),
Dependencies: []string{
path.Join("..", "..", "sdk", "python", "env", "src"),
filepath.Join("..", "..", "sdk", "python", "env", "src"),
},
Quick: true,
Env: []string{
@ -1206,11 +1217,14 @@ func TestProviderSecretConfig(t *testing.T) {
// Tests dynamic provider in Python.
func TestDynamicPython(t *testing.T) {
if runtime.GOOS == WindowsOS {
t.Skip("Temporarily skipping test on Windows - pulumi/pulumi#3811")
}
var randomVal string
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: filepath.Join("dynamic", "python"),
Dependencies: []string{
path.Join("..", "..", "sdk", "python", "env", "src"),
filepath.Join("..", "..", "sdk", "python", "env", "src"),
},
ExtraRuntimeValidation: func(t *testing.T, stack integration.RuntimeValidationStackInfo) {
randomVal = stack.Outputs["random_val"].(string)
@ -1253,6 +1267,9 @@ func TestResourceWithSecretSerialization(t *testing.T) {
}
func TestStackReferenceSecretsNodejs(t *testing.T) {
if runtime.GOOS == WindowsOS {
t.Skip("Temporarily skipping test on Windows - pulumi/pulumi#3811")
}
owner := os.Getenv("PULUMI_TEST_OWNER")
if owner == "" {
t.Skipf("Skipping: PULUMI_TEST_OWNER is not set")
@ -1261,7 +1278,7 @@ func TestStackReferenceSecretsNodejs(t *testing.T) {
d := "stack_reference_secrets"
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: path.Join(d, "nodejs", "step1"),
Dir: filepath.Join(d, "nodejs", "step1"),
Dependencies: []string{"@pulumi/pulumi"},
Config: map[string]string{
"org": owner,
@ -1269,7 +1286,7 @@ func TestStackReferenceSecretsNodejs(t *testing.T) {
Quick: true,
EditDirs: []integration.EditDir{
{
Dir: path.Join(d, "nodejs", "step2"),
Dir: filepath.Join(d, "nodejs", "step2"),
Additive: true,
ExpectNoChanges: true,
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
@ -1286,6 +1303,9 @@ func TestStackReferenceSecretsNodejs(t *testing.T) {
}
func TestStackReferenceSecretsDotnet(t *testing.T) {
if runtime.GOOS == WindowsOS {
t.Skip("Temporarily skipping test on Windows - pulumi/pulumi#3811")
}
owner := os.Getenv("PULUMI_TEST_OWNER")
if owner == "" {
t.Skipf("Skipping: PULUMI_TEST_OWNER is not set")
@ -1294,7 +1314,7 @@ func TestStackReferenceSecretsDotnet(t *testing.T) {
d := "stack_reference_secrets"
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: path.Join(d, "dotnet", "step1"),
Dir: filepath.Join(d, "dotnet", "step1"),
Dependencies: []string{"Pulumi"},
Config: map[string]string{
"org": owner,
@ -1302,7 +1322,7 @@ func TestStackReferenceSecretsDotnet(t *testing.T) {
Quick: true,
EditDirs: []integration.EditDir{
{
Dir: path.Join(d, "dotnet", "step2"),
Dir: filepath.Join(d, "dotnet", "step2"),
Additive: true,
ExpectNoChanges: true,
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
@ -1367,10 +1387,13 @@ func TestPartialValuesNode(t *testing.T) {
}
func TestPartialValuesPython(t *testing.T) {
if runtime.GOOS == WindowsOS {
t.Skip("Temporarily skipping test on Windows - pulumi/pulumi#3811")
}
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: filepath.Join("partial_values", "python"),
Dependencies: []string{
path.Join("..", "..", "sdk", "python", "env", "src"),
filepath.Join("..", "..", "sdk", "python", "env", "src"),
},
AllowEmptyPreviewChanges: true,
})

View file

@ -3,7 +3,6 @@
package ints
import (
"path"
"path/filepath"
"testing"
@ -20,7 +19,7 @@ var dirs = []string{
func TestNodejsTransformations(t *testing.T) {
for _, dir := range dirs {
d := path.Join("nodejs", dir)
d := filepath.Join("nodejs", dir)
t.Run(d, func(t *testing.T) {
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: d,
@ -34,7 +33,7 @@ func TestNodejsTransformations(t *testing.T) {
func TestPythonTransformations(t *testing.T) {
for _, dir := range dirs {
d := path.Join("python", dir)
d := filepath.Join("python", dir)
t.Run(d, func(t *testing.T) {
integration.ProgramTest(t, &integration.ProgramTestOptions{
Dir: d,