Skip to content

Commit 2e618f2

Browse files
committed
Add job to regenerate template (and fix it)
1 parent 72decab commit 2e618f2

File tree

2 files changed

+73
-5
lines changed

2 files changed

+73
-5
lines changed

.azure-pipelines/steps/update-github-pipeline-status.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# This file is auto-generated by Build.VariableGenerations.GenerateUpdateGitHubPipelineStep
1+
# This file is auto-generated by Build.VariableGenerations.GenerateUpdateGitHubPipelineStep
22
stages:
33
- stage: azure_pipeline_succeeded
44
dependsOn:
@@ -161,13 +161,12 @@ stages:
161161
name: azure-managed-linux-tasks
162162
steps:
163163
- checkout: none
164-
- template: steps/update-github-status.yml
164+
- template: update-github-status.yml
165165
parameters:
166166
checkName: 'azure_pipeline_complete'
167167
status: 'success'
168168
description: 'Pipeline succeeded'
169-
170-
- stage: azure_pipeline_failes
169+
- stage: azure_pipeline_failed
171170
dependsOn:
172171
- merge_commit_id
173172
- generate_variables
@@ -328,7 +327,7 @@ stages:
328327
name: azure-managed-linux-tasks
329328
steps:
330329
- checkout: none
331-
- template: steps/update-github-status.yml
330+
- template: update-github-status.yml
332331
parameters:
333332
checkName: 'azure_pipeline_complete'
334333
status: 'failure'

tracer/build/_build/Build.VariableGenerations.cs

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,6 +1768,75 @@ List<string> GetTracerStagesThatWillNotRun(string[] gitChanges)
17681768
}
17691769
});
17701770

1771+
Target GenerateUpdateGitHubPipelineStep
1772+
=> _ => _
1773+
.Unlisted()
1774+
.Executes(() =>
1775+
{
1776+
var tracerConfig = PipelineParser.GetPipelineDefinition(RootDirectory);
1777+
1778+
var dependsOnStages = tracerConfig
1779+
.Stages
1780+
.Where(x => !string.IsNullOrEmpty(x.Stage))
1781+
.Select(x => $" - {x.Stage}");
1782+
var dependsOn = string.Join(Environment.NewLine, dependsOnStages);
1783+
1784+
var conditionStages = tracerConfig
1785+
.Stages
1786+
.Where(x => !string.IsNullOrEmpty(x.Stage))
1787+
.Select(x => $" in(dependencies.{x.Stage}.result, 'Succeeded','SucceededWithIssues','Skipped')");
1788+
var conditions = string.Join($",{Environment.NewLine}", conditionStages);
1789+
1790+
var template =
1791+
$"""
1792+
# This file is auto-generated by Build.VariableGenerations.GenerateUpdateGitHubPipelineStep
1793+
stages:
1794+
- stage: azure_pipeline_succeeded
1795+
dependsOn:
1796+
{dependsOn}
1797+
condition: |
1798+
and(
1799+
{conditions})
1800+
jobs:
1801+
- job: report_success
1802+
timeoutInMinutes: 60 #default value
1803+
pool:
1804+
name: azure-managed-linux-tasks
1805+
steps:
1806+
- checkout: none
1807+
- template: update-github-status.yml
1808+
parameters:
1809+
checkName: 'azure_pipeline_complete'
1810+
status: 'success'
1811+
description: 'Pipeline succeeded'
1812+
- stage: azure_pipeline_failed
1813+
dependsOn:
1814+
{dependsOn}
1815+
condition: |
1816+
not(and(
1817+
{conditions}))
1818+
jobs:
1819+
- job: report_failure
1820+
timeoutInMinutes: 60 #default value
1821+
pool:
1822+
name: azure-managed-linux-tasks
1823+
steps:
1824+
- checkout: none
1825+
- template: update-github-status.yml
1826+
parameters:
1827+
checkName: 'azure_pipeline_complete'
1828+
status: 'failure'
1829+
description: 'One or more stages failed. See associated failed Azure DevOps jobs'
1830+
1831+
""";
1832+
1833+
Logger.Information("Regenerated azure pipeline template {Template}", template);
1834+
1835+
var templatePath = RootDirectory / ".azure-pipelines" / "steps" / "update-github-pipeline-status.yml";
1836+
File.WriteAllText(templatePath, template);
1837+
Logger.Information("Update template at {Path}", templatePath);
1838+
});
1839+
17711840
static bool IsGitBaseBranch(string baseBranch)
17721841
{
17731842
// *****

0 commit comments

Comments
 (0)