forked from pulumi/pulumi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.proj
354 lines (309 loc) · 16.9 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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<?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="pulumictl get version --language dotnet" 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:Version=$(Version)"
WorkingDirectory="$(DotNetSdkDirectory)" />
<Exec Command="go install -ldflags "-X github.com/pulumi/pulumi/sdk/v3/go/common/version.Version=$(Version)" github.com/pulumi/pulumi/sdk/v3/dotnet/cmd/pulumi-language-dotnet"
WorkingDirectory="$(SdkDirectory)"/>
</Target>
<Target Name="DotNetInstallPlugin">
<Exec Command="pulumictl get version --language dotnet" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags "-X github.com/pulumi/pulumi/sdk/v3/go/common/version.Version=$(Version)" github.com/pulumi/pulumi/sdk/v3/dotnet/cmd/pulumi-language-dotnet"
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="pulumictl get version" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags "-X github.com/pulumi/pulumi/sdk/v3/go/common/version.Version=$(Version)" github.com/pulumi/pulumi/sdk/v3/go/pulumi-language-go"
WorkingDirectory="$(SdkDirectory)"/>
</Target>
<Target Name="GoInstallPlugin">
<Exec Command="pulumictl get version" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags "-X github.com/pulumi/pulumi/sdk/v3/go/common/version.Version=$(Version)" github.com/pulumi/pulumi/sdk/v3/go/pulumi-language-go"
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="pulumictl get version --language javascript" 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" />
<Exec Command="go install -ldflags "-X github.com/pulumi/pulumi/sdk/v3/go/common/version.Version=$(Version)" github.com/pulumi/pulumi/sdk/v3/nodejs/cmd/pulumi-language-nodejs"
WorkingDirectory="$(SdkDirectory)"/>
</Target>
<Target Name="NodeJSInstallPlugin">
<ItemGroup>
<NodeJSDistFiles Include="$(NodeJSSdkDirectory)\dist\*.cmd" />
</ItemGroup>
<Copy SourceFiles="@(NodeJSDistFiles)"
DestinationFolder="$(PulumiBin)\" />
<Exec Command="pulumictl get version --language javascript" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags "-X github.com/pulumi/pulumi/sdk/v3/go/common/version.Version=$(Version)" github.com/pulumi/pulumi/sdk/v3/nodejs/cmd/pulumi-language-nodejs"
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 --dev"
WorkingDirectory="$(PythonSdkDirectory)\env\src" />
</Target>
<Target Name="PythonBuild">
<Exec Command="pulumictl get version --language python" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="PypiVersion" />
</Exec>
<Exec Command="pulumictl get version" 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="$(PypiVersion)" />
<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" />
<Exec Command="go install -ldflags "-X github.com/pulumi/pulumi/sdk/v3/go/common/version.Version=$(Version)" github.com/pulumi/pulumi/sdk/v3/python/cmd/pulumi-language-python"
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)\" />
<Exec Command="pulumictl get version" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags "-X github.com/pulumi/pulumi/sdk/v3/go/common/version.Version=$(Version)" github.com/pulumi/pulumi/sdk/v3/python/cmd/pulumi-language-python"
EnvironmentVariables="GOBIN=$(PulumiBin)"
WorkingDirectory="$(SdkDirectory)"/>
</Target>
<!-- Install the Pulumi SDK -->
<Target Name="InstallPulumiPlugin">
<Exec Command="pulumictl get version" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="Version" />
</Exec>
<Exec Command="go install -ldflags "-X github.com/pulumi/pulumi/pkg/v3/version.Version=v$(Version)" github.com/pulumi/pulumi/pkg/v3/cmd/pulumi"
EnvironmentVariables="GOBIN=$(PulumiBin)"
WorkingDirectory="$(PkgDirectory)"/>
</Target>
<!-- Build -->
<Target Name="Build"
DependsOnTargets="BuildDotNetSDK;BuildGoSDK;BuildNodeJSSDK;BuildPythonSDK;InstallPulumiPlugin">
</Target>
<!-- 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" />
<Exec Command="yarn install"
WorkingDirectory="$(TestsDirectory)\integration\construct_component_slow\testcomponent" />
<Exec Command="yarn link @pulumi/pulumi"
WorkingDirectory="$(TestsDirectory)\integration\construct_component_slow\testcomponent" />
<Exec Command="yarn install"
WorkingDirectory="$(TestsDirectory)\integration\construct_component_plain\testcomponent" />
<Exec Command="yarn link @pulumi/pulumi"
WorkingDirectory="$(TestsDirectory)\integration\construct_component_plain\testcomponent" />
<Exec Command="yarn install"
WorkingDirectory="$(TestsDirectory)\integration\component_provider_schema\testcomponent" />
<Exec Command="yarn link @pulumi/pulumi"
WorkingDirectory="$(TestsDirectory)\integration\component_provider_schema\testcomponent" />
<Exec Command="yarn install"
WorkingDirectory="$(TestsDirectory)\integration\construct_component_unknown\testcomponent" />
<Exec Command="yarn link @pulumi/pulumi"
WorkingDirectory="$(TestsDirectory)\integration\construct_component_unknown\testcomponent" />
<Exec Command="yarn install"
WorkingDirectory="$(TestsDirectory)\integration\construct_component_error_apply\testcomponent" />
<Exec Command="yarn link @pulumi/pulumi"
WorkingDirectory="$(TestsDirectory)\integration\construct_component_error_apply\testcomponent" />
<Exec Command="yarn install"
WorkingDirectory="$(TestsDirectory)\integration\construct_component_methods\testcomponent" />
<Exec Command="yarn link @pulumi/pulumi"
WorkingDirectory="$(TestsDirectory)\integration\construct_component_methods\testcomponent" />
</Target>
<Target Name="TestBuild">
<Exec Command="go build -o pulumi-resource-testprovider.exe" WorkingDirectory="$(TestsDirectory)\testprovider" />
<Exec Command="yarn run tsc" WorkingDirectory="$(TestsDirectory)\integration\construct_component\testcomponent" />
<Exec Command="go build -o pulumi-resource-testcomponent.exe" WorkingDirectory="$(TestsDirectory)\integration\construct_component\testcomponent-go" />
<Exec Command="yarn run tsc" WorkingDirectory="$(TestsDirectory)\integration\construct_component_slow\testcomponent" />
<Exec Command="yarn run tsc" WorkingDirectory="$(TestsDirectory)\integration\construct_component_plain\testcomponent" />
<Exec Command="go build -o pulumi-resource-testcomponent.exe" WorkingDirectory="$(TestsDirectory)\integration\construct_component_plain\testcomponent-go" />
<Exec Command="yarn run tsc" WorkingDirectory="$(TestsDirectory)\integration\component_provider_schema\testcomponent" />
<Exec Command="go build -o pulumi-resource-testcomponent.exe" WorkingDirectory="$(TestsDirectory)\integration\component_provider_schema\testcomponent-go" />
<Exec Command="yarn run tsc" WorkingDirectory="$(TestsDirectory)\integration\construct_component_unknown\testcomponent" />
<Exec Command="go build -o pulumi-resource-testcomponent.exe" WorkingDirectory="$(TestsDirectory)\integration\construct_component_unknown\testcomponent-go" />
<Exec Command="yarn run tsc" WorkingDirectory="$(TestsDirectory)\integration\construct_component_error_apply\testcomponent" />
<Exec Command="yarn run tsc" WorkingDirectory="$(TestsDirectory)\integration\construct_component_methods\testcomponent" />
<Exec Command="go build -o pulumi-resource-testcomponent.exe" WorkingDirectory="$(TestsDirectory)\integration\construct_component_methods\testcomponent-go" />
<!-- Install pulumi SDK into the venv managed by pipenv. -->
<Exec Command="pipenv run pip install -e ."
WorkingDirectory="$(PythonSdkDirectory)\env\src" />
</Target>
<!-- Tests -->
<Target Name="Tests"
DependsOnTargets="BuildTests">
<Exec Command="go test -timeout 5m -parallel $(TestParallelism) .\backend\..."
IgnoreExitCode="true"
WorkingDirectory="$(PkgDirectory)">
<Output TaskParameter="ExitCode" PropertyName="BackendTestsExitCode" />
</Exec>
<Exec Command="pipenv run pytest -ra lib\test\automation"
WorkingDirectory="$(PythonSdkDirectory)" />
<Error Text="backend tests (.\pkg\backend) failed"
Condition="$(BackendTestsExitCode) != 0"/>
<Exec Command="go test -timeout 1h -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 -timeout 1h -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="CIBuild"
DependsOnTargets="Build;Tests" />
</Project>