mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-04 08:09:27 +00:00
This PR adds support for running unit tests with all three - sqlite, postgres and mysql. This way we cover their code as well. --------- Signed-off-by: Yashodhan Joshi <yjdoc2@gmail.com> Co-authored-by: Yashodhan Joshi <yjdoc2@gmail.com>
108 lines
2.7 KiB
YAML
108 lines
2.7 KiB
YAML
name: Unit tests
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "main"
|
|
paths-ignore:
|
|
- "**.md"
|
|
pull_request:
|
|
branches:
|
|
- "*"
|
|
paths-ignore:
|
|
- "**.md"
|
|
|
|
env:
|
|
COLUMNS: 150
|
|
ZO_RESULT_CACHE_ENABLED: true
|
|
|
|
jobs:
|
|
unit_tests:
|
|
runs-on:
|
|
labels: ubicloud-standard-8
|
|
|
|
services:
|
|
postgres:
|
|
image: postgres:17.5-alpine3.22
|
|
env:
|
|
POSTGRES_PASSWORD: password
|
|
ports:
|
|
- 5432:5432
|
|
# needed because the postgres container does not provide a healthcheck
|
|
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
|
mysql:
|
|
image: mysql:9.3
|
|
env:
|
|
MYSQL_ROOT_PASSWORD: password
|
|
MYSQL_DATABASE: mysql
|
|
ports:
|
|
- 3306:3306
|
|
|
|
steps:
|
|
- name: Clone the current repo
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Rust Toolchain
|
|
uses: dtolnay/rust-toolchain@master
|
|
with:
|
|
toolchain: nightly-2025-03-02
|
|
targets: x86_64-unknown-linux-gnu
|
|
- uses: taiki-e/install-action@v2
|
|
with:
|
|
tool: nextest
|
|
- uses: Swatinem/rust-cache@v2
|
|
with:
|
|
cache-on-failure: true
|
|
- name: Install Protoc
|
|
uses: arduino/setup-protoc@v3
|
|
with:
|
|
version: "21.12"
|
|
|
|
- name: Simulate building frontend code
|
|
run: mkdir -p web/dist && touch web/dist/index.html
|
|
|
|
- name: Print rustc cfg
|
|
run: rustc -C target-cpu=native --print cfg
|
|
|
|
- name: Setup cargo config
|
|
run: cargo --config net.git-fetch-with-cli=true clippy -- -D warnings
|
|
|
|
- name: Run unit tests
|
|
run: |
|
|
# required for all dbs
|
|
export ZO_INTERNAL_GRPC_TOKEN=fake
|
|
export ZO_TEXT_DATA_TYPE=text
|
|
|
|
# setup and run with postgres
|
|
echo "Running with postgres"
|
|
export ZO_META_STORE=postgres
|
|
export ZO_META_POSTGRES_DSN=postgres://postgres:password@localhost:5432/postgres
|
|
./coverage.sh run-cov
|
|
|
|
# cleanup
|
|
rm -rf data
|
|
rm -rf ./json
|
|
rm -rf ./src/infra/data
|
|
|
|
# Run wih sqlite
|
|
echo "Running with sqlite"
|
|
export ZO_META_STORE=sqlite
|
|
export ZO_META_POSTGRES_DSN=""
|
|
./coverage.sh run-cov
|
|
|
|
# cleanup
|
|
rm -rf data
|
|
rm -rf ./json
|
|
rm -rf ./src/infra/data
|
|
|
|
# setup and run with mysql
|
|
echo "Running with mysql"
|
|
export ZO_META_STORE=mysql
|
|
export ZO_META_MYSQL_DSN=mysql://root:password@localhost:3306/mysql
|
|
./coverage.sh run-cov
|
|
|
|
# finally print the coverage data
|
|
./coverage.sh check
|
|
|
|
|