Skip to content

Commit 6d0c310

Browse files
authored
postgreql array with testing (#105)
* add postgreql array testing * rename github action * all under internal/integration * fix test * fix test * fix test * fix test * fix env in action * fix test * test more array types * fix generating unused test files * add StringArray type * trying to make ts work
1 parent 43c593f commit 6d0c310

34 files changed

+640
-112
lines changed

.github/workflows/integration.yml renamed to .github/workflows/client.yml

Lines changed: 40 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
name: integration
1+
name: client
2+
3+
env:
4+
QUERYX_ENV: test
5+
26
on:
37
push:
48
paths-ignore:
@@ -14,8 +18,6 @@ jobs:
1418
- name: Test
1519
run: |
1620
go test $(go list ./... | grep -Ev "generator|internal") -race -coverprofile=coverage.txt -covermode=atomic
17-
# - name: Upload coverage to Codecov
18-
# uses: codecov/codecov-action@v3
1921
- name: Build
2022
run: go build -o /usr/local/bin/queryx cmd/queryx/main.go
2123
- uses: actions/upload-artifact@v4
@@ -44,6 +46,8 @@ jobs:
4446
--health-interval 10s
4547
--health-timeout 5s
4648
--health-retries 5
49+
env:
50+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/queryx_test?sslmode=disable
4751
steps:
4852
- uses: actions/checkout@v3
4953
- uses: actions/download-artifact@v4
@@ -52,22 +56,19 @@ jobs:
5256
path: /usr/local/bin
5357
- run: chmod a+x /usr/local/bin/queryx
5458
- name: generate
55-
env:
56-
QUERYX_ENV: test
57-
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/queryx_test?sslmode=disable
5859
run: |
59-
cd internal/integration
60+
cd internal/integration/client
6061
queryx db:migrate --schema postgresql.hcl
6162
queryx db:migrate --schema postgresql.hcl
6263
queryx generate --schema postgresql.hcl
6364
- name: golangci-lint
6465
uses: golangci/golangci-lint-action@v3
6566
with:
6667
args: --timeout=3m
67-
working-directory: internal/integration/db
68+
working-directory: internal/integration/client/db
6869
- name: go test
6970
run: |
70-
cd internal/integration
71+
cd internal/integration/client
7172
go test -v ./...
7273
postgresql-typescript:
7374
needs: [build]
@@ -86,6 +87,8 @@ jobs:
8687
--health-interval 10s
8788
--health-timeout 5s
8889
--health-retries 5
90+
env:
91+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/queryx_test?sslmode=disable
8992
steps:
9093
- uses: actions/checkout@v3
9194
- uses: actions/download-artifact@v4
@@ -94,25 +97,18 @@ jobs:
9497
path: /usr/local/bin
9598
- run: chmod a+x /usr/local/bin/queryx
9699
- name: generate
97-
env:
98-
QUERYX_ENV: test
99-
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/queryx_test?sslmode=disable
100100
run: |
101-
cd internal/integration
101+
cd internal/integration/client
102102
queryx db:migrate --schema postgresql.hcl
103103
queryx generate --schema postgresql.hcl
104104
- name: yarn install
105105
run: |
106-
cd internal/integration
106+
cd internal/integration/client
107107
yarn install
108108
- name: yarn test
109109
run: |
110-
cd internal/integration
111-
yarn test
112-
# - name: yarn tsc
113-
# run: |
114-
# cd internal/integration
115-
# yarn tsc
110+
cd internal/integration/client
111+
yarn vitest run --dir client
116112
mysql-golang:
117113
needs: [build]
118114
runs-on: ubuntu-latest
@@ -130,6 +126,8 @@ jobs:
130126
--health-start-period 10s
131127
--health-timeout 5s
132128
--health-retries 10
129+
env:
130+
DATABASE_URL: mysql://root:@localhost:3306/queryx_test
133131
steps:
134132
- uses: actions/checkout@v3
135133
- uses: actions/download-artifact@v4
@@ -138,22 +136,19 @@ jobs:
138136
path: /usr/local/bin
139137
- run: chmod a+x /usr/local/bin/queryx
140138
- name: generate
141-
env:
142-
QUERYX_ENV: test
143-
DATABASE_URL: mysql://root:@localhost:3306/queryx_test
144139
run: |
145-
cd internal/integration
140+
cd internal/integration/client
146141
queryx db:migrate --schema mysql.hcl
147142
queryx db:migrate --schema mysql.hcl
148143
queryx generate --schema mysql.hcl
149144
- name: golangci-lint
150145
uses: golangci/golangci-lint-action@v3
151146
with:
152147
args: --timeout=3m
153-
working-directory: internal/integration/db
148+
working-directory: internal/integration/client/db
154149
- name: go test
155150
run: |
156-
cd internal/integration
151+
cd internal/integration/client
157152
go test -v ./...
158153
mysql-typescript:
159154
needs: [build]
@@ -172,6 +167,8 @@ jobs:
172167
--health-start-period 10s
173168
--health-timeout 5s
174169
--health-retries 10
170+
env:
171+
DATABASE_URL: mysql://root:@localhost:3306/queryx_test
175172
steps:
176173
- uses: actions/checkout@v3
177174
- uses: actions/download-artifact@v4
@@ -180,28 +177,23 @@ jobs:
180177
path: /usr/local/bin
181178
- run: chmod a+x /usr/local/bin/queryx
182179
- name: generate
183-
env:
184-
QUERYX_ENV: test
185-
DATABASE_URL: mysql://root:@localhost:3306/queryx_test
186180
run: |
187-
cd internal/integration
181+
cd internal/integration/client
188182
queryx db:migrate --schema mysql.hcl
189183
queryx generate --schema mysql.hcl
190184
- name: yarn install
191185
run: |
192-
cd internal/integration
186+
cd internal/integration/client
193187
yarn install
194188
- name: yarn test
195189
run: |
196-
cd internal/integration
197-
yarn test
198-
# - name: yarn tsc
199-
# run: |
200-
# cd internal/integration
201-
# yarn tsc
190+
cd internal/integration/client
191+
yarn vitest run --dir client
202192
sqlite-golang:
203193
needs: [build]
204194
runs-on: ubuntu-latest
195+
env:
196+
DATABASE_URL: sqlite:test.sqlite3
205197
steps:
206198
- uses: actions/checkout@v3
207199
- uses: actions/download-artifact@v4
@@ -210,26 +202,25 @@ jobs:
210202
path: /usr/local/bin
211203
- run: chmod a+x /usr/local/bin/queryx
212204
- name: generate
213-
env:
214-
QUERYX_ENV: test
215-
DATABASE_URL: sqlite:test.sqlite3
216205
run: |
217-
cd internal/integration
206+
cd internal/integration/client
218207
queryx db:migrate --schema sqlite.hcl
219208
queryx db:migrate --schema sqlite.hcl
220209
queryx generate --schema sqlite.hcl
221210
- name: golangci-lint
222211
uses: golangci/golangci-lint-action@v3
223212
with:
224213
args: --timeout=3m
225-
working-directory: internal/integration/db
214+
working-directory: internal/integration/client/db
226215
- name: go test
227216
run: |
228-
cd internal/integration
217+
cd internal/integration/client
229218
go test -v ./...
230219
sqlite-typescript:
231220
needs: [build]
232221
runs-on: ubuntu-latest
222+
env:
223+
DATABASE_URL: sqlite:test.sqlite3
233224
steps:
234225
- uses: actions/checkout@v3
235226
- uses: actions/download-artifact@v4
@@ -238,22 +229,17 @@ jobs:
238229
path: /usr/local/bin
239230
- run: chmod a+x /usr/local/bin/queryx
240231
- name: generate
241-
env:
242-
QUERYX_ENV: test
243-
DATABASE_URL: sqlite:test.sqlite3
244232
run: |
245-
cd internal/integration
233+
cd internal/integration/client
246234
queryx db:migrate --schema sqlite.hcl
247235
queryx generate --schema sqlite.hcl
248236
- name: yarn install
249237
run: |
250-
cd internal/integration
238+
cd internal/integration/client
251239
yarn install
252240
- name: yarn test
241+
env:
242+
DATABASE_URL: sqlite:client/test.sqlite3
253243
run: |
254-
cd internal/integration
255-
yarn test
256-
# - name: yarn tsc
257-
# run: |
258-
# cd internal/integration
259-
# yarn tsc
244+
cd internal/integration/client
245+
yarn vitest run --dir client

.github/workflows/migrate.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ jobs:
3232
- run: chmod a+x /usr/local/bin/queryx
3333
- name: migrate
3434
run: |
35-
cd internal/migrate
35+
cd internal/integration/migrate
3636
queryx db:migrate --schema sqlite1.hcl
3737
- name: sleep
3838
run: sleep 1 # so the generated migration files have non-conflicting filenames
3939
- name: migrate again
4040
run: |
41-
cd internal/migrate
41+
cd internal/integration/migrate
4242
queryx db:migrate --schema sqlite2.hcl
4343
- name: test
4444
run: |
45-
cd internal/migrate
45+
cd internal/integration/migrate
4646
sqlite3 test.sqlite3 "insert into users(name, email) values('test', '[email protected]')"
4747
postgresql:
4848
needs: [build]
@@ -73,13 +73,13 @@ jobs:
7373
- run: chmod a+x /usr/local/bin/queryx
7474
- name: migrate
7575
run: |
76-
cd internal/migrate
76+
cd internal/integration/migrate
7777
queryx db:migrate --schema postgresql1.hcl
7878
- name: sleep
7979
run: sleep 1
8080
- name: migrate again
8181
run: |
82-
cd internal/migrate
82+
cd internal/integration/migrate
8383
queryx db:migrate --schema postgresql2.hcl
8484
- name: test
8585
run: |
@@ -113,13 +113,13 @@ jobs:
113113
- run: chmod a+x /usr/local/bin/queryx
114114
- name: migrate
115115
run: |
116-
cd internal/migrate
116+
cd internal/integration/migrate
117117
queryx db:migrate --schema mysql1.hcl
118118
- name: sleep
119119
run: sleep 1
120120
- name: migrate again
121121
run: |
122-
cd internal/migrate
122+
cd internal/integration/migrate
123123
queryx db:migrate --schema mysql2.hcl
124124
- name: test
125125
run: |

.github/workflows/postgresql.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: postgresql
2+
3+
env:
4+
QUERYX_ENV: test
5+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/queryx_test?sslmode=disable
6+
7+
on:
8+
push:
9+
paths-ignore:
10+
- "website/**"
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-go@v4
17+
with:
18+
go-version: "1.20"
19+
- name: Test
20+
run: |
21+
go test $(go list ./... | grep -Ev "generator|internal") -race -coverprofile=coverage.txt -covermode=atomic
22+
- name: Build
23+
run: go build -o /usr/local/bin/queryx cmd/queryx/main.go
24+
- uses: actions/upload-artifact@v4
25+
with:
26+
name: bin
27+
path: /usr/local/bin/queryx
28+
golang:
29+
needs: [build]
30+
strategy:
31+
matrix:
32+
postgres:
33+
- "14.2"
34+
runs-on: ubuntu-latest
35+
services:
36+
postgres:
37+
image: postgres:${{matrix.postgres}}
38+
env:
39+
POSTGRES_PASSWORD: postgres
40+
POSTGRES_USER: postgres
41+
POSTGRES_DB: queryx_test
42+
ports:
43+
- 5432:5432
44+
options: >-
45+
--health-cmd pg_isready
46+
--health-interval 10s
47+
--health-timeout 5s
48+
--health-retries 5
49+
steps:
50+
- uses: actions/checkout@v3
51+
- uses: actions/download-artifact@v4
52+
with:
53+
name: bin
54+
path: /usr/local/bin
55+
- run: chmod a+x /usr/local/bin/queryx
56+
- name: generate
57+
run: |
58+
cd internal/integration/postgresql
59+
queryx db:migrate
60+
queryx generate
61+
- name: go test
62+
run: |
63+
cd internal/integration/postgresql
64+
go test -v ./...
65+
# typescript:
66+
# needs: [build]
67+
# runs-on: ubuntu-latest
68+
# services:
69+
# postgres:
70+
# image: postgres:14.2
71+
# env:
72+
# POSTGRES_PASSWORD: postgres
73+
# POSTGRES_USER: postgres
74+
# POSTGRES_DB: queryx_test
75+
# ports:
76+
# - 5432:5432
77+
# options: >-
78+
# --health-cmd pg_isready
79+
# --health-interval 10s
80+
# --health-timeout 5s
81+
# --health-retries 5
82+
# steps:
83+
# - uses: actions/checkout@v3
84+
# - uses: actions/download-artifact@v4
85+
# with:
86+
# name: bin
87+
# path: /usr/local/bin
88+
# - run: chmod a+x /usr/local/bin/queryx
89+
# - name: generate
90+
# run: |
91+
# cd internal/integration/postgresql
92+
# queryx db:migrate
93+
# queryx generate
94+
# - name: yarn install
95+
# run: |
96+
# cd internal/integration/postgresql
97+
# yarn install
98+
# - name: yarn test
99+
# run: |
100+
# cd internal/integration/postgresql
101+
# yarn test

0 commit comments

Comments
 (0)