Skip to content

Commit 45c861c

Browse files
committed
[ci]: add native arm64/armhf sonic-slave build pipeline
setup sonic-slave template and use the template for amd64, arm64 and armhf sonic-slave Signed-off-by: Guohan Lu <[email protected]>
1 parent 9c4a7c2 commit 45c861c

File tree

4 files changed

+211
-61
lines changed

4 files changed

+211
-61
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Starter pipeline
2+
# Start with a minimal pipeline that you can customize to build and deploy your code.
3+
# Add steps that build, run tests, deploy, and more:
4+
# https://aka.ms/yaml
5+
# Build and push sonic-slave-[buster|jessie|stretch] images for amd64/armhf/arm64
6+
7+
schedules:
8+
- cron: "0 8 * * *"
9+
branches:
10+
include:
11+
- master
12+
- 202012
13+
always: true
14+
15+
trigger: none
16+
pr:
17+
branches:
18+
include:
19+
- master
20+
paths:
21+
include:
22+
- sonic-slave-jessie
23+
- sonic-slave-stretch
24+
- sonic-slave-buster
25+
- sonic-slave-bullseye
26+
27+
parameters:
28+
- name: 'arches'
29+
type: object
30+
default:
31+
- arm64
32+
- name: 'dists'
33+
type: object
34+
default:
35+
- bullseye
36+
- buster
37+
- stretch
38+
39+
stages:
40+
- stage: Build
41+
jobs:
42+
- ${{ each dist in parameters.dists }}:
43+
- ${{ if contains(variables['Build.DefinitionName'], dist) }}:
44+
- ${{ each arch in parameters.arches }}:
45+
- template: docker-sonic-slave-template.yml
46+
parameters:
47+
pool: sonicbld-arm64
48+
arch: ${{ arch }}
49+
dist: ${{ dist }}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Starter pipeline
2+
# Start with a minimal pipeline that you can customize to build and deploy your code.
3+
# Add steps that build, run tests, deploy, and more:
4+
# https://aka.ms/yaml
5+
# Build and push sonic-slave-[buster|jessie|stretch] images for amd64/armhf/arm64
6+
7+
schedules:
8+
- cron: "0 8 * * *"
9+
branches:
10+
include:
11+
- master
12+
- 202012
13+
always: true
14+
15+
trigger: none
16+
pr:
17+
branches:
18+
include:
19+
- master
20+
paths:
21+
include:
22+
- sonic-slave-jessie
23+
- sonic-slave-stretch
24+
- sonic-slave-buster
25+
- sonic-slave-bullseye
26+
27+
parameters:
28+
- name: 'arches'
29+
type: object
30+
default:
31+
- armhf
32+
- name: 'dists'
33+
type: object
34+
default:
35+
- bullseye
36+
- buster
37+
- stretch
38+
39+
stages:
40+
- stage: Build
41+
jobs:
42+
- ${{ each dist in parameters.dists }}:
43+
- ${{ if contains(variables['Build.DefinitionName'], dist) }}:
44+
- ${{ each arch in parameters.arches }}:
45+
- template: docker-sonic-slave-template.yml
46+
parameters:
47+
pool: sonicbld-armhf
48+
arch: ${{ arch }}
49+
dist: ${{ dist }}
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Starter pipeline
2+
# Start with a minimal pipeline that you can customize to build and deploy your code.
3+
# Add steps that build, run tests, deploy, and more:
4+
# https://aka.ms/yaml
5+
# Build and push sonic-slave-[buster|jessie|stretch] images for amd64/armhf/arm64
6+
7+
parameters:
8+
- name: arch
9+
type: string
10+
values:
11+
- amd64
12+
- armhf
13+
- arm64
14+
- name: dist
15+
type: string
16+
values:
17+
- bullseye
18+
- buster
19+
- stretch
20+
- jessie
21+
- name: registry_url
22+
type: string
23+
default: sonicdev-microsoft.azurecr.io
24+
- name: registry_conn
25+
type: string
26+
default: sonicdev
27+
- name: pool
28+
type: string
29+
default: sonicbld
30+
values:
31+
- sonicbld
32+
- sonicbld-arm64
33+
- sonicbld-armhf
34+
35+
jobs:
36+
- job: Build_${{ parameters.dist }}_${{ parameters.arch }}
37+
timeoutInMinutes: 360
38+
pool: ${{ parameters.pool }}
39+
steps:
40+
- template: cleanup.yml
41+
- checkout: self
42+
clean: true
43+
submodules: recursive
44+
- bash: |
45+
set -ex
46+
47+
SLAVE_DIR=sonic-slave-${{ parameters.dist }}
48+
if [ x${{ parameters.pool }} == x"sonicbld" ]; then
49+
if [ x${{ parameters.arch }} == x"amd64" ]; then
50+
SLAVE_BASE_IMAGE=${SLAVE_DIR}
51+
SLAVE_BASE_IMAGE_UPLOAD=${SLAVE_DIR}
52+
elif [ x${{ parameters.pool }} == x"sonicbld" ]; then
53+
SLAVE_BASE_IMAGE=${SLAVE_DIR}-march-${{ parameters.arch }}
54+
SLAVE_BASE_IMAGE_UPLOAD=${SLAVE_DIR}-march-${{ parameters.arch }}
55+
fi
56+
elif [[ x${{ parameters.pool }} == x"sonicbld-armhf" && x${{ parameters.arch }} == x"armhf" ]]; then
57+
SLAVE_BASE_IMAGE=${SLAVE_DIR}
58+
SLAVE_BASE_IMAGE_UPLOAD=${SLAVE_DIR}-armhf
59+
elif [[ x${{ parameters.pool }} == x"sonicbld-arm64" && x${{ parameters.arch }} == x"arm64" ]]; then
60+
SLAVE_BASE_IMAGE=${SLAVE_DIR}
61+
SLAVE_BASE_IMAGE_UPLOAD=${SLAVE_DIR}-arm64
62+
else
63+
echo "do not support build ${{ parameters.arch }} on ${{ parameters.pool }}"
64+
exit 1
65+
fi
66+
67+
if [ x"$(Build.SourceBranchName)" == x"202012" ]; then
68+
BUILD_OPTIONS = 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web,git,docker'
69+
fi
70+
71+
containers=$(docker container ls | grep "sonic-slave" | awk '{ print $1 }')
72+
if [ ! -z "$containers" ]; then
73+
docker container kill $containers || true
74+
sleep 5
75+
fi
76+
images=$(docker images 'sonic-slave-*' -a -q)
77+
if [ ! -z "$images" ]; then
78+
docker rmi -f $images
79+
fi
80+
81+
tmpfile=$(mktemp)
82+
83+
echo ${{ parameters.arch }} > .arch
84+
85+
DOCKER_DATA_ROOT_FOR_MULTIARCH=/data/march/docker BLDENV=${{ parameters.dist }} $(BUILD_OPTIONS) make -f Makefile.work sonic-slave-build | tee $tmpfile
86+
SLAVE_BASE_TAG=$(grep "^Checking sonic-slave-base image:" $tmpfile | awk -F ':' '{print $3}')
87+
SLAVE_TAG=$(grep "^Checking sonic-slave image:" $tmpfile | awk -F ':' '{print $3}')
88+
89+
mkdir -p target
90+
91+
docker tag $SLAVE_BASE_IMAGE:$SLAVE_BASE_TAG $REGISTRY_SERVER/$SLAVE_BASE_IMAGE_UPLOAD:latest
92+
docker tag $SLAVE_BASE_IMAGE:$SLAVE_BASE_TAG $REGISTRY_SERVER/$SLAVE_BASE_IMAGE_UPLOAD:$SLAVE_BASE_TAG
93+
set +x
94+
echo "##vso[task.setvariable variable=VARIABLE_SLAVE_BASE_IMAGE]$SLAVE_BASE_IMAGE_UPLOAD"
95+
echo "##vso[task.setvariable variable=VARIABLE_SLAVE_BASE_TAG]$SLAVE_BASE_TAG"
96+
env:
97+
REGISTRY_SERVER: ${{ parameters.registry_url }}
98+
displayName: Build sonic-slave-${{ parameters.dist }}-${{ parameters.arch }}
99+
100+
- task: Docker@2
101+
displayName: Upload image
102+
inputs:
103+
containerRegistry: ${{ parameters.registry_conn }}
104+
repository: $(VARIABLE_SLAVE_BASE_IMAGE)
105+
command: push
106+
tags: |
107+
$(VARIABLE_SLAVE_BASE_TAG)
108+
latest

