Skip to content

Commit

Permalink
ci: init ci workflows (#4)
Browse files Browse the repository at this point in the history
* ci: init ci workflows

* fix all lint errors

* add TEST_HGE_ACCESS_KEY for tests
  • Loading branch information
scriptnull authored May 20, 2024
1 parent e44b90d commit b540bb5
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 5 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Lint
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: "1.22.2"
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Tests
on: [push]

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22.x"
- name: Test
env:
TEST_HGE_ACCESS_KEY: ${{ secrets.TEST_HGE_ACCESS_KEY }}
run: go test -v -cover ./...
2 changes: 1 addition & 1 deletion cmd/fieldgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ package %s
return
}
if err := writeToFile(outputFileName, header+gen); err != nil {
fmt.Fprintf(os.Stderr, err.Error())
fmt.Fprint(os.Stderr, err.Error())
os.Exit(1)
}
}
Expand Down
6 changes: 6 additions & 0 deletions eywa.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ func (q *query[T, M]) build() string {

func (q *query[T, M]) Exec(client *Client) ([]M, error) {
respBytes, err := client.do(q.build())
if err != nil {
return nil, err
}

type graphqlResponse struct {
Data map[string][]M `json:"data"`
Expand Down Expand Up @@ -301,6 +304,9 @@ func (q *queryByPk[T, M]) build() string {

func (q *queryByPk[T, M]) Exec(c *Client) (M, error) {
respBytes, err := c.do(q.build())
if err != nil {
return nil, err
}

type graphqlResponse struct {
Data map[string]M `json:"data"`
Expand Down
7 changes: 3 additions & 4 deletions eywa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import (
)

type testTable struct {
Name string `json:"name"`
Age int `json:"age"`
ID *int `json:"id,omitempty"`
nullableField *string `json:"nullable_field"`
Name string `json:"name"`
Age int `json:"age"`
ID *int `json:"id,omitempty"`
}

func (t testTable) ModelName() string {
Expand Down

0 comments on commit b540bb5

Please sign in to comment.