Skip to content

Commit

Permalink
GitHub Action (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrkowalczuk committed Jan 16, 2024
1 parent df97f08 commit 8801563
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 69 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go
name: go
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
test:
runs-on: ubuntu-latest
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Setup
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Test
run: go test -race -count=2 -coverprofile=cover.out -mod=readonly ./...
env:
PQT_POSTGRES_ADDRESS: postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable
29 changes: 0 additions & 29 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
gen:
echo 'package model' > ./example/app/internal/model/schema.pqt.go
cd example && go install ./generator
cd example && go generate ./app/internal/model
cd example/app/internal/model && go generate

run:
cd example && go run app/main.go
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pqt [![GoDoc](https://godoc.org/github.com/piotrkowalczuk/pqt?status.svg)](http://godoc.org/github.com/piotrkowalczuk/pqt) [![Build Status](https://travis-ci.org/piotrkowalczuk/pqt.svg?branch=master)](https://travis-ci.org/piotrkowalczuk/pqt) [![codecov.io](https://codecov.io/github/piotrkowalczuk/pqt/coverage.svg?branch=master)](https://codecov.io/github/piotrkowalczuk/pqt?branch=master)
# pqt [![GoDoc](https://godoc.org/github.com/piotrkowalczuk/pqt?status.svg)](http://godoc.org/github.com/piotrkowalczuk/pqt) ![go workflow](https://github.com/piotrkowalczuk/pqt/actions/workflows/go.yml/badge.svg?branch=piotrkowalczuk/gh-action)

This package is a toolbox for Postgres driven applications.
It provides multiple tools to help to work with Postgres efficiently.
Expand Down Expand Up @@ -49,4 +49,4 @@ $ make run

## Contribution

TODO
TODO
5 changes: 5 additions & 0 deletions example/app/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module github.com/piotrkowalczuk/pqt/example/app

go 1.21.4

require github.com/lib/pq v1.10.9
2 changes: 2 additions & 0 deletions example/app/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
4 changes: 2 additions & 2 deletions example/app/internal/model/schema.pqt.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion example/app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func main() {

count, err = repo.news.Count(ctx, &model.NewsCountExpr{})
if err != nil {
if err != context.DeadlineExceeded {
if !errors.Is(err, context.DeadlineExceeded) {
log.Fatal(err)
}
log.Fatal("as expected, news count failed due to deadline")
Expand Down
2 changes: 1 addition & 1 deletion example/generator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
fmt.Fprint(file, "/// SQL ...\n")
fmt.Fprint(file, "// SQL ...\n")
fmt.Fprint(file, "const SQL = `\n")

if err := sqlGen.GenerateTo(sch, file); err != nil {
Expand Down
8 changes: 0 additions & 8 deletions example/glide.lock

This file was deleted.

6 changes: 0 additions & 6 deletions example/glide.yaml

This file was deleted.

Binary file removed example/model.test
Binary file not shown.
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/piotrkowalczuk/pqt

go 1.21.4

require (
github.com/aryann/difflib v0.0.0-20210328193216-ff5ff6dc229b
github.com/huandu/xstrings v1.4.0
github.com/lib/pq v1.10.9
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
github.com/aryann/difflib v0.0.0-20210328193216-ff5ff6dc229b h1:uUXgbcPDK3KpW29o4iy7GtuappbWT0l5NaMo9H9pJDw=
github.com/aryann/difflib v0.0.0-20210328193216-ff5ff6dc229b/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
github.com/huandu/xstrings v1.4.0 h1:D17IlohoQq4UcpqD7fDk80P7l+lwAmlFaBHgOipl2FU=
github.com/huandu/xstrings v1.4.0/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
6 changes: 4 additions & 2 deletions internal/gogen/gen_general.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ func (g *Generator) Interfaces() {
}

func (g *Generator) Statics() {
g.Print(`
code := `
const (
JoinInner = iota
JoinLeft
Expand Down Expand Up @@ -1013,7 +1013,9 @@ func (c *Composer) Add(arg interface{}) {
// Args returns all arguments stored as a slice.
func (c *Composer) Args() []interface{} {
return c.args
}`)
}`

g.Print(code)
}

func (g *Generator) PluginsStatics(s *pqt.Schema) {
Expand Down
2 changes: 1 addition & 1 deletion internal/gogen/gen_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func RunInTransaction(ctx context.Context, db *sql.DB, f func(tx *sql.Tx) error,
}
return tx.Commit()
}(); err == RetryTransaction {
}(); errors.Is(err, RetryTransaction) {
continue
}
return err
Expand Down
2 changes: 1 addition & 1 deletion pqtgo/pqtgogen/generator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func RunInTransaction(ctx context.Context, db *sql.DB, f func(tx *sql.Tx) error,
}
return tx.Commit()
}(); err == RetryTransaction {
}(); errors.Is(err, RetryTransaction) {
continue
}
return err
Expand Down
15 changes: 0 additions & 15 deletions test.sh

This file was deleted.

0 comments on commit 8801563

Please sign in to comment.