pulumi/build.proj

347 lines
15 KiB
Plaintext
Raw Normal View History

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<RepoRootDirectory>$(MSBuildThisFileDirectory)</RepoRootDirectory>
<PkgDirectory>$(RepoRootDirectory)\pkg\</PkgDirectory>
<TestsDirectory>$(RepoRootDirectory)\tests\</TestsDirectory>
<SdkDirectory>$(RepoRootDirectory)\sdk\</SdkDirectory>
<NodeJSSdkDirectory>$(SdkDirectory)\nodejs\</NodeJSSdkDirectory>
<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>
<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="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/v2/dotnet/cmd/pulumi-language-dotnet" />
</ItemGroup>
<Exec Command="go install -ldflags &quot;-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=$(Version)&quot; %(DotNetPackagesToBuild.Identity)"
WorkingDirectory="$(SdkDirectory)"/>
</Target>
<Target Name="DotNetInstallPlugin">
<ItemGroup>
<DotNetPackagesToBuild Include="github.com/pulumi/pulumi/sdk/v2/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/sdk/v2/go/common/version.Version=$(Version)&quot; %(DotNetPackagesToBuild.Identity)"
EnvironmentVariables="GOBIN=$(PulumiBin)"
WorkingDirectory="$(SdkDirectory)"/>
</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/v2/go/pulumi-language-go" />
</ItemGroup>
<Exec Command="go install -ldflags &quot;-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=$(Version)&quot; %(GoPackagesToBuild.Identity)"
WorkingDirectory="$(SdkDirectory)"/>
</Target>
<Target Name="GoInstallPlugin">
<ItemGroup>
<GoPackagesToBuild Include="github.com/pulumi/pulumi/sdk/v2/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/sdk/v2/go/common/version.Version=$(Version)&quot; %(GoPackagesToBuild.Identity)"
EnvironmentVariables="GOBIN=$(PulumiBin)"
WorkingDirectory="$(SdkDirectory)"/>
</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="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)" />
<!-- Copy Protos -->
<ItemGroup>
<NodeSdkProtos Include="$(NodeJSSdkDirectory)\proto\*.js" />
</ItemGroup>
<Copy SourceFiles="@(NodeSdkProtos)"
DestinationFolder="$(NodeJSSdkDirectory)\bin\proto" />
<!-- Copy Language Cases -->
<ItemGroup>
<NodeSdkTestDataFiles Include="$(NodeJSSdkDirectory)\tests\runtime\langhost\cases\**\*" />
</ItemGroup>
<Copy SourceFiles="@(NodeSdkTestDataFiles)"
DestinationFolder="$(NodeJSSdkDirectory)\bin\tests\runtime\langhost\cases" />
<ItemGroup>
<NodeJSPackagesToBuild Include="github.com/pulumi/pulumi/sdk/v2/nodejs/cmd/pulumi-language-nodejs" />
</ItemGroup>
<Exec Command="go install -ldflags &quot;-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=$(Version)&quot; %(NodeJSPackagesToBuild.Identity)"
WorkingDirectory="$(SdkDirectory)"/>
</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/v2/version.Version=$(Version)&quot; %(NodeJSPackagesToBuild.Identity)"
EnvironmentVariables="GOBIN=$(PulumiBin)"
WorkingDirectory="$(SdkDirectory)"/>
</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 --python 3.7 install --dev"
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/v2/python/cmd/pulumi-language-python" />
</ItemGroup>
<Exec Command="go install -ldflags &quot;-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=$(Version)&quot; %(PythonPackagesToBuild.Identity)"
WorkingDirectory="$(SdkDirectory)"/>
</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/v2/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/sdk/v2/go/common/version.Version=$(Version)&quot; %(PythonPackagesToBuild.Identity)"
EnvironmentVariables="GOBIN=$(PulumiBin)"
WorkingDirectory="$(SdkDirectory)"/>
</Target>
<!-- Install the Pulumi SDK -->
<Target Name="InstallPulumiPlugin">
<ItemGroup>
<PulumiPackagesToBuild Include="github.com/pulumi/pulumi/pkg/v2/cmd/pulumi" />
</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/v2/version.Version=$(Version)&quot; %(PulumiPackagesToBuild.Identity)"
EnvironmentVariables="GOBIN=$(PulumiBin)"
WorkingDirectory="$(PkgDirectory)"/>
</Target>
<!-- Build -->
<Target Name="Build"
DependsOnTargets="BuildDotNetSDK;BuildGoSDK;BuildNodeJSSDK;BuildPythonSDK;InstallPulumiPlugin">
</Target>
<!-- Release Build
This is used to create the dependencies required for shipping the binary to the end user.
In the old scripts `BuildNodeJSSDK` was called `BuildNodeSdk` and included tasks for
* TypeScriptCompileNodeSdk (now called NodeJSBuild)
* GoCompileNodeSdk (now called NodeJSBuild)
* BinPlaceNodeSdk (included as part of NodeJSBuild)
The old task `BuildGoCmds` has now been renamed to `InstallPulumiPlugin`
-->
<Target Name="ReleaseBuild"
DependsOnTargets="BuildNodeJSSDK;InstallPulumiPlugin">
</Target>
Initial support for remote component construction. (#5280) These changes add initial support for the construction of remote components. For now, this support is limited to the NodeJS SDK; follow-up changes will implement support for the other SDKs. Remote components are component resources that are constructed and managed by plugins rather than by Pulumi programs. In this sense, they are a bit like cloud resources, and are supported by the same distribution and plugin loading mechanisms and described by the same schema system. The construction of a remote component is initiated by a `RegisterResourceRequest` with the new `remote` field set to `true`. When the resource monitor receives such a request, it loads the plugin that implements the component resource and calls the `Construct` method added to the resource provider interface as part of these changes. This method accepts the information necessary to construct the component and its children: the component's name, type, resource options, inputs, and input dependencies. It is responsible for dispatching to the appropriate component factory to create the component, then returning its URN, resolved output properties, and output property dependencies. The dependency information is necessary to support features such as delete-before-replace, which rely on precise dependency information for custom resources. These changes also add initial support for more conveniently implementing resource providers in NodeJS. The interface used to implement such a provider is similar to the dynamic provider interface (and may be unified with that interface in the future). An example of a NodeJS program constructing a remote component resource also implemented in NodeJS can be found in `tests/construct_component/nodejs`. This is the core of #2430.
2020-09-08 04:33:55 +02:00
<!-- This is where we build and install the NodeJS SDK -->
<Target Name="BuildTests"
DependsOnTargets="TestDependencies;TestBuild">
</Target>
<Target Name="TestDependencies">
<Exec Command="yarn install"
WorkingDirectory="$(TestsDirectory)\integration\construct_component\testcomponent" />
<Exec Command="yarn link @pulumi/pulumi"
WorkingDirectory="$(TestsDirectory)\integration\construct_component\testcomponent" />
</Target>
<Target Name="TestBuild">
<Exec Command="yarn run tsc" WorkingDirectory="$(TestsDirectory)\integration\construct_component\testcomponent" />
</Target>
<!-- Tests -->
Initial support for remote component construction. (#5280) These changes add initial support for the construction of remote components. For now, this support is limited to the NodeJS SDK; follow-up changes will implement support for the other SDKs. Remote components are component resources that are constructed and managed by plugins rather than by Pulumi programs. In this sense, they are a bit like cloud resources, and are supported by the same distribution and plugin loading mechanisms and described by the same schema system. The construction of a remote component is initiated by a `RegisterResourceRequest` with the new `remote` field set to `true`. When the resource monitor receives such a request, it loads the plugin that implements the component resource and calls the `Construct` method added to the resource provider interface as part of these changes. This method accepts the information necessary to construct the component and its children: the component's name, type, resource options, inputs, and input dependencies. It is responsible for dispatching to the appropriate component factory to create the component, then returning its URN, resolved output properties, and output property dependencies. The dependency information is necessary to support features such as delete-before-replace, which rely on precise dependency information for custom resources. These changes also add initial support for more conveniently implementing resource providers in NodeJS. The interface used to implement such a provider is similar to the dynamic provider interface (and may be unified with that interface in the future). An example of a NodeJS program constructing a remote component resource also implemented in NodeJS can be found in `tests/construct_component/nodejs`. This is the core of #2430.
2020-09-08 04:33:55 +02:00
<Target Name="Tests"
DependsOnTargets="BuildTests">
<Exec Command="go test -v -timeout 5m -parallel $(TestParallelism) .\backend\..."
IgnoreExitCode="true"
WorkingDirectory="$(PkgDirectory)">
<Output TaskParameter="ExitCode" PropertyName="BackendTestsExitCode" />
</Exec>
<Error Text="backend tests (.\pkg\backend) failed"
Condition="$(BackendTestsExitCode) != 0"/>
<Exec Command="go test -v -timeout 40m -cover -parallel $(TestParallelism) .\examples"
IgnoreExitCode="true"
WorkingDirectory="$(TestsDirectory)">
<Output TaskParameter="ExitCode" PropertyName="ExamplesTestExitCode" />
2018-02-20 03:59:55 +01:00
</Exec>
<Error Text="examples tests (.\tests\examples) failed"
Condition="$(ExamplesTestExitCode) != 0"/>
<Exec Command="go test -v -timeout 40m -cover -parallel $(TestParallelism) -tags=all .\integration"
IgnoreExitCode="true"
WorkingDirectory="$(TestsDirectory)">
<Output TaskParameter="ExitCode" PropertyName="IntegrationTestExitCode" />
</Exec>
<Error Text="integration tests (.\tests\integration) failed"
Condition="$(IntegrationTestExitCode) != 0"/>
</Target>
<Target Name="Publish">
2020-03-26 21:29:15 +01:00
<Exec Command="&quot;$(MSBuildThisFileDirectory)\scripts\publish.cmd&quot;" ConsoleToMSBuild="true" />
</Target>
<Target Name="ReleaseProcess"
DependsOnTargets="ReleaseBuild;Publish" />
<Target Name="CIBuild"
DependsOnTargets="Build;Tests" />
</Project>