Skip to content

Fix somebugs 500 (#1245) #1733

Fix somebugs 500 (#1245)

Fix somebugs 500 (#1245) #1733

Workflow file for this run

name: build package
on:
pull_request:
branches:
- master
push:
branches:
- master
# Replaces separate cancel job: supersede in-flight runs on the same ref.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
DEBIAN_FRONTEND: noninteractive
jobs:
build-rpm:
name: Run on CentOS 8
runs-on: ubuntu-latest
container:
image: "oceanbase/obdiag-builder:latest"
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Install dependencies and build obdiag rpm
run: |
/opt/miniconda3/bin/conda create --name obdiag311 python=3.11 -y
source /opt/miniconda3/bin/activate obdiag311
pip3 install .[build]
make pack
- name: "Upload rpm"
uses: actions/upload-artifact@v6
with:
name: obdiag-rpm-packages
path: |
/github/home/rpmbuild/RPMS/x86_64/oceanbase-diagnostic-tool-*.rpm
retention-days: 3
build-rpm-centos7:
name: Build RPM on CentOS 7
runs-on: ubuntu-latest
env:
DOCKER_BUILDKIT: 1
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Docker build (CentOS 7 image; make pack inside image)
run: |
set -eux
docker build -t obdiag-builder-centos7 -f dockerfiles/Dockerfile.builder-centos7 .
- name: Copy RPM out of image
run: |
set -eux
mkdir -p centos7-rpm-out
docker run --rm \
-v "${GITHUB_WORKSPACE}/centos7-rpm-out:/out" \
--entrypoint /bin/bash \
obdiag-builder-centos7 \
-c 'shopt -s nullglob; rpms=(/obdiag/oceanbase-diagnostic-tool-*.rpm); if [ ${#rpms[@]} -eq 0 ]; then echo "No RPM under /obdiag (WORKDIR where make pack runs)"; ls -la /obdiag; exit 1; fi; cp -av "${rpms[@]}" /out/'
- name: Upload rpm (CentOS 7)
uses: actions/upload-artifact@v6
with:
name: obdiag-rpm-packages-centos7
path: centos7-rpm-out/oceanbase-diagnostic-tool-*.rpm
retention-days: 3
build-deb:
name: Build Ubuntu/Debian Package
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Python 3.11
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y dpkg-dev
- 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)
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "release=${RELEASE}" >> $GITHUB_OUTPUT
echo "Building version: ${VERSION}, release: ${RELEASE}"
- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip setuptools wheel
pip3 install .[build]
- name: Build Ubuntu/Debian package
run: |
chmod +x ./ubuntu/build_ubuntu.sh
./ubuntu/build_ubuntu.sh ${{ steps.version.outputs.version }} ${{ steps.version.outputs.release }}
- name: Upload DEB Artifact
uses: actions/upload-artifact@v6
with:
name: obdiag-deb-package-native
path: ./oceanbase-diagnostic-tool_*.deb
retention-days: 3
test-deb-install:
name: Test DEB Installation on Ubuntu
needs: build-deb
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Download DEB Artifact
uses: actions/download-artifact@v7
with:
name: obdiag-deb-package-native
path: .
- name: Install and verify obdiag
run: |
set -eux
sudo dpkg -i oceanbase-diagnostic-tool_*.deb
obdiag --version
obdiag --help
which obdiag
- name: Uninstall obdiag
run: |
set -eux
sudo dpkg --remove oceanbase-diagnostic-tool
! which obdiag || echo "obdiag still exists after uninstall"
convert-to-deb:
name: Convert RPM to DEB (Legacy)
needs: build-rpm
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Download RPM Artifact
uses: actions/download-artifact@v7
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: |
set -eux
sudo alien -k --scripts oceanbase-diagnostic-tool-*.rpm
- name: Upload DEB Artifact
uses: actions/upload-artifact@v6
with:
name: obdiag-deb-package
path: ./oceanbase-diagnostic-tool_*.deb
retention-days: 3
build-macos-arm:
name: Build macOS ARM64 Package
runs-on: macos-14 # Apple Silicon (M1/M2)
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Setup Python 3.11
uses: actions/setup-python@v6
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@v6
with:
name: obdiag-macos-arm64-package
path: |
dist_pkg/*.tar.gz
dist_pkg/*.zip
retention-days: 3
run-with-observer:
name: run-with-observer (${{ matrix.name }})
runs-on: ubuntu-latest
needs: build-rpm
strategy:
fail-fast: false
matrix:
include:
- name: latest
ce_image: oceanbase/oceanbase-ce:latest
pass_tag_env: "false"
test_tag: latest
config_file: workflow_data/config.yml
- name: ce-4.2.1
ce_image: oceanbase/oceanbase-ce:4.2.1
pass_tag_env: "true"
test_tag: "4.2.1"
config_file: workflow_data/config.yml.421
- name: ce-4.2.5
ce_image: oceanbase/oceanbase-ce:4.2.5.1-101000092024120918
pass_tag_env: "true"
test_tag: "4.2.5"
config_file: workflow_data/config.yml.421
- name: ce-4.3.5-lts
ce_image: oceanbase/oceanbase-ce:4.3.5-lts
pass_tag_env: "true"
test_tag: "4.3.5"
config_file: workflow_data/config.yml
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Download RPM Artifact
uses: actions/download-artifact@v7
with:
name: obdiag-rpm-packages
path: .
- name: install obdiag
run: |
set -eux
IMG='${{ matrix.ce_image }}'
TEST_TAG='${{ matrix.test_tag }}'
CONFIG='${{ matrix.config_file }}'
if [ "${{ matrix.pass_tag_env }}" = "true" ]; then
docker run -id --name obdiag_ob -e tag="$TEST_TAG" "$IMG"
else
docker run -id --name obdiag_ob "$IMG"
fi
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 "$CONFIG" obdiag_ob:/root/.obdiag/config.yml
- name: run obdiag test
run: |
set -eux
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=${{ matrix.test_tag }} && sh /root/run_obdiag_test.sh"
echo "obdiag install success"
docker rm -f obdiag_ob