Skip to content

Commit

Permalink
feat: initial pass at refactor to genqlient (#66)
Browse files Browse the repository at this point in the history
Maintains parity with the current functionality but replaces the
repo count and repo gathering with queries from genqlient's generated
code. Does not break everything out into testable functions, but enables
further iterative refactors and feature addition.
  • Loading branch information
adrielp authored Aug 14, 2023
1 parent 1518bd6 commit 62ddb78
Show file tree
Hide file tree
Showing 13 changed files with 27,644 additions and 133 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ jobs:
- name: Make lint-all
run: make lint-all

- name: Check GenQlient
run: |
make genqlient-all
git diff -s --exit-code || (echo 'Generated GraphQL queries are out of date. Run make genqlient-all and commit the changes' && exit 1)
- name: Check packages are up-to-date
run: |
make tidy-all
git diff -s --exit-code || (echo 'Packages are out of date. Run make tidy-all and commit the changes' && exit 1)
build:
name: build
strategy:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ ocb
tmp

dist/

# MacOS
.DS_Store

13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ install-tools:
go install github.com/securego/gosec/v2/cmd/gosec@latest
go install golang.org/x/tools/cmd/goimports@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
go install github.com/Khan/genqlient@latest

.PHONY: lint-all $(PKG_RECEIVER_DIRS)
lint-all: $(PKG_RECEIVER_DIRS)
Expand All @@ -86,3 +87,15 @@ cibuild: check-prep
dockerbuild:
$(MAKE) build OS=linux ARCH=amd64
docker build . -t liatrio/liatrio-otel-collector:localdev --build-arg BIN_PATH="./build/otelcol-custom"

.PHONY: genqlient-all
genqlient-all: install-tools
$(MAKE) -j 4 -C $(PKG_RECEIVER_DIRS) genqlient

.PHONY: tidy-all
tidy-all:
$(MAKE) -j 4 -C $(PKG_RECEIVER_DIRS) tidy

.PHONY: fmt-all
fmt-all:
$(MAKE) -j 4 -C $(PKG_RECEIVER_DIRS) fmt
12 changes: 12 additions & 0 deletions Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ else
.SHELLFLAGS = -o pipefail -c
endif

GENQLIENT_DIR = $(shell find . -type f -name 'genqlient.yaml' -exec dirname {} \;)

# SRC_ROOT is the top of the source tree.
SRC_ROOT := $(shell git rev-parse --show-toplevel)

Expand All @@ -28,3 +30,13 @@ metagen:
.PHONY: test
test:
go test -v ./...

.PHONY: fmt
fmt:
go fmt ./...

.PHONY: genqlient
genqlient:
cd $(GENQLIENT_DIR) && \
[[ -f genqlient.yaml && -f genqlient.graphql && -f schema.graphql ]] && \
go run github.com/Khan/genqlient@latest
8 changes: 2 additions & 6 deletions pkg/receiver/gitproviderreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/liatrio/liatrio-otel-collector/pkg/receiver/gitproviderreceive
go 1.19

require (
github.com/Khan/genqlient v0.6.0
github.com/google/go-cmp v0.5.9
github.com/google/go-github/v50 v50.2.0
github.com/shurcooL/githubv4 v0.0.0-20230704064427-599ae7bbf278
github.com/stretchr/testify v1.8.4
go.opentelemetry.io/collector v0.81.0
Expand All @@ -20,10 +20,8 @@ require (

require (
contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230710112148-e01326fd72eb // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
Expand All @@ -36,7 +34,6 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand Down Expand Up @@ -66,6 +63,7 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/tklauser/go-sysconf v0.3.11 // indirect
github.com/tklauser/numcpus v0.6.0 // indirect
github.com/vektah/gqlparser/v2 v2.5.1 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/collector/config/configauth v0.81.0 // indirect
Expand All @@ -91,13 +89,11 @@ require (
go.opentelemetry.io/otel/trace v1.16.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/oauth2 v0.10.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
gonum.org/v1/gonum v0.13.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/grpc v1.56.2 // indirect
google.golang.org/protobuf v1.31.0 // indirect
Expand Down
48 changes: 10 additions & 38 deletions pkg/receiver/gitproviderreceiver/go.sum

Large diffs are not rendered by default.

Loading

0 comments on commit 62ddb78

Please sign in to comment.