Update CI & fix failures #330
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
name: '[Kafka API] Bazel Build' | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
env: | |
KAFKA_SRC_LINK: https://archive.apache.org/dist/kafka/3.3.1/kafka_2.13-3.3.1.tgz | |
CPU_CORE_NUM: 2 | |
LIBRDKAFKA_TAG: v2.4.0 | |
jobs: | |
kafka-api-bazel-build: | |
runs-on: ${{ matrix.os }} | |
env: | |
OS_VERSION: ${{ matrix.os }} | |
TEST_LABELS: ${{ matrix.test-labels }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-22.04 | |
test-labels: unit,integration | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Update the List for Available Packages | |
if: contains(matrix.os, 'ubuntu') | |
run: | | |
sed -e 's/azure.archive.ubuntu.com/us.archive.ubuntu.com/g' -e t -e d /etc/apt/sources.list | sudo tee /etc/apt/sources.list.d/nonazure.list | |
sudo apt-get update | |
- name: Install Dependencies | |
run: | | |
# 1. Install librdkafka | |
git clone https://github.com/edenhill/librdkafka.git | |
cd librdkafka | |
git reset --hard ${LIBRDKAFKA_TAG} | |
./configure | |
make -j${CPU_CORE_NUM} && sudo make install | |
cd ../ | |
# 2. Install boost lib | |
if [[ ${OS_VERSION} == 'ubuntu'* ]]; then | |
sudo apt install -y libboost-all-dev | |
elif [[ ${OS_VERSION} == 'macos'* ]]; then | |
brew install boost | |
fi | |
# 3. Install Jre, Kafka for integration/regression tests | |
if [[ ${TEST_LABELS} == *'integration'* ]] || [[ ${TEST_LABELS} == *'robustness'* ]]; then | |
# Install Jre | |
if [[ ${OS_VERSION} == 'ubuntu-22.04' ]]; then | |
sudo apt install -y openjdk-18-jre | |
fi | |
# Install kafka | |
time wget -nv ${KAFKA_SRC_LINK} | |
tar -xzf `basename ${KAFKA_SRC_LINK}` | |
export PATH=`pwd`/`basename ${KAFKA_SRC_LINK} .tgz`/bin:$PATH | |
# Save the PATH to environment file | |
echo "PATH=${PATH}" >> $GITHUB_ENV | |
fi | |
- name: Build | |
run: | | |
bazel build //... | |
- name: Test | |
if: matrix.test-labels | |
timeout-minutes: 15 | |
run: | | |
# Restore the PATH from environment file | |
export PATH=${{ env.PATH }} | |
# Setup Kafka cluster for integration test & regression test | |
if [[ ${TEST_LABELS} == *'integration'* ]] || [[ ${TEST_LABELS} == *'robustness'* ]]; then | |
# Start Kafka cluster | |
rm -f test.env | |
scripts/start-local-kafka-cluster.py --zookeeper-port 52181 --broker-ports 50091 50092 50093 --temp-dir ./tmp & | |
# Wait server to be ready | |
for i in {1..60}; do cat test.env 2>/dev/null && break || sleep 1; done | |
# Set the environment variables: KAFKA_BROKER_LIST, KAFKA_BROKER_PIDS | |
source test.env | |
fi | |
# Run tests | |
bazel test //... --test_env=KAFKA_BROKER_LIST=$KAFKA_BROKER_LIST --test_tag_filters="${TEST_LABELS}" --test_verbose_timeout_warnings --test_output=all | |
# Stop Kafka cluster for integration test & regression test | |
if [[ ${TEST_LABELS} == *'integration'* ]] || [[ ${TEST_LABELS} == *'robustness'* ]]; then | |
# Stop kafka cluster | |
kafka-server-stop.sh | |
zookeeper-server-stop.sh | |
fi | |