Skip to content

Commit b45ad00

Browse files
am64x/am243x: workflow: add github workflow for build
- add workflow for doing build check on github PRs Fixes: SITSW-6357 Signed-off-by: Venkatesan Krishnamoorthy <v-krishnamoorthy@ti.com>
1 parent 3542d46 commit b45ad00

2 files changed

Lines changed: 329 additions & 0 deletions

File tree

.github/workflows/build-test.sh

Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
#
2+
# Copyright (C) 2025 Texas Instruments Incorporated.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions
6+
# are met:
7+
#
8+
# Redistributions of source code must retain the above copyright
9+
# notice, this list of conditions and the following disclaimer.
10+
#
11+
# Redistributions in binary form must reproduce the above copyright
12+
# notice, this list of conditions and the following disclaimer in the
13+
# documentation and/or other materials provided with the
14+
# distribution.
15+
#
16+
# Neither the name of Texas Instruments Incorporated nor the names of
17+
# its contributors may be used to endorse or promote products derived
18+
# from this software without specific prior written permission.
19+
#
20+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
#
32+
33+
34+
#########################################################################
35+
# Params #
36+
#########################################################################
37+
#Get user input
38+
while [ $# -gt 0 ]; do
39+
case "$1" in
40+
--device=*)
41+
device="${1#*=}"
42+
;;
43+
--profile_list=*)
44+
profile_list="${1#*=}"
45+
;;
46+
--enable_test_build=*)
47+
enable_test_build="${1#*=}"
48+
;;
49+
-h|--help)
50+
echo Usage: $0 [options]
51+
echo
52+
echo Options:
53+
echo --device Device to be built
54+
echo --profile_list Profile list separated by comma to be built. Default to release,debug
55+
echo --enable_test_build Enable test build
56+
exit 0
57+
;;
58+
*)
59+
printf "Error: Invalid argument $1!!\n"
60+
esac
61+
shift
62+
done
63+
64+
#Default value if not provided
65+
: ${device:="am64x"}
66+
: ${enable_test_build:="true"}
67+
: ${profile_list:="debug,release"}
68+
69+
#Convert , to space
70+
profile_list=`echo ${profile_list} | sed -e "s|\,| |g"`
71+
72+
#########################################################################
73+
# Log files #
74+
#########################################################################
75+
log_dir=$GITHUB_WORKSPACE/logs
76+
build_dir=$GITHUB_WORKSPACE/mcu_plus_sdk
77+
pr_checkout_dir=$GITHUB_WORKSPACE/pr_checkout
78+
build_log=${log_dir}/build.log
79+
build_error_log=${log_dir}/build_error.log
80+
81+
82+
#########################################################################
83+
# Functions #
84+
#########################################################################
85+
print_time_diff() {
86+
local end_time=$(date +%s)
87+
local start_time=$1
88+
local deltatime=$(( end_time-start_time ))
89+
local hours=$(( deltatime/3600 ))
90+
local minutes=$(( deltatime/60 ))
91+
local minutes=$(( minutes%60 ))
92+
local seconds=$(( deltatime%60 ))
93+
printf "$2: %d:%02d:%02d\n" $hours $minutes $seconds
94+
printf " \n"
95+
}
96+
97+
make_folders() {
98+
echo "Making required folder..."
99+
mkdir -p ${log_dir}
100+
echo "Making required folder ... Done"
101+
echo " "
102+
}
103+
104+
proc=`nproc`
105+
repo_init() {
106+
mkdir workarea
107+
cd workaread
108+
echo "Doing repo init and sync ..."
109+
local start_time=`date +%s`
110+
sudo apt-get update
111+
sudo apt-get -y install repo
112+
113+
repo init -u https://github.com/TexasInstruments/mcupsdk-manifests.git -m ${device}/dev.xml -b main --depth=1
114+
repo sync -j${proc} -q
115+
116+
#Show the current branch/git status
117+
repo forall -c "pwd;git branch -vv | cut -d ' ' -f 1-4"
118+
119+
print_time_diff $start_time "Repo Init Time"
120+
echo "Doing repo init and sync ... Done"
121+
echo " "
122+
123+
#Checkout the PR
124+
pushd ${build_dir} 1>/dev/null
125+
126+
git fetch origin pull/${PR_NUMBER}/head:pr_${PR_NUMBER} -q
127+
git switch pr_${PR_NUMBER}
128+
git log --oneline -n5
129+
popd 1>/dev/null
130+
131+
}
132+
133+
download_components() {
134+
echo "Downloading Components ..."
135+
136+
local start_time=`date +%s`
137+
138+
mkdir ${HOME}/ti
139+
140+
find ./mcupsdk_setup -name "*.sh" -execdir chmod u+x {} +
141+
./mcupsdk_setup/${device}/download_components.sh --skip_ccs=true
142+
pip3 install pyserial xmodem tqdm pyelftools construct
143+
144+
print_time_diff $start_time "Download Components Time"
145+
echo "Downloading Components ... Done"
146+
echo " "
147+
}
148+
149+
check_logs() {
150+
if [ -e ${build_error_log} ]; then
151+
if [ -s ${build_error_log} ]; then
152+
echo "Build for SOC $device failed ...."
153+
echo
154+
echo
155+
cat ${build_error_log}
156+
exit 1
157+
fi
158+
fi
159+
}
160+
161+
build_sdk() {
162+
echo "Build SDK ..."
163+
local start_time=`date +%s`
164+
165+
pushd ${build_dir} 1>/dev/null
166+
167+
#Scrub build files
168+
169+
echo " Scrub Build Files for DEVICE:${device} ..."
170+
make -s ${jobs_option} scrub DEVICE=${device} 1>>${build_log} 2>>${build_error_log}
171+
make -s gen-buildfiles-clean DEVICE=${device} 1>>${build_log} 2>>${build_error_log}
172+
echo " Scrub Build Files for DEVICE:${device} completed!!"
173+
check_logs
174+
175+
echo " Generate Build Files for DEVICE:${device} ..."
176+
make -s gen-buildfiles DEVICE=${device} 1>>${build_log} 2>>${build_error_log}
177+
echo " Generate Build Files for DEVICE:${device} completed!!"
178+
check_logs
179+
180+
for profile in ${profile_list}
181+
do
182+
echo " Building for DEVICE:${device} PROFILE:${profile} ..."
183+
make -s -j${proc} all DEVICE=${device} PROFILE=${profile} 1>>${build_log} 2>>${build_error_log}
184+
echo " Building for DEVICE:${device} PROFILE:${profile} completed!!"
185+
check_logs
186+
done
187+
188+
if [ "${enable_test_build}" == "true" ]; then
189+
for profile in ${profile_list}
190+
do
191+
echo " Building Tests for DEVICE:${device} PROFILE:${profile} ..."
192+
make -s -j${proc} tests DEVICE=${device} PROFILE=${profile} 1>>${build_log} 2>>${build_error_log}
193+
echo " Building Tests for DEVICE:${device} PROFILE:${profile} completed!!"
194+
check_logs
195+
done
196+
fi
197+
198+
echo " Generate docs for DEVICE:${device} ..."
199+
make -s docs DEVICE=${device} 1>>${build_log} 2>>${build_error_log}
200+
echo " Generate docs for DEVICE:${device} completed!!"
201+
#Redirect doxy error
202+
cat docs_src/docs/api_guide/doxy_warnings_${device}.txt >> ${build_error_log}
203+
check_logs
204+
205+
popd 1>/dev/null
206+
207+
print_time_diff $start_time "Build Time"
208+
echo "Build SDK ... Done"
209+
}
210+
211+
#########################################################################
212+
# Script run #
213+
#########################################################################
214+
make_folders
215+
repo_init
216+
download_components
217+
build_sdk

