Skip to content

Commit

Permalink
Merge pull request #16 from insidieux/issue-15-go-get-cmd
Browse files Browse the repository at this point in the history
Fix issue #15: cannot get inizio cmd via go get
  • Loading branch information
insidieux authored Apr 19, 2021
2 parents f73c21b + 13d506e commit 56229d3
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 44 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ jobs:
head_ref: ${{ github.head_ref }}
- name: Cleanup
run: make cleanup
- name: Generate wire
run: make wire
- name: Vendor
run: make vendor
- name: Build
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ jobs:
uses: actions/checkout@v2
- name: Cleanup
run: make cleanup
- name: Generate wire
run: make wire
- name: Vendor
run: make vendor
- name: Test
run: make test
- name: Lint
run: make lint
- name: Test
run: make test
- name: Send code coverage report
uses: codecov/codecov-action@v1
with:
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@

/bin/*
coverage.out
wire_gen.go
*packr.go
41 changes: 21 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
override APP_NAME=inizio
override GO_VERSION=1.16
override PROTOC_VERSION=3.1.32
override MOCKERY_VERSION=v2.7.1
override GOLANGCI_LINT_VERSION=v1.38.0
override GOLANGCI_LINT_VERSION=v1.39.0
override SECUREGO_GOSEC_VERSION=v2.7.0
override HADOLINT_VERSION=v1.23.0
override HADOLINT_VERSION=v2.2.0
override WIRE_VERSION=v0.5.0
override PROTOC_VERSION=3.1.33
override MOCKERY_VERSION=v2.7.4
override CHANGELOG_GENERATOR_VERSION=1.15.2

GOOS?=$(shell go env GOOS || echo linux)
Expand All @@ -20,31 +21,16 @@ $(error "Binary docker not found in $(PATH)")
endif

.PHONY: all
all: cleanup wire vendor lint test build
all: cleanup vendor lint test build

# --- [ CI helpers ] ---------------------------------------------------------------------------------------------------

.PHONY: cleanup
cleanup:
@rm ${PWD}/bin/${APP_NAME} || true
@rm ${PWD}/coverage.out || true
@find ${PWD} -type f -name "wire_gen.go" -delete
@rm -r ${PWD}/vendor || true

.PHONY: wire
wire:
@docker build \
--build-arg GO_VERSION=${GO_VERSION} \
-f ${PWD}/build/docker/utils/wire/Dockerfile \
-t wire:custom \
build/docker/utils/wire
@find ${PWD} -type f -name "wire_gen.go" -delete
@docker run --rm \
-v ${PWD}:/project \
-w /project \
wire:custom \
/project/...

.PHONY: vendor
vendor:
@rm -r ${PWD}/vendor || true
Expand Down Expand Up @@ -133,6 +119,21 @@ build:

# --- [ Local helpers ] ------------------------------------------------------------------------------------------------

.PHONY: wire
wire:
@docker build \
--build-arg GO_VERSION=${GO_VERSION} \
--build-arg WIRE_VERSION=${WIRE_VERSION} \
-f ${PWD}/build/docker/utils/wire/Dockerfile \
-t wire:custom \
build/docker/utils/wire
@find ${PWD} -type f -name "wire_gen.go" -delete
@docker run --rm \
-v ${PWD}:/project \
-w /project \
wire:custom \
/project/...

.PHONY: protoc
protoc: $(shell find api/protobuf -type f -name "*.proto")
@find ${PWD}/internal -type f -name "*.pb.go" -delete
Expand Down
12 changes: 0 additions & 12 deletions build/docker/cmd/inizio/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
ARG GO_VERSION=1.16
ARG ALPINE_VERSION=3.12

### Wire
FROM golang:${GO_VERSION} as wire
ARG WIRE_VERSION=v0.5.0
RUN GO111MODULE=on go get -u -t github.com/google/wire/cmd/wire@${WIRE_VERSION}
COPY . /project
WORKDIR /project
RUN find . -not -path "./vendor/*" -type f -name "wire_gen.go" -delete \
&& /go/bin/wire ./... \
&& mkdir -p /usr/local/src/wire \
&& find . -not -path "./vendor/*" -type f -name "wire_gen.go" -exec cp --parents {} /usr/local/src/wire \;

### Vendor
FROM golang:${GO_VERSION} as vendor
COPY . /project
Expand All @@ -22,7 +11,6 @@ RUN go mod tidy && \
### Build binary
FROM golang:${GO_VERSION} as build-binary
COPY . /project
COPY --from=wire /usr/local/src/wire /project
COPY --from=vendor /project/vendor /project/vendor
WORKDIR /project
RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 GO111MODULE=on go build \
Expand Down
3 changes: 2 additions & 1 deletion build/docker/utils/wire/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ ARG GO_VERSION=1.16

### Image
FROM golang:${GO_VERSION}
RUN go get -u -t github.com/google/wire/cmd/wire
ARG WIRE_VERSION=v0.5.0
RUN go get -u -t github.com/google/wire/cmd/wire@${WIRE_VERSION}
ENTRYPOINT ["/go/bin/wire"]
72 changes: 72 additions & 0 deletions cmd/inizio/internal/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion cmd/inizio/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import (
)

func main() {
ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()
if err := internal.NewCommand().ExecuteContext(ctx); err != nil {
logger.GetLogger().Fatalf(`Failed to execute command: %s`, err.Error())
}
Expand Down
4 changes: 2 additions & 2 deletions internal/builtin/layout/embed/Makefile.gotmpl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
override APP_NAME={{ .Application.Name | lower }}
{{ $version := semver (.Golang.Version | default "1.16") }}override GO_VERSION={{ $version.Major }}.{{ $version.Minor }}
override GOLANGCI_LINT_VERSION=v1.38.0
override GOLANGCI_LINT_VERSION=v1.39.0
override SECUREGO_GOSEC_VERSION=v2.7.0
override HADOLINT_VERSION=v1.23.0
override HADOLINT_VERSION=v2.2.0

GOOS?=$(shell go env GOOS || echo linux)
GOARCH?=$(shell go env GOARCH || echo amd64)
Expand Down

0 comments on commit 56229d3

Please sign in to comment.