Skip to content

tests

tests #77

Workflow file for this run

name: 'tests'
on:
workflow_dispatch:
push:
branches:
- main
paths-ignore:
- '**/*.md'
schedule:
- cron: '0 9 * * *'
jobs:
unit-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node: [18, 20, 22]
steps:
- uses: actions/checkout@main
- name: Setup NodeJS ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: |
npm ci
- name: Linting
run: |
npm run lint
- name: Unit testing
run: |
npm run test
node-integration-tests-local-single-node:
needs: unit-tests
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node: [18, 20, 22]
clickhouse: [head, latest]
steps:
- uses: actions/checkout@main
- name: Start ClickHouse (version - ${{ matrix.clickhouse }}) using docker-compose
uses: isbang/[email protected]
env:
CLICKHOUSE_VERSION: ${{ matrix.clickhouse }}
with:
compose-file: 'docker-compose.yml'
down-flags: '--volumes'
- name: Setup NodeJS ${{ matrix.node }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
- name: Install dependencies
run: |
npm ci
- name: Build
run: |
npm run build
- name: Test - apply migrations ./tests/migrations/few
run: |
node ./lib/cli.js migrate --host=http://localhost:8123 --user=default --password='' --db=analytics --migrations-home=./tests/migrations/few
- name: Verify Migration
run: |
echo "Checking if tables exist..."
response=$(curl -s "http://localhost:8123/?query=SELECT%20groupArray(name)%20FROM%20system.tables%20WHERE%20name%20IN%20('_migrations','events','sessions')%20AND%20database%20=%20'analytics'")
echo "Response: $response"
expected_tables="['_migrations','events','sessions']"
if [ "$response" = "$expected_tables" ]; then
echo "The tables were created successfully."
else
echo "Tables were not found!"
echo "Expected: $expected_tables"
echo "Got: $response"
exit 1
fi