.github/workflows/build-test.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Build Test
2+
3+
env:
4+
PR_NUMBER: ${{ github.event.number }}
5+
6+
# Controls when the workflow will run
7+
on:
8+
# Triggers the workflow on push or pull request events but only for the $default-branch branch
9+
push:
10+
branches: [ "next", "next_stage" ]
11+
pull_request:
12+
branches: [ "next", "next_stage" ]
13+
14+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
15+
jobs:
16+
# This workflow contains a build jobs for all the SOCs in the repo
17+
build_am64x:
18+
# The type of runner that the job will run on
19+
runs-on: ubuntu-22.04
20+
21+
# Steps represent a sequence of tasks that will be executed as part of the job
22+
steps:
23+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
24+
- uses: actions/checkout@v4
25+
with:
26+
# Relative path under $GITHUB_WORKSPACE to place the repository
27+
path: 'pr_checkout'
28+
29+
# Runs a single command using the runners shell
30+
- name: build_test
31+
run: |
32+
cp ./pr_checkout/.github/workflows/build-test.sh .
33+
chmod +x ./build-test.sh
34+
./build-test.sh --device=am64x
35+
36+
37+
build_am243x:
38+
# The type of runner that the job will run on
39+
runs-on: ubuntu-22.04
40+
41+
# Steps represent a sequence of tasks that will be executed as part of the job
42+
steps:
43+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
44+
- uses: actions/checkout@v4
45+
with:
46+
# Relative path under $GITHUB_WORKSPACE to place the repository
47+
path: 'pr_checkout'
48+
49+
# Runs a single command using the runners shell
50+
- name: build_test
51+
run: |
52+
cp ./pr_checkout/.github/workflows/build-test.sh .
53+
chmod +x ./build-test.sh
54+
./build-test.sh --device=am243x
55+
56+
build_am263x:
57+
# The type of runner that the job will run on
58+
runs-on: ubuntu-22.04
59+
60+
# Steps represent a sequence of tasks that will be executed as part of the job
61+
steps:
62+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
63+
- uses: actions/checkout@v4
64+
with:
65+
# Relative path under $GITHUB_WORKSPACE to place the repository
66+
path: 'pr_checkout'
67+
68+
# Runs a single command using the runners shell
69+
- name: build_test
70+
run: |
71+
cp ./pr_checkout/.github/workflows/build-test.sh .
72+
chmod +x ./build-test.sh
73+
./build-test.sh --device=am263x
74+
75+
build_am263px:
76+
# The type of runner that the job will run on
77+
runs-on: ubuntu-22.04
78+
79+
# Steps represent a sequence of tasks that will be executed as part of the job
80+
steps:
81+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
82+
- uses: actions/checkout@v4
83+
with:
84+
# Relative path under $GITHUB_WORKSPACE to place the repository
85+
path: 'pr_checkout'
86+
87+
# Runs a single command using the runners shell
88+
- name: build_test
89+
run: |
90+
cp ./pr_checkout/.github/workflows/build-test.sh .
91+
chmod +x ./build-test.sh
92+
./build-test.sh --device=am263px
93+
94+
build_am273x:
95+
# The type of runner that the job will run on
96+
runs-on: ubuntu-22.04
97+
98+
# Steps represent a sequence of tasks that will be executed as part of the job
99+
steps:
100+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
101+
- uses: actions/checkout@v4
102+
with:
103+
# Relative path under $GITHUB_WORKSPACE to place the repository
104+
path: 'pr_checkout'
105+
106+
# Runs a single command using the runners shell
107+
- name: build_test
108+
run: |
109+
cp ./pr_checkout/.github/workflows/build-test.sh .
110+
chmod +x ./build-test.sh
111+
./build-test.sh --device=am273x
112+

0 commit comments

Comments
 (0)