-
Notifications
You must be signed in to change notification settings - Fork 7
executable file
·190 lines (179 loc) · 6.86 KB
/
build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Build
on:
pull_request:
branches:
- main
- dev
env:
DST_BASE: /data1/k230/github-actions/k230_linux_sdk
SUB_BASE: ${{ github.event.number }}_${{ github.run_id }}
TFTP_ROOT: /data1/tftp_server
NFS_ROOT: /data/nfs_server
HW_VER: v0.1
defaults:
run:
shell: bash
concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
build_image:
name: Build
runs-on: [self-hosted, k230_linux_sdk]
timeout-minutes: 45
container:
image: ai.b-bug.org:5000/k230_sdk:latest
env:
CONF: ${{ matrix.hw_type }}_${{ matrix.hw_model }}_defconfig
volumes:
- /data:/data
- /data1:/data1
options: --hostname runner
strategy:
matrix:
hw_type: ["k230"]
hw_model: ["canmv"]
outputs:
image_md5: ${{ steps.save_tftp.outputs.image_md5 }}
image_path: ${{ steps.save_tftp.outputs.image_path }}
steps:
- name: Build Env Setup
id: build_env
run: |
set -x
echo '----------Build ENV Prepare----------'
echo 'Add SSH KEY for Multiple repo'
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo "$SSH_PRIVATE_KEY" | ssh-add - > ~/.ssh/id_ed25519 || exit 1
'[[ -f /.dockerenv ]] && echo -e "Host *\n StrictHostKeyChecking no\n" > ~/.ssh/config'
echo $SHELL
echo "increate ssh timeout for github"
echo " ServerAliveInterval 30" >> ~/.ssh/config
echo " ServerAliveCountMax 60" >> ~/.ssh/config
echo " TCPKeepAlive yes" >> ~/.ssh/config
cat ~/.ssh/config
whoami
uptime
pwd
uname -a
cat /etc/issue
HW_TYPE=$(echo $CONF | awk -F '_' '{print $1}')
HW_MODEL=$(echo $CONF | awk -F "_" '{if ($3 == "v2") print $2"_"$3; else print $2}')
echo "HW_TYPE ${HW_TYPE}, HW_MODEL ${HW_MODEL}"
- name: Checkout Code
id: checkout_code
run: |
PR_REPO=${{ github.event.pull_request.head.repo.full_name }}
PR_BRANCH=${{ github.event.pull_request.head.ref }}
BASE_REPO=${{ github.repository }}
BASE_BRANCH=${{ github.event.pull_request.base.ref }}
echo "PR_REPO: ${PR_REPO}, PR_BRANCH: ${PR_BRANCH}"
echo "BASE_REPO: ${BASE_REPO}, BASE_BRANCH: ${BASE_BRANCH}"
echo "Cloning PR repository ${PR_REPO} branch ${PR_BRANCH}"
echo "set github proxy"
git config --global http.proxy ${GITHUB_PROXY}
git config --global https.proxy ${GITHUB_PROXY}
git clone --depth=0 --branch=${PR_BRANCH} https://github.com/${PR_REPO} /workspace || git clone --depth=0 --branch=${PR_BRANCH} https://github.com/${PR_REPO} /workspace
cd /workspace
git fetch origin ${PR_BRANCH}:${PR_BRANCH} || exit 1
git checkout ${PR_BRANCH} || exit 1
ls -alht
pwd
- name: Build Image
id: build_image
run: |
pwd
echo "----------start to build linux sdk image----------"
time make CONF=${CONF} BR2_PRIMARY_SITE=${DL_SITE} || exit 1
echo "----------show linux sdk image build output----------"
pwd
du -h -d 2 output/${CONF}/ || exit 1
ls -alht output/${CONF}/images || exit 1
echo "----------remove img----------"
rm -rf output/${CONF}/images/sysimage-sdcard.img
echo "----------build sdk image done----------"
- name: Save Image
id: save_image
run: |
pwd
echo "----------save image----------"
SRC_DIR="./output/${CONF}/images"
echo "SRC_DIR: ${SRC_DIR}"
echo ${DST_BASE}
echo "set DST_DIR with different type based on docs/images/src"
DST_DIR="${DST_BASE}/images"
echo "DST_DIR: ${DST_DIR}"
echo "---create repo dir---"
sudo mkdir -p ${DST_DIR}
echo "----------Save build to external path----------"
SUB_DIR="${SUB_BASE}/${CONF}";
echo "---create current image version dir---"
sudo mkdir -p ${DST_DIR}/${SUB_DIR}/ || exit 1
echo "---save sdk build output---"
sudo cp -rf --sparse=always -L ${SRC_DIR}/${HW_TYPE}_${HW_MODEL}_*.img.gz ${DST_DIR}/${SUB_DIR}/
echo "${DST_DIR}/${SUB_DIR}/"
ls "${DST_DIR}/${SUB_DIR}/"
echo "add latest link for current build"
test -h ${DST_DIR}/latest && sudo rm ${DST_DIR}/latest
sudo ln -s ${DST_DIR}/${ver} ${DST_DIR}/latest || exit 1
ls ${DST_DIR}/latest
echo "----------output URL----------"
echo "${DST_DIR}/${SUB_DIR}/" | sed "s/\/data1/https:\/\/ai\.b-bug\.org/g"
echo "----------save image done----------"
- name: Save image to TFTP
id: save_tftp
run: |
echo "start to save test image for config: ${CONF} ------";
echo "SRC_DIR: ${SRC_DIR}"
echo ${TFTP_BASE};
echo "set DST_DIR with different type based on docs/images/src";
DST_DIR="${TFTP_BASE}/${HW_TYPE}/${HW_MODEL}_${HW_VER}";
echo ${DST_DIR};
SUB_DIR=${SUB_BASE}/${CONF}
echo "---create tftp dir---";
sudo mkdir -p ${DST_DIR}/${SUB_DIR}/ || exit 1;
sudo cp -rf --sparse=always -L ${SRC_DIR}/${HW_TYPE}_${HW_MODEL}_*.img.gz ${DST_DIR}/${SUB_DIR}
cp --sparse=always $CONF/images/k510.dtb $SAVE_DIR/k510.dtb
image_md5=$(md5sum ${DST_DIR}/${SUB_DIR}/${HW_TYPE}_${HW_MODEL}_*.img.gz | awk '{print $1}')
image_path="${DST_DIR}/${SUB_DIR}/"
echo $image_md5
echo $image_path
echo "image_md5=$image_md5" >> $GITHUB_OUTPUT
echo "image_path=$image_path" >> $GITHUB_OUTPUT
test_image:
name: Test
needs: build_image
timeout-minutes: 15
runs-on: [self-hosted, k230_linux_sdk]
env:
CONF: ${{ matrix.hw_type }}_${{ matrix.hw_model }}_defconfig
container:
image: ai.b-bug.org:5000/k230_sdk:latest
volumes:
- /data:/data
- /data1:/data1
options: --hostname runner
strategy:
matrix:
hw_type: ["k230"]
hw_model: ["canmv"]
steps:
- name: Run Test
id: run_test
run: |
echo "=============================="
echo "There is NO test job NOW"
echo "=============================="
echo "add this stage for future job"
echo "=============================="
echo "image md5: ${{needs.build_image.outputs.image_md5}}"
echo "image path: ${{needs.build_image.outputs.image_path}}"
whoami
uptime
pwd
uname -a
cat /etc/issue
HW_TYPE=$(echo $CONF | awk -F '_' '{print $1}')
HW_MODEL=$(echo $CONF | awk -F "_" '{if ($3 == "v2") print $2"_"$3; else print $2}')
echo "HW_TYPE ${HW_TYPE}, HW_MODEL ${HW_MODEL}"