Skip to content

Commit

Permalink
add create full program, generate-fast (#303)
Browse files Browse the repository at this point in the history
* add create full program, generate-fast

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* add env var to disable cache if wanted, move install to tools.go

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* cleanup generate

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* use fork

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* use fork

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* remove builder line from dockerfile

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* fixup

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

* fixup the generate

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>

---------

Signed-off-by: Sarah Funkhouser <147884153+golanglemonade@users.noreply.github.com>
  • Loading branch information
golanglemonade authored Dec 11, 2024
1 parent 317b923 commit 18e23bf
Show file tree
Hide file tree
Showing 20 changed files with 1,886 additions and 45 deletions.
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ issues:
exclude-files:
- internal/graphapi/gen_server.go
- internal/graphapi/gen_models.go
- internal/openlaneclient/graphclient.go
- pkg/openlaneclient/graphclient.go
- schema.graphql
output:
Expand Down
9 changes: 8 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@ repos:
entry: npx format-graphql@1.4.0 --write=true
language: node
files: 'query/.*\.graphql$'

- repo: local
hooks:
- id: generate
name: Run Go Generate
description: This hook runs go generate on the project
entry: go-generate-fast ./...
language: golang
files: \.(go|graphql|tmpl)$
29 changes: 27 additions & 2 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,45 @@ env:
TEST_DB_CONTAINER_EXPIRY: "2" # in minutes
TEST_FGA_URL: "localhost:8080"
ENV: config
# go build
GOFLAGS: -buildvcs=false
# for test container settings
RYUK_CONNECTION_TIMEOUT: "5m"
RYUK_VERBOSE: "true"
## generate env vars for caching
GO_GENERATE_FAST_DEBUG: "false" # set to true to debug go-generate-fast
GO_GENERATE_FAST_CACHE_DIR: "/tmp/.cache"
GO_GENERATE_FAST_DISABLE: "false" # set to true to disable cached entries

tasks:
default:
silent: true
cmds:
- task --list

generate:
generate:ci:
desc: a combination of the ent, graph, and gqlgen tasks which are required to fully generate the necessary graph, server, resolvers, client, etc.
cmds:
- go generate ./...
- task: tidy

generate:
desc: a combination of the ent, graph, and gqlgen tasks which are required to fully generate the necessary graph, server, resolvers, client, etc.
cmds:
- go-generate-fast ./...
- task: tidy

generate:ent:
desc: generate ent models
cmds:
- go-generate-fast generate_ent.go
- task: tidy

generate:gql:
desc: generate gql graphql models and resolvers, along with the client
cmds:
- go-generate-fast generate_gql.go
- task: tidy

## Go tasks
go:lint:
Expand Down Expand Up @@ -141,7 +166,7 @@ tasks:
ci:
desc: a task that runs during CI
cmds:
- task: generate
- task: generate:ci
- task: tidy
- "git config --global --add safe.directory /workdir"
- |
Expand Down
2 changes: 0 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
FROM golang:1.23.4 AS builder

FROM gcr.io/distroless/static:nonroot

# `nonroot` coming from distroless
Expand Down
13 changes: 0 additions & 13 deletions generate.go

This file was deleted.

5 changes: 5 additions & 0 deletions generate_ent.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package main

//go:generate_input internal/ent/entc.go internal/ent/schema/* internal/ent/mixin/* internal/ent/templates/*
//go:generate_output internal/ent/generated/*
//go:generate go run ./internal/ent/entc.go
13 changes: 13 additions & 0 deletions generate_gql.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package main

//go:generate_input internal/graphapi/generate/generate.go gqlgen.yml github.com/theopenlane/core/internal/ent/generated/* schema/*
//go:generate_output internal/graphapi/* pkg/openlaneclient/models.go
//go:generate go run ./internal/graphapi/generate/generate.go

//go:generate_input gen_schema.go internal/graphapi/gen_server.go
//go:generate_output schema.graphql
//go:generate go run ./gen_schema.go

//go:generate_input query/* schema/* gqlgenc.yml
//go:generate_output pkg/openlaneclient/graphqlclient.go
//go:generate go run github.com/Yamashou/gqlgenc generate --configdir schema
179 changes: 172 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ module github.com/theopenlane/core

go 1.23.3

replace github.com/oNaiPs/go-generate-fast => github.com/golanglemonade/go-generate-fast v0.0.0-20241211000619-c8e4743fac43

require (
ariga.io/entcache v0.1.0
dario.cat/mergo v1.0.1
Expand Down Expand Up @@ -42,6 +44,7 @@ require (
github.com/mcuadros/go-defaults v1.2.0
github.com/mitchellh/go-homedir v1.1.0
github.com/nyaruka/phonenumbers v1.4.3
github.com/oNaiPs/go-generate-fast v0.0.0-00010101000000-000000000000
github.com/oklog/ulid/v2 v2.1.0
github.com/openfga/go-sdk v0.6.3
github.com/pkg/errors v0.9.1
Expand Down Expand Up @@ -81,8 +84,27 @@ require (
)

require (
4d63.com/gocheckcompilerdirectives v1.2.1 // indirect
4d63.com/gochecknoglobals v0.2.1 // indirect
cel.dev/expr v0.18.0 // indirect
github.com/4meepo/tagalign v1.3.4 // indirect
github.com/Abirdcfly/dupword v0.1.3 // indirect
github.com/Antonboom/errname v1.0.0 // indirect
github.com/Antonboom/nilnil v1.0.0 // indirect
github.com/Antonboom/testifylint v1.5.2 // indirect
github.com/BurntSushi/toml v1.4.1-0.20241028111116-b7406c026f5a // indirect
github.com/Crocmagnon/fatcontext v0.5.3 // indirect
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
github.com/GaijinEntertainment/go-exhaustruct/v3 v3.3.0 // indirect
github.com/Masterminds/semver/v3 v3.3.1 // indirect
github.com/OpenPeeDeeP/depguard/v2 v2.2.0 // indirect
github.com/Yiling-J/theine-go v0.6.0 // indirect
github.com/alecthomas/go-check-sumtype v0.2.0 // indirect
github.com/alexkohler/nakedret/v2 v2.0.5 // indirect
github.com/alexkohler/prealloc v1.0.0 // indirect
github.com/alingse/asasalint v0.0.11 // indirect
github.com/ashanbrown/forbidigo v1.6.0 // indirect
github.com/ashanbrown/makezero v1.2.0 // indirect
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.21 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.25 // indirect
Expand All @@ -97,40 +119,183 @@ require (
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.6 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.33.2 // indirect
github.com/aws/smithy-go v1.22.1 // indirect
github.com/bitfield/gotestdox v0.2.2 // indirect
github.com/bkielbasa/cyclop v1.2.3 // indirect
github.com/blizzy78/varnamelen v0.8.0 // indirect
github.com/bmatcuk/doublestar/v4 v4.7.1 // indirect
github.com/bombsimon/wsl/v4 v4.4.1 // indirect
github.com/breml/bidichk v0.3.2 // indirect
github.com/breml/errchkjson v0.4.0 // indirect
github.com/butuzov/ireturn v0.3.1 // indirect
github.com/butuzov/mirror v1.3.0 // indirect
github.com/catenacyber/perfsprint v0.7.1 // indirect
github.com/ccojocar/zxcvbn-go v1.0.2 // indirect
github.com/charithe/durationcheck v0.0.10 // indirect
github.com/chavacava/garif v0.1.0 // indirect
github.com/cheekybits/genny v1.0.0 // indirect
github.com/ckaznocha/intrange v0.3.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/cpuguy83/dockercfg v0.3.2 // indirect
github.com/curioswitch/go-reassign v0.3.0 // indirect
github.com/daixiang0/gci v0.13.5 // indirect
github.com/denis-tingaikin/go-header v0.5.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/dnephin/pflag v1.0.7 // indirect
github.com/docker/docker v27.3.1+incompatible // indirect
github.com/ettle/strcase v0.2.0 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/firefart/nonamedreturns v1.0.5 // indirect
github.com/fzipp/gocyclo v0.6.0 // indirect
github.com/ghostiam/protogetter v0.3.8 // indirect
github.com/go-bindata/go-bindata v3.1.2+incompatible // indirect
github.com/go-critic/go-critic v0.11.5 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-toolsmith/astcast v1.1.0 // indirect
github.com/go-toolsmith/astcopy v1.1.0 // indirect
github.com/go-toolsmith/astequal v1.2.0 // indirect
github.com/go-toolsmith/astfmt v1.1.0 // indirect
github.com/go-toolsmith/astp v1.1.0 // indirect
github.com/go-toolsmith/strparse v1.1.0 // indirect
github.com/go-toolsmith/typep v1.1.0 // indirect
github.com/go-xmlfmt/xmlfmt v1.1.3 // indirect
github.com/gobuffalo/flect v1.0.3 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gofrs/flock v0.12.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect
github.com/golangci/go-printf-func-name v0.1.0 // indirect
github.com/golangci/gofmt v0.0.0-20240816233607-d8596aa466a9 // indirect
github.com/golangci/golangci-lint v1.62.2 // indirect
github.com/golangci/misspell v0.6.0 // indirect
github.com/golangci/modinfo v0.3.4 // indirect
github.com/golangci/plugin-module-register v0.1.1 // indirect
github.com/golangci/revgrep v0.5.3 // indirect
github.com/golangci/unconvert v0.0.0-20240309020433-c5143eacb3ed // indirect
github.com/google/go-github/v67 v67.0.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gordonklaus/ineffassign v0.1.0 // indirect
github.com/gostaticanalysis/analysisutil v0.7.1 // indirect
github.com/gostaticanalysis/comment v1.5.0 // indirect
github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect
github.com/gostaticanalysis/nilerr v0.1.1 // indirect
github.com/hashicorp/go-immutable-radix/v2 v2.1.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/hexops/gotextdiff v1.0.3 // indirect
github.com/jessevdk/go-flags v1.6.1 // indirect
github.com/jgautheron/goconst v1.7.1 // indirect
github.com/jingyugao/rowserrcheck v1.1.1 // indirect
github.com/jjti/go-spancheck v0.6.4 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/julz/importas v0.1.0 // indirect
github.com/karamaru-alpha/copyloopvar v1.1.0 // indirect
github.com/kisielk/errcheck v1.8.0 // indirect
github.com/kkHAIKE/contextcheck v1.1.5 // indirect
github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/kulti/thelper v0.6.3 // indirect
github.com/kunwardeep/paralleltest v1.0.10 // indirect
github.com/kyoh86/exportloopref v0.1.11 // indirect
github.com/lasiar/canonicalheader v1.1.2 // indirect
github.com/ldez/gomoddirectives v0.6.0 // indirect
github.com/ldez/grignotin v0.6.0 // indirect
github.com/ldez/tagliatelle v0.7.1 // indirect
github.com/leonklingele/grouper v1.1.2 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/macabu/inamedparam v0.1.3 // indirect
github.com/maratori/testableexamples v1.0.0 // indirect
github.com/maratori/testpackage v1.1.1 // indirect
github.com/matoous/godox v0.0.0-20241202171805-94d1edd68ebb // indirect
github.com/matryer/moq v0.5.1 // indirect
github.com/mgechev/revive v1.5.1 // indirect
github.com/mjibson/esc v0.2.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/patternmatcher v0.6.0 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/user v0.1.0 // indirect
github.com/moby/sys/userns v0.1.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/moricho/tparallel v0.3.2 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/nakabonne/nestif v0.3.1 // indirect
github.com/nishanths/exhaustive v0.12.0 // indirect
github.com/nishanths/predeclared v0.2.2 // indirect
github.com/nunnatsa/ginkgolinter v0.18.3 // indirect
github.com/polyfloyd/go-errorlint v1.7.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/quasilyte/go-ruleguard v0.4.3-0.20240823090925-0fe6f58b47b1 // indirect
github.com/quasilyte/go-ruleguard/dsl v0.3.22 // indirect
github.com/quasilyte/gogrep v0.5.0 // indirect
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
github.com/raeperd/recvcheck v0.1.2 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/ryancurrah/gomodguard v1.3.5 // indirect
github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect
github.com/sanposhiho/wastedassign/v2 v2.1.0 // indirect
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
github.com/sashamelentyev/interfacebloat v1.1.0 // indirect
github.com/sashamelentyev/usestdlibvars v1.27.0 // indirect
github.com/securego/gosec/v2 v2.21.4 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c // indirect
github.com/shirou/gopsutil/v3 v3.24.5 // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/sivchari/containedctx v1.0.3 // indirect
github.com/sivchari/tenv v1.12.1 // indirect
github.com/sonatard/noctx v0.1.0 // indirect
github.com/sourcegraph/go-diff v0.7.0 // indirect
github.com/ssgreg/nlreturn/v2 v2.2.1 // indirect
github.com/stbenjam/no-sprintf-host-port v0.2.0 // indirect
github.com/tdakkota/asciicheck v0.3.0 // indirect
github.com/testcontainers/testcontainers-go v0.34.0 // indirect
github.com/testcontainers/testcontainers-go/modules/openfga v0.34.0 // indirect
github.com/tetafro/godot v1.4.18 // indirect
github.com/timakin/bodyclose v0.0.0-20241017074824-adbc21e6bf36 // indirect
github.com/timonwong/loggercheck v0.10.1 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
github.com/tomarrell/wrapcheck/v2 v2.10.0 // indirect
github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect
github.com/ultraware/funlen v0.1.0 // indirect
github.com/ultraware/whitespace v0.1.1 // indirect
github.com/uudashr/gocognit v1.2.0 // indirect
github.com/uudashr/iface v1.3.0 // indirect
github.com/xen0n/gosmopolitan v1.2.2 // indirect
github.com/yagipy/maintidx v1.0.0 // indirect
github.com/yeya24/promlinter v0.3.0 // indirect
github.com/ykadowak/zerologlint v0.1.5 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
github.com/zeebo/xxh3 v1.0.2 // indirect
gitlab.com/bosi/decorder v0.4.2 // indirect
go-simpler.org/musttag v0.13.0 // indirect
go-simpler.org/sloglint v0.7.2 // indirect
go.uber.org/automaxprocs v1.6.0 // indirect
go.uber.org/mock v0.5.0 // indirect
golang.org/x/exp/typeparams v0.0.0-20241210194714-1829a127f884 // indirect
gonum.org/v1/gonum v0.15.1 // indirect
gopkg.in/VividCortex/ewma.v1 v1.1.1 // indirect
gopkg.in/fatih/color.v1 v1.7.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/mattn/go-colorable.v0 v0.1.0 // indirect
gopkg.in/mattn/go-isatty.v0 v0.0.4 // indirect
gopkg.in/mattn/go-runewidth.v0 v0.0.4 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gotest.tools/gotestsum v1.12.0 // indirect
honnef.co/go/tools v0.5.1 // indirect
k8s.io/api v0.31.3 // indirect
k8s.io/apiextensions-apiserver v0.31.3 // indirect
k8s.io/apimachinery v0.31.3 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/utils v0.0.0-20241210054802-24370beab758 // indirect
mvdan.cc/gofumpt v0.7.0 // indirect
mvdan.cc/unparam v0.0.0-20240917084806-57a3b4290ba3 // indirect
sigs.k8s.io/controller-tools v0.16.5 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.3 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

require (
Expand Down Expand Up @@ -171,9 +336,9 @@ require (
github.com/dvsekhvalnov/jose2go v1.7.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/envoyproxy/protoc-gen-validate v1.1.0 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/fatih/color v1.18.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fsnotify/fsnotify v1.8.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.7
github.com/ghodss/yaml v1.0.0 // indirect
Expand Down Expand Up @@ -218,7 +383,7 @@ require (
github.com/lestrrat-go/iter v1.0.2 // indirect
github.com/lestrrat-go/option v1.0.1 // indirect
github.com/lib/pq v1.10.9
github.com/magiconair/properties v1.8.7 // indirect
github.com/magiconair/properties v1.8.9 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand Down Expand Up @@ -249,7 +414,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/pquerna/otp v1.4.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.57.0 // indirect
github.com/prometheus/common v0.61.0 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/resend/resend-go/v2 v2.11.0 // indirect
github.com/riverqueue/river/riverdriver v0.14.2 // indirect
Expand Down Expand Up @@ -300,7 +465,7 @@ require (
go.uber.org/goleak v1.3.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20240904232852-e7e105dedf7e // indirect
golang.org/x/exp v0.0.0-20241210194714-1829a127f884 // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.32.0 // indirect
golang.org/x/sync v0.10.0
Expand Down
Loading

0 comments on commit 18e23bf

Please sign in to comment.