Skip to content

Commit 241095c

Browse files
Publisher: Enable Publisher Connection integration tests #445 (#613)
* add integration test * fix test * fix test * addd workflow * fix linting * fix test --------- Co-authored-by: Sagar Swami Rao Kulkarni <47278626+sagarswamirao@users.noreply.github.com>
1 parent 892c71d commit 241095c

File tree

2 files changed

+1310
-0
lines changed

2 files changed

+1310
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: Connection Integration Tests
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- "packages/server/src/service/connection.ts"
8+
- "packages/server/src/service/connection.spec.ts"
9+
- ".github/workflows/connection-integration-tests.yml"
10+
pull_request:
11+
branches: [main]
12+
paths:
13+
- "packages/server/src/service/connection.ts"
14+
- "packages/server/src/service/connection.spec.ts"
15+
workflow_dispatch:
16+
17+
jobs:
18+
connection-integration-tests:
19+
name: Connection Integration Tests
20+
runs-on: ubuntu-latest
21+
timeout-minutes: 15
22+
23+
services:
24+
postgres:
25+
image: postgres:15
26+
env:
27+
POSTGRES_USER: postgres
28+
POSTGRES_PASSWORD: postgres
29+
POSTGRES_DB: malloy_test
30+
options: >-
31+
--health-cmd pg_isready
32+
--health-interval 10s
33+
--health-timeout 5s
34+
--health-retries 5
35+
ports:
36+
- 5432:5432
37+
38+
steps:
39+
- name: Checkout code
40+
uses: actions/checkout@v4
41+
42+
- name: Setup Bun
43+
uses: oven-sh/setup-bun@v1
44+
with:
45+
bun-version: latest
46+
47+
- name: Install dependencies
48+
run: bun install
49+
50+
- name: Setup BigQuery credentials
51+
env:
52+
BQ_PRESTO_TRINO_KEY: ${{ secrets.BQ_PRESTO_TRINO_KEY }}
53+
run: |
54+
if [ -z "$BQ_PRESTO_TRINO_KEY" ]; then
55+
echo "BQ_PRESTO_TRINO_KEY is not set"
56+
exit 1
57+
fi
58+
# Detect base64 vs JSON
59+
if echo "$BQ_PRESTO_TRINO_KEY" | grep -qE '^\s*eyJ'; then
60+
echo "Detected Base64 credentials. Decoding..."
61+
echo "$BQ_PRESTO_TRINO_KEY" | base64 --decode > /tmp/bq-credentials.json
62+
else
63+
echo "Detected raw JSON credentials."
64+
echo "$BQ_PRESTO_TRINO_KEY" > /tmp/bq-credentials.json
65+
fi
66+
# Validate JSON
67+
jq . /tmp/bq-credentials.json > /dev/null
68+
# Export for rest of job
69+
echo "GOOGLE_APPLICATION_CREDENTIALS=/tmp/bq-credentials.json" >> $GITHUB_ENV
70+
echo "BIGQUERY_TEST_PROJECT_ID=$(jq -r '.project_id' /tmp/bq-credentials.json)" >> $GITHUB_ENV
71+
echo "BigQuery credentials file written to /tmp/bq-credentials.json"
72+
73+
- name: Run connection integration tests
74+
env:
75+
POSTGRES_TEST_HOST: localhost
76+
POSTGRES_TEST_PORT: "5432"
77+
POSTGRES_TEST_USER: postgres
78+
POSTGRES_TEST_PASSWORD: postgres
79+
POSTGRES_TEST_DATABASE: malloy_test
80+
BIGQUERY_TEST_DATASET: ${{ secrets.BIGQUERY_TEST_DATASET }}
81+
BIGQUERY_TEST_TABLE: ${{ secrets.BIGQUERY_TEST_TABLE }}
82+
run: |
83+
cd packages/server
84+
bun test --timeout 100000 src/service/connection.spec.ts

0 commit comments

Comments
 (0)