Skip to content

Commit

Permalink
Test gqlgen generate in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mtibben committed Mar 1, 2022
1 parent 3a9413f commit b862f58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/check-init
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ set -euo pipefail
gqlgen_dir=$(pwd)
cd $(mktemp -d)
go mod init inittest
printf '// +build tools\npackage tools\nimport _ "github.com/99designs/gqlgen"' | gofmt > tools.go
go mod tidy
go mod edit -replace=github.com/99designs/gqlgen="$gqlgen_dir"
go get -d github.com/99designs/gqlgen
go mod tidy

if ! go run github.com/99designs/gqlgen init &>/dev/null ; then
if ! go run github.com/99designs/gqlgen init ; then
echo "gqlgen init failed"
exit 125
fi

if ! go run github.com/99designs/gqlgen generate ; then
echo "gqlgen generate failed"
exit 125
fi
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ var initCmd = &cli.Command{
fmt.Println("Creating", serverFilename)
fmt.Println("Generating...")
if err := api.Generate(cfg, api.AddPlugin(servergen.New(serverFilename))); err != nil {
fmt.Fprintln(os.Stderr, err.Error())
return err
}

fmt.Printf("\nExec \"go run ./%s\" to start GraphQL server\n", serverFilename)
Expand Down

0 comments on commit b862f58

Please sign in to comment.