Skip to content

Commit

Permalink
build: add oceanbase-ce CI workflow (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
whhe authored Jun 5, 2024
1 parent a344cdf commit 11848cd
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
55 changes: 55 additions & 0 deletions .github/workflows/ci-oceanbase-ce.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: oceanbase-ce

on:
push:
paths:
- '.github/workflows/ci-oceanbase-ce.yml'
- 'oceanbase-ce/**'
pull_request:
paths:
- '.github/workflows/ci-oceanbase-ce.yml'
- 'oceanbase-ce/**'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4

- name: Build Docker image
run: ./oceanbase-ce/docker_build.sh

- name: Export Docker image
run: docker save -o oceanbase-ce.tar oceanbase-ce

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: oceanbase-ce
path: oceanbase-ce.tar

test-slim:
runs-on: ubuntu-latest
needs: build
steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: oceanbase-ce
path: /tmp

- name: Load Docker image
run: docker load -i /tmp/oceanbase-ce.tar

- name: Start Docker container
uses: oceanbase/setup-oceanbase-ce@v1
with:
image_name: oceanbase-ce
container_name: ob-slim
fastboot: false

- name: Test Docker container
run: |
docker exec ob-slim obclient -h127.0.0.1 -P2881 -uroot -e 'select version()'
docker exec ob-slim obclient -h127.0.0.1 -P2881 -uroot@test -e 'show databases'
20 changes: 19 additions & 1 deletion oceanbase-ce/docker_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ ACTUAL_INIT_STORE_PY_SCRIPT="init_store_for_fast_start.py"
CWD=$(cd `dirname $0`;pwd)
cd "${CWD}"

function boot_raw_observer() {
log_file="raw_observer.log"

docker run --name raw_observer -v ${CWD}/boot:/root/dest -d raw_observer
docker logs -f raw_observer > "$log_file" 2>&1 &

while true; do
while IFS= read -r line; do
echo "$line"
if [[ "$line" == *"prepare fast boot finish"* ]]; then
return 0
elif [[ "$line" == *"prepare fast boot failed"* ]]; then
return -1
fi
done < <(tail -f "$log_file")
done
}

function fast_boot_docker_build() {
rm -rf boot
cp -r step_1_boot boot
Expand All @@ -27,7 +45,7 @@ function fast_boot_docker_build() {
rm -rf boot

cd "${CWD}" && mkdir -p ${CWD}/boot/etc
docker run -it -v ${CWD}/boot:/root/dest raw_observer
boot_raw_observer
if [ $? == 0 ]; then
echo "================== prepare docker run ok ==============="
else
Expand Down

0 comments on commit 11848cd

Please sign in to comment.