.azure-pipelines/docker-sonic-slave.yml

Lines changed: 5 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -45,70 +45,14 @@ parameters:
4545
type: string
4646
default: sonicdev
4747

48-
variables:
49-
- ${{ if eq(variables['Build.SourceBranchName'], '202012') }}:
50-
- name: BUILD_OPTIONS
51-
value: 'SONIC_VERSION_CONTROL_COMPONENTS=deb,py2,py3,web,git,docker'
52-
5348
stages:
5449
- stage: Build
5550
jobs:
5651
- ${{ each dist in parameters.dists }}:
5752
- ${{ if endswith(variables['Build.DefinitionName'], dist) }}:
5853
- ${{ each arch in parameters.arches }}:
59-
- job: Build_${{ dist }}_${{ arch }}
60-
timeoutInMinutes: 360
61-
pool: sonicbld
62-
steps:
63-
- template: cleanup.yml
64-
- checkout: self
65-
clean: true
66-
submodules: recursive
67-
- bash: |
68-
set -ex
69-
70-
containers=$(docker container ls | grep "sonic-slave" | awk '{ print $1 }')
71-
if [ ! -z "$containers" ]; then
72-
docker container kill $containers || true
73-
sleep 5
74-
fi
75-
images=$(docker images 'sonic-slave-*' -a -q)
76-
if [ ! -z "$images" ]; then
77-
docker rmi -f $images
78-
fi
79-
80-
SLAVE_DIR=sonic-slave-${{ dist }}
81-
if [ x${{ arch }} == x"amd64" ]; then
82-
SLAVE_BASE_IMAGE=${SLAVE_DIR}
83-
else
84-
SLAVE_BASE_IMAGE=${SLAVE_DIR}-march-${{ arch }}
85-
fi
86-
87-
tmpfile=$(mktemp)
88-
89-
echo ${{ arch }} > .arch
90-
91-
DOCKER_DATA_ROOT_FOR_MULTIARCH=/data/march/docker BLDENV=${{ dist }} $(BUILD_OPTIONS) make -f Makefile.work sonic-slave-build | tee $tmpfile
92-
SLAVE_BASE_TAG=$(grep "^Checking sonic-slave-base image:" $tmpfile | awk -F ':' '{print $3}')
93-
SLAVE_TAG=$(grep "^Checking sonic-slave image:" $tmpfile | awk -F ':' '{print $3}')
94-
95-
mkdir -p target
96-
97-
docker tag $SLAVE_BASE_IMAGE:$SLAVE_BASE_TAG $REGISTRY_SERVER/$SLAVE_BASE_IMAGE:latest
98-
docker tag $SLAVE_BASE_IMAGE:$SLAVE_BASE_TAG $REGISTRY_SERVER/$SLAVE_BASE_IMAGE:$SLAVE_BASE_TAG
99-
set +x
100-
echo "##vso[task.setvariable variable=VARIABLE_SLAVE_BASE_IMAGE]$SLAVE_BASE_IMAGE"
101-
echo "##vso[task.setvariable variable=VARIABLE_SLAVE_BASE_TAG]$SLAVE_BASE_TAG"
102-
env:
103-
REGISTRY_SERVER: ${{ parameters.registry_url }}
104-
displayName: Build sonic-slave-${{ dist }}-${{ arch }}
105-
106-
- task: Docker@2
107-
displayName: Upload image
108-
inputs:
109-
containerRegistry: ${{ parameters.registry_conn }}
110-
repository: $(VARIABLE_SLAVE_BASE_IMAGE)
111-
command: push
112-
tags: |
113-
$(VARIABLE_SLAVE_BASE_TAG)
114-
latest
54+
- template: docker-sonic-slave-template.yml
55+
parameters:
56+
pool: sonicbld
57+
arch: ${{ arch }}
58+
dist: ${{ dist }}

0 commit comments

Comments
 (0)