Appbuilder-SDK组件新增增量组件规范性检测功能 #1391
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python | |
name: Python package | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
Pylint: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.12.5"] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install flake8 pytest | |
python -m pip install chainlit~=1.0.200 flask~=2.3.2 flask-restful==0.3.9 | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Lint with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | |
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | |
Linux-CI-Tests: | |
runs-on: ubuntu-latest | |
env: | |
APPBUILDER_TOKEN: bce-v3/ALTAK-RPJR9XSOVFl6mb5GxHbfU/072be74731e368d8bbb628a8941ec50aaeba01cd | |
APPBUILDER_TOKEN_V2: bce-v3/ALTAK-xKvnRD8ybhsGkN88XxZ6Z/34adbccbc144e9677f8d244ee83271f9a11a70f7 | |
BAIDU_VDB_API_KEY: apaasTest1 | |
INSTANCE_ID: vdb-bj-vuzmppgqrnhv | |
DATASET_ID: 56e82915-9642-4a03-bb02-74744c17863e | |
APPBUILDER_TOKEN_DOC_FORMAT: bce-v3/ALTAK-bcKsgHd39g0Aaq3nCYUUQ/b06384229df1462c6fb011383d09230346a20ac4 | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.9","3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Print ENV | |
run: | | |
env | |
ls | |
pwd | |
- name: Git Clone And Checkout Branch | |
run: | | |
fork_repo="https://github.com/$GITHUB_ACTOR/app-builder.git" | |
mkdir cicd | |
cd cicd | |
git clone $fork_repo | |
cd app-builder | |
git checkout $GITHUB_HEAD_REF | |
git remote add upstream https://github.com/baidubce/app-builder.git | |
git fetch upstream | |
git remote -v | |
git status | |
# 找到当前分支与 upstream/master 的共同祖先提交 | |
merge_base=$(git merge-base HEAD upstream/master) | |
echo "merge_base=$merge_base" | |
# 比较当前分支与 merge_base 之间的差异 | |
changed_files=$(git diff --name-only --diff-filter=ACMRT $merge_base) | |
changed_files_py_sh=$(git diff --name-only --diff-filter=ACMRT $merge_base -- 'appbuilder/**') | |
echo "发生更改的文件为:" | |
echo "$changed_files" | |
echo "发生更改的py/sh文件为:" | |
if [ -n "$changed_files_py_sh" ]; then | |
export APPBUILDER_PYTHON_TESTS=True | |
echo "$changed_files_py_sh" | |
else | |
export APPBUILDER_PYTHON_TESTS=False | |
echo "没有检测到Python或Shell文件被更改" | |
fi | |
echo "APPBUILDER_PYTHON_TESTS=$APPBUILDER_PYTHON_TESTS" >> $GITHUB_ENV | |
pwd | |
- name: Install dependencies | |
run: | | |
echo $APPBUILDER_PYTHON_TESTS | |
if [ "$APPBUILDER_PYTHON_TESTS" = "False" ]; then | |
echo "环境变量APPBUILDER_PYTHON_TESTS为False,没有检测到Python或Shell文件被更改,跳过Install dependencies部分。" | |
else | |
echo "检测到Python或Shell文件被更改(根据环境变量APPBUILDER_PYTHON_TESTS),准备启动单元测试Install dependencies部分..." | |
cd cicd/app-builder | |
pwd | |
sudo apt-get install ffmpeg libavcodec-extra | |
python3 -m ensurepip --upgrade | |
python3 -m pip install --upgrade pip | |
python3 -m pip install --upgrade setuptools | |
python3 -m pip install wheel | |
python3 -m pip install coverage | |
python3 -m pip install diff-cover | |
python3 -m pip install pydub | |
python3 -m pip install SQLAlchemy==2.0.31 | |
python3 -m pip install chainlit~=1.0.200 flask~=2.3.2 flask-restful==0.3.9 | |
python3 -m pip install opentelemetry-exporter-otlp==1.23.0 opentelemetry-instrumentation==0.44b0 opentelemetry-sdk==1.23.0 opentelemetry-api==1.23.0 | |
python3 -m pip install pandas==2.2.2 | |
fi | |
- name: Build whl | |
run: | | |
echo $APPBUILDER_PYTHON_TESTS | |
if [ "$APPBUILDER_PYTHON_TESTS" = "False" ]; then | |
echo "环境变量APPBUILDER_PYTHON_TESTS为False,没有检测到Python或Shell文件被更改,跳过Build whl部分。" | |
else | |
echo "检测到Python或Shell文件被更改(根据环境变量APPBUILDER_PYTHON_TESTS),准备启动单元测试Build whl部分..." | |
cd cicd/app-builder | |
pwd | |
python3 setup.py bdist_wheel | |
python3 -m pip uninstall -y appbuilder-sdk | |
python3 -m pip install dist/*.whl | |
fi | |
- name: Test with unittest | |
run: | | |
echo $APPBUILDER_PYTHON_TESTS | |
if [ "$APPBUILDER_PYTHON_TESTS" = "False" ]; then | |
echo "环境变量APPBUILDER_PYTHON_TESTS为False,没有检测到Python或Shell文件被更改,跳过Test with unittest部分。" | |
else | |
echo "检测到Python或Shell文件被更改(根据环境变量APPBUILDER_PYTHON_TESTS),准备启动单元测试Test with unittest部分..." | |
cd cicd/app-builder | |
pwd | |
sh appbuilder/tests/run_python_test.sh | |
fi |