From 781628816d5f7f51fe5a6619f2a4978adb8934e5 Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Mon, 15 Apr 2024 17:46:44 +0200 Subject: [PATCH] Fix make in_docker generate (#3616) --- .cspell.json | 6 ++++- .mockery.yaml | 2 ++ .pre-commit-config.yaml | 2 +- Makefile | 13 +++++++--- docker/Dockerfile.make | 33 ++++++++++++++---------- pipeline/rpc/proto/generate.go | 5 ---- pipeline/rpc/proto/woodpecker.pb.go | 4 +-- pipeline/rpc/proto/woodpecker_grpc.pb.go | 2 +- server/forge/forge.go | 1 - server/forge/mocks/forge.go | 2 +- server/store/mocks/store.go | 2 +- server/store/store.go | 1 - 12 files changed, 42 insertions(+), 31 deletions(-) create mode 100644 .mockery.yaml diff --git a/.cspell.json b/.cspell.json index 107c9e082..30b77e051 100644 --- a/.cspell.json +++ b/.cspell.json @@ -90,7 +90,11 @@ "binutils", "nocolor", "logfile", - "Keyfunc" + "Keyfunc", + "protoc", + "PROTOC", + "GOBIN", + "GOPATH" ], "ignorePaths": [ "**/node_modules/**/*", diff --git a/.mockery.yaml b/.mockery.yaml new file mode 100644 index 000000000..cc734bcae --- /dev/null +++ b/.mockery.yaml @@ -0,0 +1,2 @@ +--- +disable-version-string: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 088f65d38..fa3427fe3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: - id: checkmake exclude: '^docker/Dockerfile.make$' # actually a Dockerfile and not a makefile - repo: https://github.com/hadolint/hadolint - rev: v2.12.1-beta + rev: v2.12.0 hooks: - id: hadolint - repo: https://github.com/pre-commit/mirrors-prettier diff --git a/Makefile b/Makefile index c0029f25b..e4a33838f 100644 --- a/Makefile +++ b/Makefile @@ -58,8 +58,6 @@ ifeq (in_docker,$(firstword $(MAKECMDGOALS))) -e TARGETOS="$(TARGETOS)" \ -e TARGETARCH="$(TARGETARCH)" \ -e CGO_ENABLED="$(CGO_ENABLED)" \ - -e GOPATH=/tmp/go \ - -e HOME=/tmp/home \ -v $(PWD):/build --rm woodpecker/make:local make $(MAKE_ARGS) else @@ -110,7 +108,7 @@ clean-all: clean ## Clean all artifacts rm -rf docs/docs/40-cli.md docs/swagger.json .PHONY: generate -generate: generate-swagger ## Run all code generations +generate: install-tools generate-swagger ## Run all code generations go generate ./... generate-swagger: install-tools ## Run swagger code generation @@ -137,6 +135,15 @@ install-tools: ## Install development tools fi ; \ hash addlicense > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ go install github.com/google/addlicense@latest; \ + fi ; \ + hash mockery > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + go install github.com/vektra/mockery/v2@latest; \ + fi ; \ + hash protoc-gen-go > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + go install google.golang.org/protobuf/cmd/protoc-gen-go@latest; \ + fi ; \ + hash protoc-gen-go-grpc > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest; \ fi ui-dependencies: ## Install UI dependencies diff --git a/docker/Dockerfile.make b/docker/Dockerfile.make index 5f508a562..84f8e3140 100644 --- a/docker/Dockerfile.make +++ b/docker/Dockerfile.make @@ -1,17 +1,19 @@ # docker build --rm -f docker/Dockerfile.make -t woodpecker/make:local . -FROM docker.io/golang:1.22-alpine3.18 as golang_image -FROM docker.io/node:21-alpine3.18 +FROM docker.io/golang:1.22-alpine3.19 as golang_image +FROM docker.io/node:21-alpine3.19 -# renovate: datasource=repology depName=alpine_3_18/make versioning=loose -ENV MAKE_VERSION="4.4.1-r1" -# renovate: datasource=repology depName=alpine_3_18/gcc versioning=loose -ENV GCC_VERSION="12.2.1_git20220924-r10" -# renovate: datasource=repology depName=alpine_3_18/binutils-gold versioning=loose -ENV BINUTILS_GOLD_VERSION="2.40-r7" -# renovate: datasource=repology depName=alpine_3_18/musl-dev versioning=loose -ENV MUSL_DEV_VERSION="1.2.4-r2" +# renovate: datasource=repology depName=alpine_3_19/make versioning=loose +ENV MAKE_VERSION="4.4.1-r2" +# renovate: datasource=repology depName=alpine_3_19/gcc versioning=loose +ENV GCC_VERSION="13.2.1_git20231014-r0" +# renovate: datasource=repology depName=alpine_3_19/binutils-gold versioning=loose +ENV BINUTILS_GOLD_VERSION="2.41-r0" +# renovate: datasource=repology depName=alpine_3_19/musl-dev versioning=loose +ENV MUSL_DEV_VERSION="1.2.4_git20230717-r4" +# renovate: datasource=repology depName=alpine_3_19/protoc versioning=loose +ENV PROTOC_VERSION="24.4-r0" -RUN apk add --no-cache --update make=${MAKE_VERSION} gcc=${GCC_VERSION} binutils-gold=${BINUTILS_GOLD_VERSION} musl-dev=${MUSL_DEV_VERSION} && \ +RUN apk add --no-cache --update make=${MAKE_VERSION} gcc=${GCC_VERSION} binutils-gold=${BINUTILS_GOLD_VERSION} musl-dev=${MUSL_DEV_VERSION} protoc=${PROTOC_VERSION} && \ corepack enable # Build packages. @@ -20,9 +22,12 @@ COPY Makefile / ENV PATH=$PATH:/usr/local/go/bin # Cache tools -RUN make install-tools && \ - mv /root/go/bin/* /usr/local/go/bin/ && \ - chmod 755 /usr/local/go/bin/* +RUN GOBIN=/usr/local/go/bin make install-tools && \ + rm -rf /Makefile + +ENV GOPATH=/tmp/go +ENV HOME=/tmp/home +ENV PATH=$PATH:/usr/local/go/bin:/tmp/go/bin WORKDIR /build RUN chmod -R 777 /root diff --git a/pipeline/rpc/proto/generate.go b/pipeline/rpc/proto/generate.go index a0f827ec1..8a3ce2ccf 100644 --- a/pipeline/rpc/proto/generate.go +++ b/pipeline/rpc/proto/generate.go @@ -16,8 +16,3 @@ package proto //go:generate protoc --go_out=paths=source_relative:. woodpecker.proto //go:generate protoc --go-grpc_out=paths=source_relative:. woodpecker.proto - -// install protoc: https://grpc.io/docs/protoc-installation/ -// and get needed binary's: -// go install google.golang.org/protobuf/cmd/protoc-gen-go@latest -// go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest diff --git a/pipeline/rpc/proto/woodpecker.pb.go b/pipeline/rpc/proto/woodpecker.pb.go index f49b64d33..c5cf5f47d 100644 --- a/pipeline/rpc/proto/woodpecker.pb.go +++ b/pipeline/rpc/proto/woodpecker.pb.go @@ -15,8 +15,8 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 -// protoc v4.25.1 +// protoc-gen-go v1.33.0 +// protoc v4.24.4 // source: woodpecker.proto package proto diff --git a/pipeline/rpc/proto/woodpecker_grpc.pb.go b/pipeline/rpc/proto/woodpecker_grpc.pb.go index 837ce74e0..787f8f6e7 100644 --- a/pipeline/rpc/proto/woodpecker_grpc.pb.go +++ b/pipeline/rpc/proto/woodpecker_grpc.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.3.0 -// - protoc v4.25.1 +// - protoc v4.24.4 // source: woodpecker.proto package proto diff --git a/server/forge/forge.go b/server/forge/forge.go index a823bc422..bb5db187d 100644 --- a/server/forge/forge.go +++ b/server/forge/forge.go @@ -15,7 +15,6 @@ package forge -//go:generate go install github.com/vektra/mockery/v2@latest //go:generate mockery --name Forge --output mocks --case underscore import ( diff --git a/server/forge/mocks/forge.go b/server/forge/mocks/forge.go index e47fd1490..a926ca16a 100644 --- a/server/forge/mocks/forge.go +++ b/server/forge/mocks/forge.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.1. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package mocks diff --git a/server/store/mocks/store.go b/server/store/mocks/store.go index 81522b9e9..229574a66 100644 --- a/server/store/mocks/store.go +++ b/server/store/mocks/store.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.1. DO NOT EDIT. +// Code generated by mockery. DO NOT EDIT. package mocks diff --git a/server/store/store.go b/server/store/store.go index 4dc47b9fc..1a34deda2 100644 --- a/server/store/store.go +++ b/server/store/store.go @@ -14,7 +14,6 @@ package store -//go:generate go install github.com/vektra/mockery/v2@latest //go:generate mockery --name Store --output mocks --case underscore import (