Skip to content

Commit

Permalink
Nick/neos 313 add mockery to devcontainer features (#624)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickzelei authored Nov 20, 2023
1 parent 19902a9 commit 75f512d
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .github/.devcontainer/devcontainer-lock.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"features": {
"ghcr.io/brokeyourbike/devcontainer-features/mockery-go:0.2.0": {
"version": "0.2.0",
"resolved": "ghcr.io/brokeyourbike/devcontainer-features/mockery-go@sha256:d068a6f83d88151b618dbc9e54ad122157ab378c0ae41247f35144c92bab5547",
"integrity": "sha256:d068a6f83d88151b618dbc9e54ad122157ab378c0ae41247f35144c92bab5547"
},
"ghcr.io/devcontainers-contrib/features/grpcurl-asdf:2": {
"version": "2.0.14",
"resolved": "ghcr.io/devcontainers-contrib/features/grpcurl-asdf@sha256:9e90a5c3525aa1da83f569a1ba53ffea20e53c844be1dabc7adc4f776ef65c8e",
Expand Down
1 change: 1 addition & 0 deletions .github/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"ghcr.io/devcontainers/features/go:1": {},
"ghcr.io/guiyomh/features/golangci-lint:0": {},
"ghcr.io/nucleuscloud/devcontainer-features/sqlc:1": {},
"ghcr.io/brokeyourbike/devcontainer-features/mockery-go:0.2.0": {},
/* NodeJS/Browser */
"ghcr.io/devcontainers/features/node:1": {},
/* Temporal */
Expand Down
10 changes: 4 additions & 6 deletions backend/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
GO=go
BUF=buf
SOPS=sops

default: all

Expand All @@ -9,7 +7,7 @@ all: build
vet:
$(GO) vet ./...

build: protos vet ## Build and grpc gateway
build: gen vet
hack/build.sh
.PHONY: build

Expand All @@ -21,11 +19,11 @@ run:
# CGO_ENABLED=0 $(GO) build -gcflags="all=-N -l" -o bin/mgmt cmd/mgmt/*.go
# .PHONY: build-debug

protos: ## Generate code
./hack/gen.sh
protos: gen
.PHONY: protos

gen: protos
gen:
./hack/gen.sh
.PHONY: gen

install-tools: install-go-tools
Expand Down
48 changes: 40 additions & 8 deletions backend/hack/gen.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,46 @@
update_frontend_client() {
rm -rf ../frontend/neosync-api-client
mkdir -p ../frontend/neosync-api-client
mv gen/es/protos/** ../frontend/neosync-api-client
rm -rf gen/es
}

# `buf format -w` writes to each file, so causes tilt to loop. instead we instruct buf
# to just output the changes in diff format and apply those.
BUF_VERSION=$(cat BUF_VERSION)
SQLC_VERSION=$(cat SQLC_VERSION)
docker run --rm -i --volume "./:/workspace" --workdir "/workspace" "bufbuild/buf:${BUF_VERSION}" format -d | patch --quiet
docker run --rm -i --volume "./:/workspace" --workdir "/workspace" "bufbuild/buf:${BUF_VERSION}" generate &
docker run --rm -i --volume "./:/workspace" --workdir "/workspace" "bufbuild/buf:${BUF_VERSION}" generate --template ./buf-es.gen.yaml &
docker run --rm -i --volume "./:/src" --workdir "/src" "sqlc/sqlc:${SQLC_VERSION}" generate &

# buf fmt
docker run --rm -i \
--volume "./protos:/workspace" \
--workdir "/workspace" \
"bufbuild/buf:${BUF_VERSION}" format -d | patch --quiet

# buf generate
docker run --rm -i \
--volume "./gen:/workspace/gen" \
--volume "./buf.work.yaml:/workspace/buf.work.yaml" \
--volume "./buf.gen.yaml:/workspace/buf.gen.yaml" \
--volume "./protos:/workspace/protos" \
--workdir "/workspace" \
"bufbuild/buf:${BUF_VERSION}" generate &
docker run --rm -i \
--volume "./gen:/workspace/gen" \
--volume "./buf.work.yaml:/workspace/buf.work.yaml" \
--volume "./buf-es.gen.yaml:/workspace/buf.gen.yaml" \
--volume "./protos:/workspace/protos" \
--workdir "/workspace" \
"bufbuild/buf:${BUF_VERSION}" generate &

# sqlc
docker run --rm -i \
--volume "./gen:/workspace/gen" \
--volume "./sql:/workspace/sql" \
--volume "./sqlc.yaml:/workspace/sqlc.yaml" \
--workdir "/workspace" \
"sqlc/sqlc:${SQLC_VERSION}" generate &
wait

rm -rf ../frontend/neosync-api-client
mkdir -p ../frontend/neosync-api-client
mv gen/es/protos/** ../frontend/neosync-api-client
rm -rf gen/es
update_frontend_client &

wait

0 comments on commit 75f512d

Please sign in to comment.