-
Notifications
You must be signed in to change notification settings - Fork 91
102 lines (83 loc) · 3.28 KB
/
kafka_api_bazel_build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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.0.2
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