Skip to content

Commit c08f25a

Browse files
zhangfeigaogaozhangfei
authored andcommitted
uadk_engine: Add CI configuration
Signed-off-by: Zhangfei Gao <[email protected]>
1 parent 3460c05 commit c08f25a

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed

.github/scripts/ci.sh

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "=== CI start ==="
5+
echo "USER: $(whoami)"
6+
echo "DIR $(pwd)"
7+
8+
WORKSPACE="$(pwd)"
9+
BUILD_DIR="$(pwd)/deps"
10+
LOCK_FILE="/var/lock/uadk-lock"
11+
12+
lock() {
13+
exit_code=1
14+
pending=0
15+
while [ "$exit_code" != 0 ]; do
16+
exit_code=0
17+
mkdir ${LOCK_FILE} &> /dev/null || exit_code=$?
18+
if [ "$exit_code" != 0 ]; then
19+
if [ "$pending" = 0 ]; then
20+
# Some script is accessing hardware
21+
echo "Wait for other building script finishing."
22+
pending=1
23+
fi
24+
fi
25+
done
26+
}
27+
28+
unlock() {
29+
if [ -d ${LOCK_FILE} ]; then
30+
rmdir ${LOCK_FILE}
31+
echo "Release lock"
32+
fi
33+
}
34+
35+
trap 'unlock' EXIT
36+
37+
clean_previous_installations() {
38+
sudo rm -f /usr/local/lib/libwd*
39+
sudo rm -rf /usr/local/lib/uadk/
40+
}
41+
42+
detect_repository() {
43+
local current_repo=$(git config --get remote.origin.url)
44+
if [[ "$current_repo" == *"uadk" ]]; then
45+
echo "UADK_PR"
46+
elif [[ "$current_repo" == *"uadk_engine" ]]; then
47+
echo "UADK_ENGINE_PR"
48+
else
49+
echo "UNKNOWN"
50+
fi
51+
}
52+
53+
lock || exit 1
54+
clean_previous_installations
55+
56+
REPO_TYPE=$(detect_repository)
57+
echo "repo: $REPO_TYPE"
58+
59+
mkdir -p "$BUILD_DIR"
60+
sudo chmod 666 /dev/hisi_* 2>/dev/null || echo "/dev/hisi_* do not exist"
61+
62+
build_uadk() {
63+
./cleanup.sh
64+
./autogen.sh
65+
if [ -n "$1" ]; then
66+
./conf.sh "$1"
67+
else
68+
./conf.sh
69+
fi
70+
71+
make -j$(nproc)
72+
sudo make install
73+
74+
sudo ./test/sanity_test.sh
75+
}
76+
77+
build_uadk_engine() {
78+
version=$(openssl version)
79+
major_version=$(echo $version | awk -F'[ .]' '{print $2}')
80+
echo "OpenSSL major version is "$major_version
81+
82+
if (( major_version >= 3 )); then
83+
dir="/usr/local/lib/ossl-modules/"
84+
else
85+
dir="/usr/local/lib/engines-1.1/"
86+
fi
87+
88+
autoreconf -i
89+
./configure --libdir="$dir" CFLAGS=-Wall
90+
91+
make -j$(nproc)
92+
sudo make install
93+
94+
./test/sanity_test.sh
95+
}
96+
97+
case "$REPO_TYPE" in
98+
"UADK_PR")
99+
echo "=== CI UADK PR ==="
100+
build_uadk --static
101+
build_uadk
102+
103+
# verify uadk_engine
104+
cd "$BUILD_DIR"
105+
git clone --depth 1 https://github.com/Linaro/uadk_engine.git
106+
cd uadk_engine
107+
build_uadk_engine
108+
;;
109+
110+
"UADK_ENGINE_PR")
111+
echo "=== ci UADK Engine PR ==="
112+
113+
# install dependent uadk
114+
cd "$BUILD_DIR"
115+
git clone --depth 1 https://github.com/Linaro/uadk.git
116+
cd uadk
117+
build_uadk
118+
119+
# build current uadk_engine pr
120+
cd "$WORKSPACE"
121+
build_uadk_engine
122+
;;
123+
esac
124+
125+
echo "🎉 CI succeed: $REPO_TYPE"

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: UADK Engine CI
2+
3+
on:
4+
pull_request:
5+
branches: [ '**' ]
6+
7+
jobs:
8+
build-and-test:
9+
runs-on: [self-hosted, linux, arm64]
10+
11+
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Build and test UADK projects
16+
run: |
17+
chmod +x .github/scripts/ci.sh
18+
.github/scripts/ci.sh

0 commit comments

Comments
 (0)