Skip to content

Commit 7264d98

Browse files
testing different configurations via github action matrix - file-per-query config (#50)
1 parent a6daa4f commit 7264d98

File tree

5 files changed

+43
-26
lines changed

5 files changed

+43
-26
lines changed

.github/workflows/main.yml

+31-21
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,17 @@ jobs:
3939
MySqlConnectorExample
4040
NpgsqlExample
4141
42-
42+
4343
ci:
4444
name: CI
4545
runs-on: ${{ matrix.os }}
4646
if: ${{ always() }}
4747
strategy:
4848
matrix:
49-
os: [ ubuntu-latest ]
50-
architecture: [ "x64", "arm64" ]
49+
os: [ 'ubuntu-latest' ]
50+
architecture: [ 'x64', 'arm64' ]
5151
dotnet-version: [ '8.0.x' ]
52+
file-per-query: [ 'true', 'false' ]
5253

5354
steps:
5455
- uses: actions/checkout@v4
@@ -84,32 +85,41 @@ jobs:
8485
./scripts/wasm/copy_to_dist.sh
8586
./scripts/wasm/update_sha.sh
8687
88+
- name: Verify pushed Dockerfile is synced
89+
run: |
90+
./scripts/generate_dockerfile.sh /tmp/Dockerfile
91+
diff /tmp/Dockerfile Dockerfile
92+
8793
- uses: sqlc-dev/setup-sqlc@v4
8894
with:
8995
sqlc-version: '1.25.0'
9096

97+
- name: Updating configuration
98+
env:
99+
FILE_PER_QUERY: ${{ matrix.file-per-query }}
100+
run: ./scripts/update_config.sh $FILE_PER_QUERY
101+
91102
- name: Verify pushed generated code is synced
103+
if: matrix.file-per-query == 'false'
92104
run: sqlc -f sqlc.wasm.yaml diff
93-
94-
- name: Verify pushed Dockerfile is synced
95-
run: |
96-
./scripts/generate_dockerfile.sh /tmp/Dockerfile
97-
diff /tmp/Dockerfile Dockerfile
98-
105+
99106
- name: Sqlc generate using Wasm plugin
100-
run: sqlc -f sqlc.wasm.yaml generate
101-
102-
- uses: hoverkraft-tech/[email protected]
107+
run: |
108+
rm MySqlConnectorExample/*.cs NpgsqlExample/*.cs
109+
sqlc -f sqlc.wasm.yaml generate
110+
111+
- name: Docker compose
112+
if: matrix.file-per-query == 'false'
113+
uses: hoverkraft-tech/[email protected]
103114
with:
104-
services: |
105-
mysqldb
106-
postgresdb
107-
plugin-tests
108-
115+
services: |
116+
mysqldb
117+
postgresdb
118+
plugin-tests
119+
109120
- name: Test generated code
110-
run: |
111-
chmod +x ./scripts/run_tests.sh
112-
./scripts/run_tests.sh
121+
if: matrix.file-per-query == 'false'
122+
run: ./scripts/run_tests.sh
113123

114124
- name: upload wasm plugin as artifact
115125
uses: actions/upload-artifact@v2
@@ -119,7 +129,7 @@ jobs:
119129
path: dist/plugin.wasm
120130

121131
release:
122-
name: Release test
132+
name: Release
123133
runs-on: ubuntu-latest
124134
if: github.ref == 'refs/heads/main' && contains(github.event.head_commit.message, '[release]')
125135
needs: [ci]

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ run-tests:
1919

2020
# process type plugin
2121
dotnet-build-process: protobuf-generate dotnet-format
22-
dotnet build SqlcGenCsharpProcess -c Release
22+
dotnet build ProcessRunner -c Release
2323

2424
dotnet-publish-process: dotnet-build-process
25-
dotnet publish SqlcGenCsharpProcess -c release --output dist/
25+
dotnet publish ProcessRunner -c release --output dist/
2626

2727
sqlc-generate-process: dotnet-publish-process
2828
sqlc -f sqlc.process.yaml generate

scripts/update_config.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -ex
4+
5+
file_per_query=$1
6+
yq -i ".sql[0].codegen[0].options.filePerQuery = ${file_per_query}" sqlc.wasm.yaml
7+
yq -i ".sql[1].codegen[0].options.filePerQuery = ${file_per_query}" sqlc.wasm.yaml

sqlc.process.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ version: "2"
22
plugins:
33
- name: csharp
44
process:
5-
cmd: ./dist/SqlcGenCsharpProcess
5+
cmd: ./dist/ProcessRunner
66
sql:
77
- schema: "examples/authors/postgresql/schema.sql"
88
queries: "examples/authors/postgresql/query.sql"

sqlc.wasm.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ sql:
1313
out: NpgsqlExample
1414
options:
1515
driver: Npgsql
16+
filePerQuery: BOOL_TO_REPLACE
1617
# targetFramework: netstandard2.0
1718
# generateCsproj: true
18-
# filePerQuery: false
1919
- schema: "examples/authors/mysql/schema.sql"
2020
queries: "examples/authors/mysql/query.sql"
2121
engine: "mysql"
@@ -24,6 +24,6 @@ sql:
2424
out: MySqlConnectorExample
2525
options:
2626
driver: MySqlConnector
27+
filePerQuery: BOOL_TO_REPLACE
2728
# targetFramework: netstandard2.0
2829
# generateCsproj: true
29-
# filePerQuery: false

0 commit comments

Comments
 (0)