Skip to content

Enhance the ability to find the python environment in build.sh #170

Enhance the ability to find the python environment in build.sh

Enhance the ability to find the python environment in build.sh #170

Workflow file for this run

name: Build and test for every PR
on:
workflow_dispatch:
pull_request:
types: [opened, reopened, synchronize]
permissions:
contents: write
jobs:
build_and_test:
name: build and test
runs-on: ubuntu-20.04
steps:
- name: Check out source code
uses: actions/checkout@v3
with:
submodules: 'recursive'
- name: prepare libraries
run: |
sudo apt update
sudo apt install -y make git pkg-config libssl-dev cmake binutils-dev libgoogle-glog-dev gcc g++ golang wget libgl1
sudo apt install -y python3.9 python3-dev python3-pip
sudo python3 -m pip install timeout_decorator numpy onnxruntime pytest opencv-python
# The version of ffmpeg installed via apt is 4.2, but the current test results are based on version 4.4, so here we need to compile version 4.4 of ffmpeg from source code
#apt install -y ffmpeg libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavresample-dev libavutil-dev libpostproc-dev libswresample-dev libswscale-dev
# When running unit tests, nasm/yasm installed via apt will cause the indicators to be misaligned, so it needs to be compiled from source code
#apt install -y nasm yasm
sudo scripts/build_ffmpeg.sh nasm yasm x264 x265 opus
- name: build
id: build
run: |
./build.sh debug
- name: set envs
run: |
echo "C_INCLUDE_PATH=${C_INCLUDE_PATH}:$(pwd)/output/bmf/include" >> $GITHUB_ENV
echo "CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}:$(pwd)/output/bmf/include" >> $GITHUB_ENV
echo "LIBRARY_PATH=${LIBRARY_PATH}:$(pwd)/output/bmf/lib" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$(pwd)/output/bmf/lib:/usr/local/lib" >> $GITHUB_ENV
echo "PYTHONPATH=$(pwd)/output/bmf/lib:$(pwd)/output" >> $GITHUB_ENV
echo "PATH=${PATH}:$(pwd)/output/bmf/bin" >> $GITHUB_ENV
echo "HMP_TEST_DATA_ROOT=$(pwd)/bmf/hml/tests/data" >> $GITHUB_ENV
- name: test
id: test
run: |
# install test modules for c++/python/go
sudo $(pwd)/output/bmf/bin/module_manager install python_copy_module python my_module:my_module $(pwd)/output/test/customize_module v0.0.1
sudo $(pwd)/output/bmf/bin/module_manager install cpp_copy_module c++ libcopy_module:CopyModule $(pwd)/output/test/c_module/lib v0.0.1
(cd $(pwd)/output/test/go_module && go build -buildmode c-shared -o lib/go_copy_module.so test_go_module.go)
sudo $(pwd)/output/bmf/bin/module_manager install go_copy_module go go_copy_module:PassThrough $(pwd)/output/test/go_module/lib v0.0.1
# download files
(cd output && wget https://github.com/BabitMF/bmf/releases/download/files/files.tar.gz && tar xvf files.tar.gz && rm -rf files.tar.gz)
(cd output && wget https://github.com/BabitMF/bmf/releases/download/files/models.tar.gz && tar xvf models.tar.gz && rm -rf models.tar.gz)
# test bmf
(cd output/bmf/bin && ./test_bmf_module_sdk && ./test_bmf_engine && ./test_cpp_builder)
#(cd output/bmf/bin && ./test_builtin_modules)
(cd output/demo/transcode && python3 test_transcode.py)
(cd output/demo/edit && python3 test_edit.py)
(cd output/demo/predict && python3 predict_sample.py)
(cd output/test/audio_copy && python3 test_simple.py)
(cd output/test/pre_module && python3 test_pre_module.py)
(cd output/test/sync_mode && python3 test_sync_mode.py)
(cd output/test/generator && python3 test_generator.py)
(cd output/test/run_by_config && python3 test_run_by_config.py)
(cd output/test/server && python3 test_server.py)
(cd output/test/c_module && python3 test_video_c_module.py)
(cd output/test/dynamical_graph && python3 dynamical_graph.py)
(cd output/test/av_log_buffer && python3 test_av_log_buffer.py)
(cd output/test/push_data_into_graph && python3 test_push_data.py)
(cd output/test/complex_edit_case && python3 test_complex_case.py)
(cd output/test/complex_edit_case && python3 test_compare_with_edit.py)
# test hmp
(cd bmf/hml/tests/data && ./gen.sh $(pwd)/../../../../output/files)
(cd bmf/hml/tests && pytest)
build_and_test_win:
name: build and test win
runs-on: windows-2019
steps:
- uses: actions/checkout@v4
- name: build_test
shell: pwsh
run: |
$bashPath = "C:\msys64\usr\bin\bash.exe"
$bashCommand = @'
export PATH=/usr/bin:/usr/lib:/usr/local/bin:/usr/local/lib:$PATH
python -V
python3 -V
echo $PATH
echo "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" | sed 's/[^0-9A-Za-z]/^&/g'
eval "$(./win_env/vcvarsall.sh x64)"
export INCLUDE="${INCLUDE};C:\\msys64\\usr\\local\\include"
wget https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-03-31-17-28/ffmpeg-n4.4.4-94-g5d07afd482-win64-gpl-shared-4.4.zip
pacman -S unzip --noconfirm
unzip ffmpeg-n4.4.4-94-g5d07afd482-win64-gpl-shared-4.4.zip
mkdir -p /usr/local
cp -r ffmpeg-n4.4.4-94-g5d07afd482-win64-gpl-shared-4.4/* /usr/local/
ls /usr/lib
ls /usr/include
ls /usr/bin
cmake -version
./build_win_lite.sh --msvc=2019 --preset=x64-Release bmf_ffmpeg
cmake --build build_win_lite/x64-Release --config Release --target ALL_BUILD
cmake --build build_win_lite/x64-Release --config Release --target ALL_BUILD
cmake --build build_win_lite/x64-Release --config Release --target ALL_BUILD
cp -r build_win_lite/x64-Release/output .
python -m pip install timeout_decorator numpy onnxruntime pytest opencv-python
export PYTHONHOME="$(dirname "$(which python)")"
export C_INCLUDE_PATH=${C_INCLUDE_PATH}:$(pwd)/output/bmf/include
export CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}:$(pwd)/output/bmf/include
export LIBRARY_PATH=${LIBRARY_PATH}:$(pwd)/output/bmf/lib
export PYTHONPATH=$(pwd)/output/bmf/lib:$(pwd)/output
export PATH=$(pwd)/3rd_party/win_rootfs/x64/usr/bin:$(pwd)/3rd_party/win_rootfs/x64/usr/lib:$(pwd)/output/bmf/bin:$(pwd)/output/bmf/lib:${PATH}
echo $PATH
echo $(pwd)
export HMP_TEST_DATA_ROOT=$(pwd)/bmf/hml/tests/data
run_bmf_graph
ffmpeg
module_manager
./output/bmf/bin/module_manager install python_copy_module python my_module:my_module $(pwd)/output/test/customize_module v0.0.1
./output/bmf/bin/module_manager install cpp_copy_module c++ copy_module:CopyModule $(pwd)/output/test/c_module/lib v0.0.1
(cd output && wget https://github.com/BabitMF/bmf/releases/download/files/files.tar.gz && tar xvf files.tar.gz && rm -rf files.tar.gz)
(cd output && wget https://github.com/BabitMF/bmf/releases/download/files/models.tar.gz && tar xvf models.tar.gz && rm -rf models.tar.gz)
cd output/bmf/bin
./test_bmf_module_sdk.exe
./test_bmf_engine.exe --gtest_filter=-go_module.module_loader
./test_cpp_builder.exe
cd -
export
ls output/bmf/lib
ls output/bmf/bin
which python
which python3
(cd output/demo/transcode && python test_transcode.py)
(cd output/demo/edit && python test_edit.py)
(cd output/demo/predict && python predict_sample.py)
(cd output/test/audio_copy && python test_simple.py)
(cd output/test/pre_module && python test_pre_module.py)
(cd output/test/sync_mode && python test_sync_mode.py)
(cd output/test/generator && python test_generator.py)
(cd output/test/run_by_config && python test_run_by_config.py)
(cd output/test/server && python test_server.py)
(cd output/test/c_module && python test_video_c_module.py)
(cd output/test/dynamical_graph && python dynamical_graph.py)
(cd output/test/av_log_buffer && python test_av_log_buffer.py)
(cd output/test/push_data_into_graph && python test_push_data.py)
(cd output/test/complex_edit_case && python test_complex_case.py)
(cd output/test/complex_edit_case && python test_compare_with_edit.py)
(cd bmf/hml/tests/data && ./gen.sh $(pwd)/../../../../output/files)
(cd bmf/hml/tests && python -m pytest)
'@
echo $bashCommand | & $bashPath