Skip to content

Commit

Permalink
83.dockter.3 (#88)
Browse files Browse the repository at this point in the history
* #82 Update dependencies

* #82 Refactor order of targets

* #83 Refactor target locations

* #83 Refactor to GitHub template

* #83 Refactor to GitHub template

* #83 Improve setup

* #83 Add check for go 1.21

* #83 Suport go1.21

* #83 Revert back to go 1.20

* #83 Revert back to go 1.20

* #83 Update to go1.21.0
  • Loading branch information
docktermj authored Aug 18, 2023
1 parent ade2286 commit e120e4e
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go-test-darwin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
go: ["1.20"]
go: ["1.20", "1.21"]
name: Go ${{ matrix.go }} - darwin
steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-test-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ["1.20"]
go: ["1.20", "1.21"]
name: Go ${{ matrix.go }} - linux
steps:
- name: Checkout repository
Expand Down
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
Expand All @@ -17,5 +20,12 @@
# Go workspace file
go.work

# macOS artifacts
.DS_STORE

# Visual Studio code
.vscode
.history
target/

# Makefile
target/
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# -----------------------------------------------------------------------------

ARG IMAGE_SENZINGAPI_RUNTIME=senzing/senzingapi-runtime:3.6.0
ARG IMAGE_GO_BUILDER=golang:1.20.4
ARG IMAGE_GO_BUILDER=golang:1.21.0-bullseye
ARG IMAGE_FINAL=senzing/senzingapi-runtime:3.6.0

# -----------------------------------------------------------------------------
Expand Down
102 changes: 48 additions & 54 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Makefile for template-go.

# Detect the operating system and architecture
# Detect the operating system and architecture.

include Makefile.osdetect

Expand All @@ -24,13 +24,13 @@ BUILD_ITERATION := $(shell git log $(BUILD_TAG)..HEAD --oneline | wc -l | sed 's
GIT_REMOTE_URL := $(shell git config --get remote.origin.url)
GO_PACKAGE_NAME := $(shell echo $(GIT_REMOTE_URL) | sed -e 's|^git@github.com:|github.com/|' -e 's|\.git$$||' -e 's|Senzing|senzing|')
PATH := $(MAKEFILE_DIRECTORY)/bin:$(PATH)
GO_OSARCH = $(subst /, ,$@)
GO_OS = $(word 1, $(GO_OSARCH))
GO_ARCH = $(word 2, $(GO_OSARCH))

# Recursive assignment ('=')

CC = gcc
GO_OSARCH = $(subst /, ,$@)
GO_OS = $(word 1, $(GO_OSARCH))
GO_ARCH = $(word 2, $(GO_OSARCH))

# Conditional assignment. ('?=')
# Can be overridden with "export"
Expand All @@ -57,8 +57,7 @@ default: help
-include Makefile.$(OSTYPE)_$(OSARCH)

# -----------------------------------------------------------------------------
# Build
# - The "build" target is implemented in Makefile.OS.ARCH files.
# Dependency management
# -----------------------------------------------------------------------------

.PHONY: dependencies
Expand All @@ -67,6 +66,11 @@ dependencies:
@go get -t -u ./...
@go mod tidy

# -----------------------------------------------------------------------------
# Build
# - The "build" target is implemented in Makefile.OS.ARCH files.
# - docker-build: https://docs.docker.com/engine/reference/commandline/build/
# -----------------------------------------------------------------------------

PLATFORMS := darwin/amd64 linux/amd64 windows/amd64
$(PLATFORMS):
Expand All @@ -93,15 +97,6 @@ build-scratch:
@mkdir -p $(TARGET_DIRECTORY)/scratch || true
@mv $(GO_PACKAGE_NAME) $(TARGET_DIRECTORY)/scratch

# -----------------------------------------------------------------------------
# Test
# - The "test" target is implemented in Makefile.OS.ARCH files.
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# docker-build
# - https://docs.docker.com/engine/reference/commandline/build/
# -----------------------------------------------------------------------------

.PHONY: docker-build
docker-build:
Expand All @@ -115,33 +110,16 @@ docker-build:
--tag $(DOCKER_IMAGE_NAME):$(BUILD_VERSION) \
.


.PHONY: docker-build-package
docker-build-package:
@docker build \
--build-arg BUILD_ITERATION=$(BUILD_ITERATION) \
--build-arg BUILD_VERSION=$(BUILD_VERSION) \
--build-arg GO_PACKAGE_NAME=$(GO_PACKAGE_NAME) \
--build-arg PROGRAM_NAME=$(PROGRAM_NAME) \
--no-cache \
--file package.Dockerfile \
--tag $(DOCKER_BUILD_IMAGE_NAME) \
.

# -----------------------------------------------------------------------------
# Package
# - The "package" target is implemented in Makefile.OS.ARCH files.
# Test
# - The "test" target is implemented in Makefile.OS.ARCH files.
# -----------------------------------------------------------------------------


# -----------------------------------------------------------------------------
# Run
# -----------------------------------------------------------------------------

.PHONY: run
run:
@go run main.go


.PHONY: docker-run
docker-run:
@docker run \
Expand All @@ -150,15 +128,31 @@ docker-run:
--name $(DOCKER_CONTAINER_NAME) \
$(DOCKER_IMAGE_NAME)


.PHONY: run
run:
@go run main.go

# -----------------------------------------------------------------------------
# Utility targets
# Package
# - The "package" target is implemented in Makefile.OS.ARCH files.
# -----------------------------------------------------------------------------

.PHONY: update-pkg-cache
update-pkg-cache:
@GOPROXY=https://proxy.golang.org GO111MODULE=on \
go get $(GO_PACKAGE_NAME)@$(BUILD_TAG)
.PHONY: docker-build-package
docker-build-package:
@docker build \
--build-arg BUILD_ITERATION=$(BUILD_ITERATION) \
--build-arg BUILD_VERSION=$(BUILD_VERSION) \
--build-arg GO_PACKAGE_NAME=$(GO_PACKAGE_NAME) \
--build-arg PROGRAM_NAME=$(PROGRAM_NAME) \
--no-cache \
--file package.Dockerfile \
--tag $(DOCKER_BUILD_IMAGE_NAME) \
.

# -----------------------------------------------------------------------------
# Utility targets
# -----------------------------------------------------------------------------

.PHONY: clean
clean:
Expand All @@ -170,26 +164,26 @@ clean:
@rm -f $(GOPATH)/bin/$(PROGRAM_NAME) || true


.PHONY: help
help:
@echo "Build $(PROGRAM_NAME) version $(BUILD_VERSION)-$(BUILD_ITERATION)".
@echo "Makefile targets:"
@$(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs


.PHONY: print-make-variables
print-make-variables:
@$(foreach V,$(sort $(.VARIABLES)), \
$(if $(filter-out environment% default automatic, \
$(origin $V)),$(warning $V=$($V) ($(value $V)))))

# -----------------------------------------------------------------------------
# Help
# -----------------------------------------------------------------------------

.PHONY: help
help:
@echo "Build $(PROGRAM_NAME) version $(BUILD_VERSION)-$(BUILD_ITERATION)".
@echo "Makefile targets:"
@$(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
.PHONY: setup
setup:
@echo "No setup required."

# -----------------------------------------------------------------------------
# Optionally include platform-specific settings and targets.
# - Note: This is last because the "last one wins" when over-writing targets.
# -----------------------------------------------------------------------------

# -include Makefile.$(OSTYPE)
# -include Makefile.$(OSTYPE)_$(OSARCH)
.PHONY: update-pkg-cache
update-pkg-cache:
@GOPROXY=https://proxy.golang.org GO111MODULE=on \
go get $(GO_PACKAGE_NAME)@$(BUILD_TAG)
6 changes: 2 additions & 4 deletions Makefile.darwin
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,16 @@ test:
# Run
# -----------------------------------------------------------------------------


# -----------------------------------------------------------------------------
# Package
# -----------------------------------------------------------------------------

.PHONY: package
package:
@echo "The 'package' target is not implemented for darwin"

# -----------------------------------------------------------------------------
# Makefile targets supported only by this platform.
# -----------------------------------------------------------------------------

.PHONY: only-darwin
only-darwin:
@echo "Only darwin has this Makefile target."
@echo "Only darwin has this Makefile target."
2 changes: 1 addition & 1 deletion Makefile.linux
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ package: docker-build-package

.PHONY: only-linux
only-linux:
@echo "Only linux has this Makefile target."
@echo "Only linux has this Makefile target."
6 changes: 2 additions & 4 deletions Makefile.windows
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,16 @@ test:
# Run
# -----------------------------------------------------------------------------


# -----------------------------------------------------------------------------
# Package
# -----------------------------------------------------------------------------

.PHONY: package
package:
@echo "The 'package' target is not implemented for windows"

# -----------------------------------------------------------------------------
# Makefile targets supported only by this platform.
# -----------------------------------------------------------------------------

.PHONY: only-windows
only-windows:
@echo "Only windows has this Makefile target."
@echo "Only windows has this Makefile target."
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/senzing/template-go

go 1.20
go 1.21

require (
github.com/senzing/go-cmdhelping v0.1.6
Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
github.com/frankban/quicktest v1.14.4/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
Expand Down Expand Up @@ -100,6 +101,7 @@ github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
Expand Down Expand Up @@ -132,9 +134,11 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
Expand All @@ -148,6 +152,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/senzing/go-cmdhelping v0.1.6 h1:/ITQwip7Pec5ZMKhSkIEvk5E+7UryMIQ+d1E/KplGj4=
Expand Down Expand Up @@ -472,6 +477,7 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
Expand Down
2 changes: 1 addition & 1 deletion package.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# -----------------------------------------------------------------------------

ARG IMAGE_SENZINGAPI_RUNTIME=senzing/senzingapi-runtime:3.6.0
ARG IMAGE_GO_BUILDER=golang:1.20.4
ARG IMAGE_GO_BUILDER=golang:1.21.0-bullseye
ARG IMAGE_FPM_BUILDER=dockter/fpm:latest
ARG IMAGE_FINAL=alpine

Expand Down

0 comments on commit e120e4e

Please sign in to comment.