forked from pulumi/pulumi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.proj
329 lines (294 loc) · 14.6 KB
/
build.proj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<?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=""$(MSBuildThisFileDirectory)\scripts\get-version.cmd"" 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 "-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=$(Version)" %(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=""$(MSBuildThisFileDirectory)\scripts\get-version.cmd"" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags "-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=$(Version)" %(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=""$(MSBuildThisFileDirectory)\scripts\get-version.cmd"" 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 "-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=$(Version)" %(GoPackagesToBuild.Identity)"
WorkingDirectory="$(SdkDirectory)"/>
</Target>
<Target Name="GoInstallPlugin">
<ItemGroup>
<GoPackagesToBuild Include="github.com/pulumi/pulumi/sdk/v2/go/pulumi-language-go" />
</ItemGroup>
<Exec Command=""$(MSBuildThisFileDirectory)\scripts\get-version.cmd"" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags "-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=$(Version)" %(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=""$(MSBuildThisFileDirectory)\scripts\get-version.cmd"" 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 "$(RepoRootDirectory)\scripts\reversion.js" "$(NodeJSSdkDirectory)\bin\package.json" $(Version)" />
<Exec Command="node "$(RepoRootDirectory)\scripts\reversion.js" "$(NodeJSSdkDirectory)\bin\version.js" $(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 "-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=$(Version)" %(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=""$(MSBuildThisFileDirectory)\scripts\get-version.cmd"" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags "-X github.com/pulumi/pulumi/pkg/v2/version.Version=$(Version)" %(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 && (yarn unlink > NUL || true) && 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=""$(MSBuildThisFileDirectory)\scripts\get-version.cmd"" 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 "-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=$(Version)" %(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=""$(MSBuildThisFileDirectory)\scripts\get-version.cmd"" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags "-X github.com/pulumi/pulumi/sdk/v2/go/common/version.Version=$(Version)" %(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=""$(MSBuildThisFileDirectory)\scripts\get-version.cmd"" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags "-X github.com/pulumi/pulumi/pkg/v2/version.Version=$(Version)" %(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>
<!-- Tests -->
<Target Name="Tests">
<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" />
</Exec>
<Error Text="examples tests (.\tests\examples) failed"
Condition="$(ExamplesTestExitCode) != 0"/>
<Exec Command="go test -v -timeout 40m -cover -parallel $(TestParallelism) .\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">
<Exec Command=""$(MSBuildThisFileDirectory)\scripts\publish.cmd"" ConsoleToMSBuild="true" />
</Target>
<Target Name="ReleaseProcess"
DependsOnTargets="ReleaseBuild;Publish" />
<Target Name="CIBuild"
DependsOnTargets="Build;Tests" />
</Project>