Skip to content

Commit 058c509

Browse files
committed
Fixed query to set xml element
1 parent d9c6617 commit 058c509

File tree

1 file changed

+11
-10
lines changed
  • update-conference-prague-2024/demo-code-feedback-system/deploy/deploy

1 file changed

+11
-10
lines changed

update-conference-prague-2024/demo-code-feedback-system/deploy/deploy/Program.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ public class BuildContext : FrostingContext
3535
public string ReleaseArtifactsDownloadDir { get; }
3636
public string UnzippedArtifactsDir { get; }
3737

38-
public UpResult? PulumiUpResult { get; set; }
39-
4038
public BuildContext(ICakeContext context)
4139
: base(context)
4240
{
@@ -141,9 +139,9 @@ public override async Task RunAsync(BuildContext context)
141139

142140
context.Log.Information($"Pulumi Up starting...");
143141

144-
context.PulumiUpResult = await pulumiStack.UpAsync();
142+
var result = await pulumiStack.UpAsync();
145143
context.Log.Information($"Pulumi Up completed");
146-
Utilities.LogPulumiResult(context, context.PulumiUpResult);
144+
Utilities.LogPulumiResult(context, result);
147145
}
148146
}
149147

@@ -153,7 +151,7 @@ public sealed class RunSeleniumTestsTask : AsyncFrostingTask<BuildContext>
153151
{
154152
public override async Task RunAsync(BuildContext context)
155153
{
156-
WriteConfig(context);
154+
await WriteConfigAsync(context);
157155
await RunTestsAsync(context);
158156
}
159157

@@ -173,22 +171,25 @@ private async Task RunTestsAsync(BuildContext context)
173171
await Task.CompletedTask;
174172
}
175173

176-
private void WriteConfig(BuildContext context)
174+
private async ValueTask WriteConfigAsync(BuildContext context)
177175
{
178176
var fullStackName = $"ProgrammerAL/{context.PulumiStackName}";
179177

180178
context.Log.Information($"Loading stack {fullStackName} from path '{context.PulumiPath}' to get outputs");
181179

182-
var stackOutputs = context.PulumiUpResult!.Outputs;
180+
var stackArgs = new LocalProgramArgs(fullStackName, context.PulumiPath);
181+
var pulumiStack = await LocalWorkspace.SelectStackAsync(stackArgs);
182+
var stackOutputs = await pulumiStack.GetOutputsAsync();
183183
var staticSiteEndpoint = stackOutputs["StaticSiteHttpsEndpoint"].Value.ToString() ?? throw new Exception($"Pulumi output 'StaticSiteHttpsEndpoint' is null for stack '{fullStackName}'");
184184

185+
185186
// Write the config file
186187
var filePath = $"{context.PlaywrightTestsPath}/.runsettings";
187188
var runsettingsXml = XElement.Load(filePath);
188-
var baseUrlElement = runsettingsXml.Element("RunSettings")
189-
!.Element("TestRunParameters")
189+
var baseUrlElement = runsettingsXml
190+
.Element("TestRunParameters")
190191
!.Elements("Parameter")
191-
.Single(x => x.Attribute("baseUrl") != null);
192+
.Single(x => string.Equals(x.Attribute("name")?.Value, "baseUrl"));
192193
baseUrlElement.Value = staticSiteEndpoint;
193194

194195
File.WriteAllText(filePath, runsettingsXml.ToString());

0 commit comments

Comments
 (0)