Skip to content

Commit fd5ac0d

Browse files
rolfbjarneCopilot
andauthored
[devops] Move Linux build verification from GitHub Actions to Azure DevOps (#24926)
Replace the GitHub Actions workflow (.github/workflows/linux-build.yml) with a new Azure DevOps stage that runs in parallel with the existing pipeline stages. The new stage checks out the code on a Linux agent, verifies system dependencies, and runs 'make' to confirm the build succeeds. The stage is added to both the official build pipeline (main-stage.yml) and the test pipeline (tests-stage.yml), using the appropriate Linux pool for each (1ES pool for official, ubuntu-latest for tests). This solves a problem with the GitHub action where it wouldn't run if the last commit was from another GitHub action (which is a good thing). This is problematic for us though, because this happens fairly often (autoformat, global.json generation), and it means such pull requests require admin rigths to merge, because the linux validation is a required check. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 8f3b670 commit fd5ac0d

5 files changed

Lines changed: 92 additions & 31 deletions

File tree

.github/workflows/linux-build.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

tools/devops/automation/scripts/TestResults.psm1

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ class ParallelTestsResults {
265265
[string] $Context
266266
[string] $VSDropsIndex
267267
[TestResult[]] $Results
268+
[string] $LinuxBuildStatus
268269

269270
ParallelTestsResults (
270271
[TestResult[]] $results,
@@ -306,6 +307,9 @@ class ParallelTestsResults {
306307
if (-not [string]::IsNullOrEmpty($this.BuildFailureMessage)) {
307308
return $false
308309
}
310+
if (-not [string]::IsNullOrEmpty($this.LinuxBuildStatus) -and $this.LinuxBuildStatus -ne "Succeeded") {
311+
return $false
312+
}
309313
$failingTests = $this.GetFailingTests()
310314
return $failingTests.Count -eq 0
311315
}
@@ -490,6 +494,19 @@ class ParallelTestsResults {
490494
}
491495
}
492496

497+
# Add Linux build verification status
498+
if (-not [string]::IsNullOrEmpty($this.LinuxBuildStatus)) {
499+
$pipelineLink = "$Env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI$Env:SYSTEM_TEAMPROJECT/_build/results?buildId=$Env:BUILD_BUILDID"
500+
$stringBuilder.AppendLine("")
501+
$stringBuilder.AppendLine("## Linux Build Verification")
502+
$stringBuilder.AppendLine("")
503+
if ($this.LinuxBuildStatus -eq "Succeeded") {
504+
$stringBuilder.AppendLine(":white_check_mark: [Linux build succeeded]($pipelineLink)")
505+
} else {
506+
$stringBuilder.AppendLine(":x: [Linux build $($this.LinuxBuildStatus.ToLower())]($pipelineLink)")
507+
}
508+
}
509+
493510
$stringBuilder.AppendLine()
494511
$stringBuilder.AppendLine("[comment]: <> (This is a test result report added by Azure DevOps)")
495512
}
@@ -664,7 +681,21 @@ class ParallelTestsResults {
664681
}
665682
}
666683

667-
return [ParallelTestsResults]::new($testResults, $Context, $VSDropsIndex)
684+
$result = [ParallelTestsResults]::new($testResults, $Context, $VSDropsIndex)
685+
686+
# Extract the Linux build verification status from stage dependencies
687+
if ($stageDep.ContainsKey("linux_build_verification")) {
688+
$linuxStage = $stageDep["linux_build_verification"]
689+
if ($linuxStage.ContainsKey("linux_build")) {
690+
$linuxJob = $linuxStage["linux_build"]
691+
if ($linuxJob.ContainsKey("result")) {
692+
$result.LinuxBuildStatus = $linuxJob["result"]
693+
Write-Host "Linux build verification status: $($result.LinuxBuildStatus)"
694+
}
695+
}
696+
}
697+
698+
return $result
668699
}
669700
}
670701

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Stage to verify the project builds successfully on Linux.
2+
3+
parameters:
4+
5+
- name: isPR
6+
type: boolean
7+
8+
- name: repositoryAlias
9+
type: string
10+
default: self
11+
12+
- name: commit
13+
type: string
14+
default: HEAD
15+
16+
- name: pool
17+
type: object
18+
default:
19+
vmImage: ubuntu-latest
20+
21+
- name: stageDisplayNamePrefix
22+
type: string
23+
default: ''
24+
25+
stages:
26+
27+
- stage: linux_build_verification
28+
displayName: '${{ parameters.stageDisplayNamePrefix }}Linux Build Verification'
29+
dependsOn: []
30+
jobs:
31+
- job: linux_build
32+
displayName: 'Build on Linux'
33+
pool: ${{ parameters.pool }}
34+
timeoutInMinutes: 60
35+
steps:
36+
- template: ../common/checkout.yml
37+
parameters:
38+
isPR: ${{ parameters.isPR }}
39+
repositoryAlias: ${{ parameters.repositoryAlias }}
40+
commit: ${{ parameters.commit }}
41+
42+
- bash: |
43+
set -ex
44+
./system-dependencies.sh
45+
displayName: 'Check system dependencies'
46+
workingDirectory: $(System.DefaultWorkingDirectory)/$(BUILD_REPOSITORY_TITLE)
47+
48+
- bash: |
49+
set -ex
50+
make -j$(nproc)
51+
displayName: 'Build on Linux'
52+
workingDirectory: $(System.DefaultWorkingDirectory)/$(BUILD_REPOSITORY_TITLE)

tools/devops/automation/templates/tests-stage.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ parameters:
123123

124124
stages:
125125

126+
- template: ./build/linux-build-verification.yml
127+
parameters:
128+
isPR: ${{ parameters.isPR }}
129+
repositoryAlias: ${{ parameters.repositoryAlias }}
130+
commit: ${{ parameters.commit }}
131+
stageDisplayNamePrefix: ${{ parameters.stageDisplayNamePrefix }}
132+
126133
- stage: configure_build
127134
displayName: '${{ parameters.stageDisplayNamePrefix }}Configure'
128135
dependsOn: ${{ parameters.dependsOn }}

tools/devops/automation/templates/tests/publish-results.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ stages:
4747
- configure_build
4848
- simulator_tests
4949
- windows_integration
50+
- linux_build_verification
5051
condition: and(succeededOrFailed(), ${{ parameters.condition }})
5152

5253
jobs:

0 commit comments

Comments
 (0)