Tests #118
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: Tests | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
schedule: | |
# At 12:00 on every day-of-month | |
- cron: "0 12 */1 * *" | |
env: | |
COMDB2_DBNAME: mattdb | |
TIMEOUT: 30 | |
jobs: | |
test: | |
name: Test suite | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: | |
- '3.12' | |
- '3.11' | |
- '3.10' | |
- '3.9' | |
- '3.8' | |
steps: | |
- name: Install dependencies | |
run: ' | |
sudo apt-get install -qy | |
pkg-config | |
' # libcdb2api-dev is installed from source below | |
- uses: actions/checkout@v3 | |
- name: Checkout comdb2 dependency | |
uses: actions/checkout@v3 | |
with: | |
repository: bloomberg/comdb2 | |
path: original_comdb2 | |
- name: Build comdb2 from source | |
run: ' | |
sudo apt-get update && | |
sudo apt-get install -qy | |
bison | |
build-essential | |
cmake | |
flex | |
libevent-dev | |
liblz4-dev | |
libprotobuf-c-dev | |
libreadline-dev | |
libsqlite3-dev | |
libssl-dev | |
libunwind-dev | |
ncurses-dev | |
protobuf-c-compiler | |
tcl | |
uuid-dev | |
zlib1g-dev && | |
( | |
mkdir original_comdb2/build && | |
cd original_comdb2/build && | |
cmake .. && | |
make && | |
sudo make install | |
) | |
' | |
- name: Start local comdb2 instance | |
run: ' | |
sudo mkdir -p /opt/bb/share/schemas/$COMDB2_DBNAME && | |
echo "$COMDB2_DBNAME 1234 $(hostname -f)" > /opt/bb/etc/cdb2/config/comdb2db.cfg && | |
(/opt/bb/bin/pmux -n &) && | |
echo started pmux && | |
/opt/bb/bin/comdb2 --create $COMDB2_DBNAME && | |
(/opt/bb/bin/comdb2 $COMDB2_DBNAME > /tmp/$COMDB2_DBNAME.log 2>&1 &); | |
iterations=0; | |
until /opt/bb/bin/cdb2sql $COMDB2_DBNAME local "select 1+1" > /dev/null 2>&1; | |
do | |
echo -n "."; | |
sleep 1; | |
iterations=$(($iterations + 1)); | |
if [ "$iterations" -ge "$TIMEOUT" ]; then | |
echo >&2 "$COMDB2_DBNAME failed to start after $iterations seconds"; | |
exit 1; | |
fi; | |
done | |
' | |
- name: Creating tables | |
run: | | |
tables="$(cat tests/schemas/$COMDB2_DBNAME/table_constraint_order.txt)" | |
for table_name in $tables | |
do | |
table_file="tests/schemas/$COMDB2_DBNAME/$table_name.csc2" | |
echo "Creating $table_name from $table_file" | |
/opt/bb/bin/cdb2sql "$COMDB2_DBNAME" local "create table $table_name { $(cat $table_file) }" | |
done | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 # note that this step overwrites the PKG_CONFIG_PATH variable | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
PKG_CONFIG_PATH=/opt/bb/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig LDFLAGS="-Wl,-rpath,/opt/bb/lib" python -m pip install .[tests] | |
- name: Run Tests | |
run: (cd tests && python -m pytest -vvv) |