Skip to content

Commit

Permalink
ci(sharebuild): add distributed compilation test for re2
Browse files Browse the repository at this point in the history
- This commit introduces a CI test to validate the distributed
  compilation of the re2 library in sharebuild mode.
  • Loading branch information
chanfun-ren committed Nov 4, 2024
1 parent 709ee86 commit 3180adf
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
sudo \
apt-utils \
git cmake g++ gcc googletest libgmock-dev libgoogle-glog-dev libssl-dev pkg-config uuid-dev grpc++ libprotobuf-dev protobuf-compiler-grpc ninja-build libyaml-cpp-dev
git cmake g++ gcc googletest libgmock-dev libssl-dev pkg-config uuid-dev grpc++ libprotobuf-dev protobuf-compiler-grpc ninja-build libyaml-cpp-dev

WORKDIR /app

Expand Down
133 changes: 127 additions & 6 deletions .github/workflows/linux-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
# 1. 检出代码
Expand Down Expand Up @@ -42,7 +42,7 @@ jobs:
# if: steps.apt-cache.outputs.cache-hit != 'true' (仅在缓存未命中时)
run: |
sudo apt-get update
sudo apt-get install -y git cmake g++ gcc googletest libgmock-dev libgoogle-glog-dev libssl-dev pkg-config uuid-dev grpc++ libprotobuf-dev protobuf-compiler-grpc ninja-build libyaml-cpp-dev
sudo apt-get install -y git cmake g++ gcc googletest libgmock-dev libssl-dev pkg-config uuid-dev grpc++ libprotobuf-dev protobuf-compiler-grpc ninja-build libyaml-cpp-dev
# # 5. 缓存 CMake 和构建产物(可选)
# - name: Cache CMake and build
Expand Down Expand Up @@ -93,13 +93,134 @@ jobs:
cmake -G Ninja ..
ninja
# 11. 运行 re2 测试
# 12. 运行 re2 测试
- name: Test re2 build
run: |
cd re2/build
./re2_test
# ctest --output-on-failure
# TODO:
# 1. remote build re2 with ninja2.
# 2. more testing projects.
## 分布式构建 re2 项目
# 13. 启动 scheduler
- name: start scheduler
run: |
# 设置环境变量
SCHEDULER_HOST=localhost
REDIS_HOST=localhost
REDIS_PORT=6379
# 安装依赖
# sudo apt-get update
sudo apt-get install -y nfs-kernel-server redis-server
# 配置并启动 Redis
sudo systemctl enable redis-server
sudo systemctl restart redis-server
# 创建必要的文件夹
mkdir -p ~/sharebuild-bin/
wget https://github.com/chanfun-ren/ninja2/releases/download/ninja2_ci_test/scheduler
chmod +x ./scheduler
cp ./scheduler ~/sharebuild-bin
# 配置 Scheduler
sudo mkdir -p /etc/scheduler
cat <<EOF | sudo tee /etc/scheduler/config.yaml > /dev/null
redis:
host: ${REDIS_HOST}
port: ${REDIS_PORT}
password: ''
db: 0
taskServer:
port: 8002
license:
code: ShareBuild1234
VerifyService:
host: 106.54.183.229
port: 8004
EOF
# 启动 Scheduler
# ~/sharebuild-bin/scheduler -config /etc/scheduler/config.yaml &
nohup ~/sharebuild-bin/scheduler -config /etc/scheduler/config.yaml > scheduler.log 2>&1 &
# 14. 启动 executor
- name: start executor
run: |
# 环境变量配置
REDIS_HOST=localhost
REDIS_PORT=6379
SCHEDULER_HOST=localhost
mkdir -p ~/sharebuild-bin
wget https://github.com/chanfun-ren/ninja2/releases/download/ninja2_ci_test/executor
chmod +x ./executor
cp ./executor ~/sharebuild-bin
# 配置 Executor
sudo mkdir -p /etc/executor
cat <<EOF | sudo tee /etc/executor/config.yaml > /dev/null
redis:
host: ${REDIS_HOST}
port: ${REDIS_PORT}
password: ''
db: 0
taskServer:
port: 8003
user: $(whoami)
schedulerRegisterServer:
host: ${SCHEDULER_HOST}
port: 8002
EOF
# 启动 Executor
# ~/sharebuild-bin/executor -config /etc/executor/config.yaml &
sudo nohup ~/sharebuild-bin/executor -config /etc/executor/config.yaml > executor.log 2>&1 &
# 15. ninja2 分布式 sharebuild 模式编译 re2
- name: sharebuild re2
run: |
# 环境变量配置
SCHEDULER_HOST=localhost
# 安装依赖
sudo apt-get install -y nfs-kernel-server
# 配置 NFS
echo "/home *(rw,no_root_squash,anonuid=1000,anongid=1000,insecure,async,no_subtree_check)" | sudo tee -a /etc/exports
sudo exportfs -a
sudo systemctl restart nfs-kernel-server
# 下载测试项目 re2
wget https://github.com/google/re2/archive/refs/tags/2021-11-01.tar.gz
tar -zxvf 2021-11-01.tar.gz
mv re2-2021-11-01 re2_sharebuild
# 分布式测试编译 re2
cd re2_sharebuild
rm -rf build
mkdir -p build
cd build
cmake -G Ninja ..
ninja -s ${SCHEDULER_HOST}:8002 -r "$(realpath ../)"
# 显示日志文件内容
- name: Show executor logs
run: cat executor.log

