Enhancement: Update configuration and improve error handling in netwo… #1574
Workflow file for this run
This file contains hidden or 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
| name: build package | |
| on: | |
| pull_request: | |
| branches: | |
| - master | |
| push: | |
| branches: | |
| - master | |
| env: | |
| ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true | |
| jobs: | |
| cancel: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Cancel Previous Runs | |
| uses: styfle/cancel-workflow-action@0.12.1 | |
| build-rpm: | |
| name: Run on CentOS 7 | |
| needs: cancel | |
| runs-on: ubuntu-latest | |
| container: | |
| image: "registry.openanolis.cn/openanolis/anolisos:23.4" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Install dependencies and build obdiag rpm | |
| run: | | |
| yum install -y wget rpm-build gcc gcc-c++ make | |
| wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh --no-check-certificate | |
| sh Miniconda3-latest-Linux-x86_64.sh -p /opt/miniconda3 -b | |
| export PATH=/opt/miniconda3/bin:$PATH | |
| /opt/miniconda3/bin/conda init | |
| /opt/miniconda3/bin/conda create --name obdiag python=3.11 -y | |
| source /opt/miniconda3/bin/activate obdiag | |
| /opt/miniconda3/envs/obdiag/bin/python3 -m pip install --upgrade pip setuptools wheel | |
| source activate obdiag | |
| pip3 install .[build] | |
| make pack | |
| - name: "Upload rpm" | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: obdiag-rpm-packages | |
| path: | | |
| /github/home/rpmbuild/RPMS/x86_64/oceanbase-diagnostic-tool-*.rpm | |
| retention-days: 3 | |
| convert-to-deb: | |
| needs: build-rpm | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Download RPM Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: obdiag-rpm-packages | |
| path: . | |
| - name: Install Alien | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y alien | |
| - name: Convert RPM to DEB | |
| run: | | |
| sudo alien -k --scripts oceanbase-diagnostic-tool-*.rpm | |
| pwd | |
| - name: Upload DEB Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: obdiag-deb-package | |
| path: ./oceanbase-diagnostic-tool_*.deb | |
| retention-days: 3 | |
| build-macos-arm: | |
| name: Build macOS ARM64 Package | |
| needs: cancel | |
| runs-on: macos-14 # Apple Silicon (M1/M2) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Setup Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Get version and release info | |
| id: version | |
| run: | | |
| VERSION=$(grep -E "^OBDIAG_VERSION" Makefile | head -1 | cut -d'=' -f2 | tr -d ' ' || echo "4.0.0") | |
| RELEASE=$(date +%Y%m%d%H%M) | |
| ARCH=$(uname -m) | |
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
| echo "release=${RELEASE}" >> $GITHUB_OUTPUT | |
| echo "arch=${ARCH}" >> $GITHUB_OUTPUT | |
| echo "Building version: ${VERSION}, release: ${RELEASE}, arch: ${ARCH}" | |
| - name: Install dependencies | |
| run: | | |
| python3 -m pip install --upgrade pip setuptools wheel | |
| # Install project (macos extras: pyzipper instead of pyminizip) and build tools | |
| pip3 install .[macos,build] | |
| pip3 uninstall -y pyminizip 2>/dev/null || true | |
| pip3 install pyzipper==0.3.6 | |
| - name: Update version info | |
| run: | | |
| BUILD_TIME=$(date "+%Y-%m-%d %H:%M:%S") | |
| VERSION=${{ steps.version.outputs.version }} | |
| sed -i '' "s/<B_TIME>/${BUILD_TIME}/g" ./src/common/version.py | |
| sed -i '' "s/<VERSION>/${VERSION}/g" ./src/common/version.py | |
| - name: Build macOS binary with PyInstaller | |
| run: | | |
| cp src/main.py src/obdiag.py | |
| pyinstaller \ | |
| --name obdiag \ | |
| --onefile \ | |
| --hidden-import=decimal \ | |
| --hidden-import=pyzipper \ | |
| --hidden-import=pymysql \ | |
| --hidden-import=paramiko \ | |
| --hidden-import=yaml \ | |
| --hidden-import=jinja2 \ | |
| --hidden-import=requests \ | |
| --hidden-import=tabulate \ | |
| --hidden-import=prettytable \ | |
| --hidden-import=colorama \ | |
| --paths="./src" \ | |
| --clean \ | |
| src/obdiag.py | |
| rm -f src/obdiag.py | |
| - name: Create distribution package | |
| run: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| RELEASE=${{ steps.version.outputs.release }} | |
| ARCH=${{ steps.version.outputs.arch }} | |
| PKG_NAME="obdiag-${VERSION}-${RELEASE}-macos-${ARCH}" | |
| mkdir -p dist_pkg/${PKG_NAME}/{bin,plugins,conf,example,resources} | |
| # Copy binary | |
| cp dist/obdiag dist_pkg/${PKG_NAME}/bin/ | |
| chmod +x dist_pkg/${PKG_NAME}/bin/obdiag | |
| # Copy plugins, conf, example, resources | |
| cp -r plugins/* dist_pkg/${PKG_NAME}/plugins/ | |
| cp -r conf/* dist_pkg/${PKG_NAME}/conf/ | |
| cp -r example/* dist_pkg/${PKG_NAME}/example/ | |
| cp -r resources/* dist_pkg/${PKG_NAME}/resources/ 2>/dev/null || true | |
| # Copy install scripts | |
| cp macos/install.sh dist_pkg/${PKG_NAME}/ | |
| cp macos/uninstall.sh dist_pkg/${PKG_NAME}/ | |
| chmod +x dist_pkg/${PKG_NAME}/*.sh | |
| # Create README | |
| cat > dist_pkg/${PKG_NAME}/README.txt << EOF | |
| OceanBase Diagnostic Tool - macOS Package | |
| ========================================== | |
| Version: ${VERSION} | |
| Build: ${RELEASE} | |
| Arch: ${ARCH} | |
| Installation: | |
| ./install.sh | |
| Usage: | |
| obdiag --help | |
| More Info: | |
| https://github.com/oceanbase/obdiag | |
| EOF | |
| # Create archives | |
| cd dist_pkg | |
| tar -czf ${PKG_NAME}.tar.gz ${PKG_NAME} | |
| zip -r ${PKG_NAME}.zip ${PKG_NAME} | |
| # Show results | |
| ls -lh ${PKG_NAME}.* | |
| shasum -a 256 ${PKG_NAME}.* | |
| - name: Upload macOS ARM64 Package | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: obdiag-macos-arm64-package | |
| path: | | |
| dist_pkg/*.tar.gz | |
| dist_pkg/*.zip | |
| retention-days: 3 | |
| run-with-observer: | |
| name: run-with-observer | |
| runs-on: ubuntu-latest | |
| needs: build-rpm | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Download RPM Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: obdiag-rpm-packages | |
| path: . | |
| - name: install obdiag | |
| run: | | |
| set -e | |
| docker run -id --name "obdiag_ob" oceanbase/oceanbase-ce:latest | |
| bash workflow_data/wait_observer_run.sh | |
| docker cp oceanbase-diagnostic-tool-*.rpm obdiag_ob:/root/ | |
| docker exec -i obdiag_ob /bin/bash -c "rpm -ivh /root/oceanbase-diagnostic-tool-*.rpm" | |
| docker cp workflow_data/config.yml obdiag_ob:/root/.obdiag/config.yml | |
| - name: run obdiag test | |
| run: | | |
| set -e | |
| docker cp workflow_data/run_obdiag_test.sh obdiag_ob:/root/run_obdiag_test.sh | |
| docker exec -i obdiag_ob /bin/bash -c "obclient -h127.0.0.1 -u root -P2881 -e 'select version();'" | |
| docker exec -i obdiag_ob /bin/bash -c "export tag=latest && sh /root/run_obdiag_test.sh" | |
| echo "obdiag install success" | |
| docker rm -f obdiag_ob | |
| run-with-observer-4_2_1: | |
| name: run-with-observer-4_2_1 | |
| runs-on: ubuntu-latest | |
| needs: build-rpm | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Download RPM Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: obdiag-rpm-packages | |
| path: . | |
| - name: install obdiag | |
| run: | | |
| set -e | |
| export tag="4.2.1" | |
| docker run -id --name "obdiag_ob" -e tag=${tag} oceanbase/oceanbase-ce:${tag} | |
| bash workflow_data/wait_observer_run.sh | |
| docker cp oceanbase-diagnostic-tool-*.rpm obdiag_ob:/root/ | |
| docker exec -i obdiag_ob /bin/bash -c "rpm -ivh /root/oceanbase-diagnostic-tool-*.rpm" | |
| docker cp workflow_data/config.yml.421 obdiag_ob:/root/.obdiag/config.yml | |
| - name: run obdiag test | |
| run: | | |
| set -e | |
| docker cp workflow_data/run_obdiag_test.sh obdiag_ob:/root/run_obdiag_test.sh | |
| docker exec -i obdiag_ob /bin/bash -c "export tag=4.2.1 && sh /root/run_obdiag_test.sh" | |
| echo "obdiag install success" | |
| docker rm -f obdiag_ob | |
| run-with-observer-4_2_5: | |
| name: run-with-observer-4_2_5 | |
| runs-on: ubuntu-latest | |
| needs: build-rpm | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Download RPM Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: obdiag-rpm-packages | |
| path: . | |
| - name: install obdiag | |
| run: | | |
| set -e | |
| export tag="4.2.5" | |
| docker run -id --name "obdiag_ob" -e tag=${tag} oceanbase/oceanbase-ce:4.2.5.1-101000092024120918 | |
| bash workflow_data/wait_observer_run.sh | |
| docker cp oceanbase-diagnostic-tool-*.rpm obdiag_ob:/root/ | |
| docker exec -i obdiag_ob /bin/bash -c "rpm -ivh /root/oceanbase-diagnostic-tool-*.rpm" | |
| docker cp workflow_data/config.yml.421 obdiag_ob:/root/.obdiag/config.yml | |
| - name: run obdiag test | |
| run: | | |
| set -e | |
| docker cp workflow_data/run_obdiag_test.sh obdiag_ob:/root/run_obdiag_test.sh | |
| docker exec -i obdiag_ob /bin/bash -c "export tag=4.2.5 && sh /root/run_obdiag_test.sh" | |
| echo "obdiag install success" | |
| docker rm -f obdiag_ob | |
| run-with-observer-4_3_5: | |
| name: run-with-observer-4_3_5 | |
| runs-on: ubuntu-latest | |
| needs: build-rpm | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Download RPM Artifact | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: obdiag-rpm-packages | |
| path: . | |
| - name: install obdiag | |
| run: | | |
| set -e | |
| export tag="4.3.5" | |
| docker run -id --name "obdiag_ob" -e tag=${tag} oceanbase/oceanbase-ce:4.3.5-lts | |
| bash workflow_data/wait_observer_run.sh | |
| docker cp oceanbase-diagnostic-tool-*.rpm obdiag_ob:/root/ | |
| docker exec -i obdiag_ob /bin/bash -c "rpm -ivh /root/oceanbase-diagnostic-tool-*.rpm" | |
| docker cp workflow_data/config.yml obdiag_ob:/root/.obdiag/config.yml | |
| - name: run obdiag test | |
| run: | | |
| set -e | |
| docker cp workflow_data/run_obdiag_test.sh obdiag_ob:/root/run_obdiag_test.sh | |
| docker exec -i obdiag_ob /bin/bash -c "export tag=4.3.5 && sh /root/run_obdiag_test.sh" | |
| echo "obdiag install success" | |
| docker rm -f obdiag_ob |