Skip to content

Commit f769d49

Browse files
authored
Merge pull request #732 from gaozhangfei/master-ci
uadk: Add CI configuration
2 parents 8bbcb02 + 258ff7a commit f769d49

2 files changed

Lines changed: 163 additions & 0 deletions

File tree

.github/scripts/ci.sh

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

.github/workflows/ci.yml

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

0 commit comments

Comments
 (0)