- name: Show scheduler logs
run: cat scheduler.log

# 测试 shabuild 编译出来的 re2 是否正常
- name: Test re2(sharebuild)
run: |
cd re2_sharebuild/build
./re2_test
# ctest --output-on-failure

# debug
- name: debug network
run: |
netstat -tuln | grep 8003
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
sudo \
apt-utils \
git cmake g++ gcc googletest libgmock-dev libgoogle-glog-dev libssl-dev pkg-config uuid-dev grpc++ libprotobuf-dev protobuf-compiler-grpc ninja-build libyaml-cpp-dev
git cmake g++ gcc googletest libgmock-dev libssl-dev pkg-config uuid-dev grpc++ libprotobuf-dev protobuf-compiler-grpc ninja-build libyaml-cpp-dev

WORKDIR /app

Expand Down
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ function install_dependencies {
case $OS_ID in
ubuntu|debian)
sudo apt-get update
sudo apt-get install -y git cmake g++ gcc googletest libgmock-dev libgoogle-glog-dev libssl-dev pkg-config uuid-dev grpc++ libprotobuf-dev protobuf-compiler-grpc ninja-build libyaml-cpp-dev
sudo apt-get install -y git cmake g++ gcc googletest libgmock-dev libssl-dev pkg-config uuid-dev grpc++ libprotobuf-dev protobuf-compiler-grpc ninja-build libyaml-cpp-dev
;;
centos)
sudo yum update -y
sudo yum install -y epel-release
sudo yum groupinstall -y "Development Tools"
sudo yum install -y git cmake3 gtest gtest-devel glog glog-devel openssl openssl-devel pkgconfig uuid-devel grpc-devel protobuf protobuf-devel protobuf-compiler ninja-build yaml-cpp yaml-cpp-devel
sudo yum install -y git cmake3 gtest gtest-devel openssl openssl-devel pkgconfig uuid-devel grpc-devel protobuf protobuf-devel protobuf-compiler ninja-build yaml-cpp yaml-cpp-devel
;;
fedora)
sudo dnf update -y
sudo dnf group install -y "Development Tools"
sudo dnf install -y git cmake g++ gtest gtest-devel glog glog-devel openssl openssl-devel pkgconfig uuid-devel grpc-devel protobuf protobuf-devel protobuf-compiler ninja-build yaml-cpp yaml-cpp-devel
sudo dnf install -y git cmake g++ gtest gtest-devel openssl openssl-devel pkgconfig uuid-devel grpc-devel protobuf protobuf-devel protobuf-compiler ninja-build yaml-cpp yaml-cpp-devel
;;
*)
failure "Unsupported OS: $OS_ID"
Expand Down

0 comments on commit 3180adf

Please sign in to comment.