Skip to content

Commit db6edb7

Browse files
committed
test: Add CI worfklow and example test
1 parent 8931d51 commit db6edb7

File tree

9 files changed

+199
-7
lines changed

9 files changed

+199
-7
lines changed

.github/workflows/ci.yml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: go
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
jobs:
8+
test:
9+
name: test
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-go@v4
14+
with:
15+
go-version: '1.21'
16+
- run: make

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
*.wasm
1+
bin

Makefile

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
1-
all: sqlc-gen-go sqlc-gen-go.wasm
1+
.PHONY: build test
22

3-
sqlc-gen-go:
4-
cd plugin && go build -o ~/bin/sqlc-gen-go ./main.go
3+
build:
4+
go build ./...
55

6-
sqlc-gen-go.wasm:
7-
cd plugin && GOOS=wasip1 GOARCH=wasm go build -o sqlc-gen-go.wasm main.go
8-
openssl sha256 plugin/sqlc-gen-go.wasm
6+
test: bin/sqlc-gen-go.wasm
7+
go test ./...
8+
9+
all: bin/sqlc-gen-go bin/sqlc-gen-go.wasm
10+
11+
bin/sqlc-gen-go: bin go.mod go.sum $(wildcard **/*.go)
12+
cd plugin && go build -o ../bin/sqlc-gen-go ./main.go
13+
14+
bin/sqlc-gen-go.wasm: bin/sqlc-gen-go
15+
cd plugin && GOOS=wasip1 GOARCH=wasm go build -o ../bin/sqlc-gen-go.wasm main.go
16+
17+
bin:
18+
mkdir -p bin

internal/endtoend/testdata/authors/go/db.go

+32
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/authors/go/models.go

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/authors/go/query.sql.go

+80
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
-- name: GetAuthor :one
2+
SELECT * FROM authors
3+
WHERE id = $1 LIMIT 1;
4+
5+
-- name: ListAuthors :many
6+
SELECT * FROM authors
7+
ORDER BY name;
8+
9+
-- name: CreateAuthor :one
10+
INSERT INTO authors (
11+
name, bio
12+
) VALUES (
13+
$1, $2
14+
)
15+
RETURNING *;
16+
17+
-- name: DeleteAuthor :exec
18+
DELETE FROM authors
19+
WHERE id = $1;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CREATE TABLE authors (
2+
id BIGSERIAL PRIMARY KEY,
3+
name text NOT NULL,
4+
bio text
5+
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: '2'
2+
plugins:
3+
- name: golang
4+
wasm:
5+
url: file://../../../../bin/sqlc-gen-go.wasm
6+
sql:
7+
- schema: schema.sql
8+
queries: query.sql
9+
engine: postgresql
10+
codegen:
11+
- plugin: golang
12+
out: go
13+
options:
14+
package: querytest
15+
sql_package: pgx/v5

0 commit comments

Comments
 (0)