Skip to content

Commit e6d311d

Browse files
authored
Add build vs and test pipeline (sonic-net#21318)
Why I did it sonic-buildimage repo integrates submodule code into the image by creating submodule advance PRs. However, these PRs often fail, and as time passes or the number of submodule PRs increases, identifying which PR caused the test failure becomes increasingly challenging. To address this, we need a pipeline capable of quickly building a VS image based on specific submodule commit IDs and precisely running the failed tests. This approach will help us efficiently pinpoint the submodule PR responsible for the failure. How I did it Create a build VS and test pipeline, users could build VS image and run tests based on specific submodule name and id, branch, topology, test scripts, features.
1 parent 5b185d4 commit e6d311d

3 files changed

+150
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
pr: none
2+
trigger: none
3+
4+
5+
name: $(TeamProject)_$(Build.DefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
6+
7+
resources:
8+
repositories:
9+
- repository: sonic-mgmt
10+
type: github
11+
name: sonic-net/sonic-mgmt
12+
ref: master
13+
endpoint: sonic-net
14+
- repository: buildimage
15+
type: github
16+
name: sonic-net/sonic-buildimage
17+
endpoint: sonic-net
18+
ref: master
19+
20+
21+
variables:
22+
- template: .azure-pipelines/azure-pipelines-repd-build-variables.yml@buildimage
23+
- template: .azure-pipelines/template-variables.yml@buildimage
24+
- name: CACHE_MODE
25+
value: rcache
26+
- name: ENABLE_FIPS
27+
value: y
28+
- name: BUILD_BRANCH
29+
${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
30+
value: $(System.PullRequest.TargetBranch)
31+
${{ else }}:
32+
value: $(Build.SourceBranchName)
33+
34+
35+
parameters:
36+
- name: SUBMODULE
37+
type: string
38+
default: ' '
39+
40+
- name: COMMIT_ID
41+
type: string
42+
default: ' '
43+
44+
- name: MGMT_BRANCH
45+
type: string
46+
default: 'master'
47+
48+
- name: TOPOLOGY
49+
type: string
50+
default: ''
51+
values:
52+
- t0
53+
- t0-64-32
54+
- t1-lag
55+
- multi-asic-t1-lag
56+
- dualtor
57+
- dpu
58+
59+
- name: DEPLOY_MG_EXTRA_PARAMS
60+
type: string
61+
default: ' '
62+
63+
- name: SCRIPTS
64+
type: string
65+
default: ' '
66+
67+
- name: FEATURES
68+
type: string
69+
default: ' '
70+
71+
- name: MIN_WORKER
72+
type: string
73+
default: '1'
74+
75+
- name: MAX_WORKER
76+
type: string
77+
default: '1'
78+
79+
- name: STOP_ON_FAILURE
80+
type: string
81+
default: 'False'
82+
values:
83+
- 'True'
84+
- 'False'
85+
86+
stages:
87+
- stage: BuildVS
88+
pool: sonicbld-1es
89+
jobs:
90+
- template: azure-pipelines-build.yml
91+
parameters:
92+
buildOptions: 'USERNAME=admin SONIC_BUILD_JOBS=$(nproc) BUILD_MULTIASIC_KVM=y INCLUDE_DHCP_SERVER=y ${{ variables. VERSION_CONTROL_OPTIONS }}'
93+
jobGroups:
94+
- name: vs
95+
SUBMODULE: ${{ parameters.SUBMODULE }}
96+
COMMIT_ID: ${{ parameters.COMMIT_ID }}
97+
98+
- stage: Test
99+
dependsOn: BuildVS
100+
condition: and(succeeded(), and(ne(stageDependencies.BuildVS.outputs['vs.SetVar.SKIP_VSTEST'], 'YES'), in(dependencies.BuildVS.result, 'Succeeded', 'SucceededWithIssues')))
101+
variables:
102+
- group: SONiC-Elastictest
103+
- name: inventory
104+
value: veos_vtb
105+
- name: testbed_file
106+
value: vtestbed.yaml
107+
108+
jobs:
109+
- job: KVMTEST
110+
displayName: "kvmtest by Elastictest"
111+
timeoutInMinutes: 240
112+
continueOnError: false
113+
pool: sonic-ubuntu-1c
114+
steps:
115+
- template: .azure-pipelines/run-test-elastictest-template.yml@sonic-mgmt
116+
parameters:
117+
TOPOLOGY: ${{ parameters.TOPOLOGY }}
118+
MIN_WORKER: ${{ parameters.MIN_WORKER }}
119+
MAX_WORKER: ${{ parameters.MAX_WORKER }}
120+
KVM_IMAGE_BRANCH: $(BUILD_BRANCH)
121+
MGMT_BRANCH: ${{ parameters.MGMT_BRANCH }}
122+
SCRIPTS: ${{ parameters.SCRIPTS }}
123+
FEATURES: ${{ parameters.FEATURES }}
124+
DEPLOY_MG_EXTRA_PARAMS: ${{ parameters.DEPLOY_MG_EXTRA_PARAMS }}
125+
STOP_ON_FAILURE: ${{ parameters.STOP_ON_FAILURE }}

.azure-pipelines/azure-pipelines-build.yml

+8
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,21 @@ parameters:
1919
- name: 'qemuOrCrossBuild'
2020
type: boolean
2121
default: false
22+
- name: SUBMODULE
23+
type: string
24+
default: ''
25+
- name: COMMIT_ID
26+
type: string
27+
default: ''
2228

2329
jobs:
2430
- template: azure-pipelines-image-template.yml
2531
parameters:
2632
jobFilters: ${{ parameters.jobFilters }}
2733
preSteps: ${{ parameters.preSteps }}
2834
postSteps: ${{ parameters.postSteps }}
35+
SUBMODULE: ${{ parameters.SUBMODULE }}
36+
COMMIT_ID: ${{ parameters.COMMIT_ID }}
2937
jobVariables:
3038
PLATFORM_AZP: $(GROUP_NAME)
3139
PLATFORM_ARCH: amd64

.azure-pipelines/azure-pipelines-image-template.yml

+17
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ parameters:
1919
- name: jobVariables
2020
type: object
2121
default: []
22+
- name: SUBMODULE
23+
type: string
24+
default: ''
25+
- name: COMMIT_ID
26+
type: string
27+
default: ''
2228
jobs:
2329
- template: azure-pipelines-job-groups.yml
2430
parameters:
@@ -42,6 +48,17 @@ jobs:
4248
fetchDepth: 0
4349
condition: and(succeeded(), eq(variables.SKIP_CHECKOUT, ''))
4450
displayName: 'Checkout code'
51+
- script: |
52+
if [ -n "${{ parameters.COMMIT_ID }}" ]; then
53+
if [ -n "${{ parameters.SUBMODULE }}" ]; then
54+
git submodule update --init --recursive
55+
cd src/${{ parameters.SUBMODULE }}
56+
fi
57+
git checkout ${{ parameters.COMMIT_ID }}
58+
else
59+
echo "No specific commit id provided, checkout to latest commit"
60+
fi
61+
displayName: 'Checkout commit'
4562
- script: |
4663
set -x
4764
sudo setfacl -R -b $(Agent.BuildDirectory)

0 commit comments

Comments
 (0)