Skip to content

Commit

Permalink
1. verify sqlc generated code is up to date (sqlc diff) (#42)
Browse files Browse the repository at this point in the history
tmp
  • Loading branch information
SockworkOrange authored May 30, 2024
1 parent 0f5288b commit 70053b1
Show file tree
Hide file tree
Showing 10 changed files with 210 additions and 84 deletions.
32 changes: 21 additions & 11 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@ jobs:
uses: xom9ikk/[email protected]
with:
load-mode: strict
- name: Setup dotnet ${{ matrix.dotnet-version }}

- name: Setup Dotnet ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: install wasm workload

- name: install Wasi workload
run: dotnet workload install wasi-experimental
- name: Download WASI SDK on Ubuntu

- name: Download Wasi SDK on Ubuntu
if: runner.os == 'Linux'
run: |
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0-linux.tar.gz
Expand All @@ -71,24 +74,31 @@ jobs:
# curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0.m-mingw.tar.gz
# tar xf wasi-sdk-22.0.m-mingw.tar.gz -C wasi-sdk-22.0
# chmod -R 755 wasi-sdk-22.0
- name: dotnet publish and build
run: WASI_SDK_PATH="$(pwd)/wasi-sdk-22.0" dotnet publish SqlcGenCsharpWasm -c release

- name: Dotnet Wasm Publish
run: |
WASI_SDK_PATH="$(pwd)/wasi-sdk-22.0" dotnet publish SqlcGenCsharpWasm -c release
./scripts/wasm/copy_to_dist.sh
./scripts/wasm/update_sha.sh
- uses: sqlc-dev/setup-sqlc@v4
with:
sqlc-version: '1.25.0'
- name: run update sha256 for builded wasm
run: |
chmod +x ./scripts/update_wasm_plugin.sh
./scripts/update_wasm_plugin.sh
- name: run sqlc with generated wasm plugin
- name: Verify pushed generated code is up to date
run: sqlc -f sqlc.wasm.yaml diff

- name: Sqlc generate using Wasm plugin
run: sqlc -f sqlc.wasm.yaml generate

- uses: hoverkraft-tech/[email protected]
with:
services: |
mysqldb
postgresdb
plugin-tests
- name: test dotnet output project
- name: Test generated code
run: |
chmod +x ./scripts/run_tests.sh
./scripts/run_tests.sh
Expand Down
2 changes: 1 addition & 1 deletion CodeGenerator/CodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private static CompilationUnitSyntax AddResharperDisables(CompilationUnitSyntax
private ClassDeclarationSyntax GetClassDeclaration(string className,
IEnumerable<MemberDeclarationSyntax> classMembers)
{
var classDeclaration = (ClassDeclarationSyntax)(Options.DotnetFramework == DotnetFramework.DotnetStandard21
var classDeclaration = (ClassDeclarationSyntax)(Options.DotnetFramework.LatestDotnetSupported()
? GetWithPrimaryConstructor()
: GetWithRegularConstructor());
return classDeclaration.AddMembers(classMembers.ToArray());
Expand Down
Loading

0 comments on commit 70053b1

Please sign in to comment.