Skip to content

Commit

Permalink
Generic client, Browser + Node.js connections (#165)
Browse files Browse the repository at this point in the history
Co-authored-by: slvrtrn <[email protected]>
Co-authored-by: Mikhail Shustov <[email protected]>
  • Loading branch information
3 people authored Jul 13, 2023
1 parent 897dbf4 commit 9da7655
Show file tree
Hide file tree
Showing 195 changed files with 4,896 additions and 4,607 deletions.
5 changes: 3 additions & 2 deletions .build/update_version.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import version from '../src/version'
import packageJson from '../package.json'
import fs from 'fs'
import packageJson from '../package.json'
import version from '../packages/client-common/src/version'
;(async () => {
// FIXME: support all 3 modules
console.log(`Current package version is: ${version}`)
packageJson.version = version
console.log('Updated package json:')
Expand Down
1 change: 1 addition & 0 deletions .docker/clickhouse/cluster/server1_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<tmp_path>/var/lib/clickhouse/tmp/</tmp_path>
<user_files_path>/var/lib/clickhouse/user_files/</user_files_path>
<access_control_path>/var/lib/clickhouse/access/</access_control_path>
<keep_alive_timeout>3</keep_alive_timeout>

<logger>
<level>debug</level>
Expand Down
1 change: 1 addition & 0 deletions .docker/clickhouse/cluster/server2_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<tmp_path>/var/lib/clickhouse/tmp/</tmp_path>
<user_files_path>/var/lib/clickhouse/user_files/</user_files_path>
<access_control_path>/var/lib/clickhouse/access/</access_control_path>
<keep_alive_timeout>3</keep_alive_timeout>

<logger>
<level>debug</level>
Expand Down
1 change: 1 addition & 0 deletions .docker/clickhouse/single_node/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<tmp_path>/var/lib/clickhouse/tmp/</tmp_path>
<user_files_path>/var/lib/clickhouse/user_files/</user_files_path>
<access_control_path>/var/lib/clickhouse/access/</access_control_path>
<keep_alive_timeout>3</keep_alive_timeout>

<logger>
<level>debug</level>
Expand Down
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
node_modules
webpack
8 changes: 5 additions & 3 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"project": ["./tsconfig.dev.json"]
"project": ["./tsconfig.all.json"]
},
"env": {
"node": true
Expand All @@ -25,10 +25,12 @@
},
"overrides": [
{
"files": ["./__tests__/**/*.ts"],
"files": ["./**/__tests__/**/*.ts"],
"rules": {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off"
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/ban-ts-comment": "off",
"no-constant-condition": "off"
}
}
]
Expand Down
167 changes: 100 additions & 67 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ name: 'tests'

on:
workflow_dispatch:
inputs:
push-coverage-report:
type: choice
required: true
description: Push coverage
options:
- yes
- no
default: no
push:
branches:
- main
Expand All @@ -20,10 +11,8 @@ on:
- 'benchmarks/**'
- 'examples/**'
pull_request:
branches:
- main
paths-ignore:
- 'README.md'
- '**/*.md'
- 'LICENSE'
- 'benchmarks/**'
- 'examples/**'
Expand All @@ -32,12 +21,12 @@ on:
- cron: '0 9 * * *'

jobs:
build:
node-unit-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node: [ 16, 18, 20 ]
node: [16, 18, 20]
steps:
- uses: actions/checkout@main

Expand All @@ -60,16 +49,47 @@ jobs:
- name: Run unit tests
run: |
npm run test:unit
npm run test:node:unit
integration-tests-local-single-node:
needs: build
browser-all-tests-local-single-node:
runs-on: ubuntu-latest
needs: node-unit-tests
strategy:
fail-fast: true
matrix:
node: [ 16, 18, 20 ]
clickhouse: [ head, latest ]
clickhouse: [head, latest]
steps:
- uses: actions/checkout@main

- name: Start ClickHouse (version - ${{ matrix.clickhouse }}) in Docker
uses: isbang/[email protected]
env:
CLICKHOUSE_VERSION: ${{ matrix.clickhouse }}
with:
compose-file: 'docker-compose.yml'
down-flags: '--volumes'

- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install dependencies
run: |
npm install
- name: Run all browser tests
run: |
npm run test:browser
node-integration-tests-local-single-node:
needs: node-unit-tests
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node: [16, 18, 20]
clickhouse: [head, latest]

steps:
- uses: actions/checkout@main
Expand All @@ -95,35 +115,27 @@ jobs:
run: |
sudo echo "127.0.0.1 server.clickhouseconnect.test" | sudo tee -a /etc/hosts
# Includes TLS integration tests run
# Will also run unit tests, but that's almost free.
# Otherwise, we need to set up a separate job,
# which will also run the integration tests for the second time,
# and that's more time-consuming.
- name: Run all tests
- name: Run integration tests
run: |
npm t -- --coverage
npm run test:node:integration
- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage
path: coverage
retention-days: 1
- name: Run TLS tests
run: |
npm run test:node:tls
integration-tests-local-cluster:
needs: build
node-integration-tests-local-cluster:
needs: node-unit-tests
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node: [ 16, 18, 20 ]
clickhouse: [ head, latest ]
node: [16, 18, 20]
clickhouse: [head, latest]

steps:
- uses: actions/checkout@main

- name: Start ClickHouse (version - ${{ matrix.clickhouse }}) in Docker
- name: Start ClickHouse cluster (version - ${{ matrix.clickhouse }}) in Docker
uses: isbang/[email protected]
env:
CLICKHOUSE_VERSION: ${{ matrix.clickhouse }}
Expand All @@ -142,15 +154,46 @@ jobs:
- name: Run integration tests
run: |
npm run test:integration:local_cluster
npm run test:node:integration:local_cluster
integration-tests-cloud:
needs: build
browser-integration-tests-local-cluster:
runs-on: ubuntu-latest
needs: node-unit-tests
strategy:
fail-fast: true
matrix:
node: [ 16, 18, 20 ]
clickhouse: [head, latest]
steps:
- uses: actions/checkout@main

- name: Start ClickHouse cluster (version - ${{ matrix.clickhouse }}) in Docker
uses: isbang/[email protected]
env:
CLICKHOUSE_VERSION: ${{ matrix.clickhouse }}
with:
compose-file: 'docker-compose.cluster.yml'
down-flags: '--volumes'

- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 16

- name: Install dependencies
run: |
npm install
- name: Run all browser tests
run: |
npm run test:browser:integration:local_cluster
node-integration-tests-cloud:
needs: node-unit-tests
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node: [16, 18, 20]

steps:
- uses: actions/checkout@main
Expand All @@ -169,37 +212,27 @@ jobs:
CLICKHOUSE_CLOUD_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST }}
CLICKHOUSE_CLOUD_PASSWORD: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD }}
run: |
npm run test:integration:cloud
npm run test:node:integration:cloud
upload-coverage-and-badge:
if: github.ref == 'refs/heads/main' && github.event.inputs.push-coverage-report != 'no'
needs:
- integration-tests-local-single-node
- integration-tests-local-cluster
- integration-tests-cloud
browser-integration-tests-cloud:
needs: node-unit-tests
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/checkout@v2
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- uses: actions/checkout@main

- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: 16
- name: Download coverage report
uses: actions/download-artifact@v3
with:
name: coverage
path: coverage
- name: Install packages
run: npm i -G make-coverage-badge
- name: Generate badge
run: npx make-coverage-badge
- name: Make "Coverage" lowercase for style points
run: sed -i 's/Coverage/coverage/g' coverage/badge.svg
- uses: stefanzweifel/git-auto-commit-action@v4
with:
file_pattern: 'coverage'
commit_message: '[skip ci] Update coverage report'

- name: Install dependencies
run: |
npm install
- name: Run integration tests
env:
CLICKHOUSE_CLOUD_HOST: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_HOST }}
CLICKHOUSE_CLOUD_PASSWORD: ${{ secrets.INTEGRATIONS_TEAM_TESTS_CLOUD_PASSWORD }}
run: |
npm run test:browser:integration:cloud
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ node_modules
benchmarks/leaks/input
*.tgz
.npmrc
webpack
Loading

0 comments on commit 9da7655

Please sign in to comment.