1
1
open System
2
2
open System.IO
3
3
open System.Linq
4
+ open System.Text .RegularExpressions
4
5
open Fake.IO
5
6
open Fake.Core
6
7
open Publish
@@ -27,6 +28,24 @@ let pulumiFSharp = Path.Combine(sdk, "Pulumi.FSharp")
27
28
let integrationTests = Path.Combine( repositoryRoot, " integration_tests" )
28
29
let pulumiLanguageDotnet = Path.Combine( repositoryRoot, " pulumi-language-dotnet" )
29
30
31
+ // Find the version of the Pulumi Go SDK that we are using for the language plugin.
32
+ let findGoSDKVersion =
33
+ let goMod = Path.Combine( pulumiLanguageDotnet, " go.mod" )
34
+ try
35
+ let lines = File.ReadAllLines( goMod)
36
+ let patternRegex = new Regex( " ^\\ s*github.com/pulumi/pulumi/sdk" , RegexOptions.IgnoreCase)
37
+ match Array.tryFind ( patternRegex.IsMatch) lines with
38
+ | Some( matchingLine) ->
39
+ let version = matchingLine.Split( ' ' )[ 1 ]
40
+ let version = version.TrimStart( 'v' )
41
+ Some( version)
42
+ | None ->
43
+ None
44
+ with
45
+ | ex ->
46
+ printfn " Error while trying to find the GO SDK version: %s " ex.Message
47
+ None
48
+
30
49
/// Runs `dotnet clean` command against the solution file,
31
50
/// then proceeds to delete the `bin` and `obj` directory of each project in the solution
32
51
let cleanSdk () =
@@ -79,9 +98,12 @@ let listIntegrationTests() =
79
98
let buildSdk () =
80
99
cleanSdk()
81
100
restoreSdk()
82
- printfn " Building Pulumi SDK"
83
- if Shell.Exec( " dotnet" , " build --configuration Release" , sdk) <> 0
84
- then failwith " build failed"
101
+ match findGoSDKVersion with
102
+ | None -> failwith " Could not find the Pulumi SDK version in go.mod"
103
+ | Some( version) ->
104
+ printfn " Building Pulumi SDK"
105
+ if Shell.Exec( " dotnet" , " build --configuration Release -p:PulumiSDKVersion=" + version, sdk) <> 0
106
+ then failwith " build failed"
85
107
86
108
/// Publishes packages for Pulumi, Pulumi.Automation and Pulumi.FSharp to nuget.
87
109
/// Requires NUGET_PUBLISH_KEY and PULUMI_VERSION environment variables.
@@ -148,10 +170,13 @@ let testPulumiSdk coverage =
148
170
let testPulumiAutomationSdk coverage =
149
171
cleanSdk()
150
172
restoreSdk()
151
- printfn " Testing Pulumi Automation SDK"
152
- let coverageArgs = if coverage then $" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput={coverageDir}/coverage.pulumi.automation.xml" else " "
153
- if Shell.Exec( " dotnet" , " test --configuration Release" + coverageArgs, pulumiAutomationSdkTests) <> 0
154
- then failwith " automation tests failed"
173
+ match findGoSDKVersion with
174
+ | None -> failwith " Could not find the Pulumi SDK version in go.mod"
175
+ | Some( version) ->
176
+ printfn " Testing Pulumi Automation SDK"
177
+ let coverageArgs = if coverage then $" -p:CollectCoverage=true -p:CoverletOutputFormat=cobertura -p:CoverletOutput={coverageDir}/coverage.pulumi.automation.xml" else " "
178
+ if Shell.Exec( " dotnet" , " test --configuration Release -p:PulumiSDKVersion=" + version + " --filter InstallDefaultRoot" + coverageArgs, pulumiAutomationSdkTests) <> 0
179
+ then failwith " automation tests failed"
155
180
156
181
let syncProtoFiles () = GitSync.repository {
157
182
remoteRepository = " https://github.com/pulumi/pulumi.git"
0 commit comments