Skip to content

Commit

Permalink
174.dockter.1 (#176)
Browse files Browse the repository at this point in the history
* #174 Refactor to template

* #174 Refactor to template

* #174 Refactor to template

* #174 Prepare for versioned release

* #174 Prepare for versioned release
  • Loading branch information
docktermj authored Aug 18, 2023
1 parent 309ed8c commit 326c6cc
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 119 deletions.
12 changes: 2 additions & 10 deletions .github/workflows/go-test-darwin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,18 @@ name: go-test-darwin.yaml
on: [push]

env:
SENZING_TOOLS_DATABASE_URL: "sqlite3://na:na@/tmp/sqlite/G2C.db"
LD_LIBRARY_PATH: /opt/senzing/g2/lib:/opt/senzing/g2/lib/macos
DYLD_LIBRARY_PATH: /opt/senzing/g2/lib:/opt/senzing/g2/lib/macos
SENZING_TOOLS_DATABASE_URL: "sqlite3://na:na@/tmp/sqlite/G2C.db"

jobs:
build:
runs-on: macos-latest
strategy:
matrix:
go: ["1.20"]
go: ["1.20", "1.21"]
name: Go ${{ matrix.go }} - darwin
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- name: Checkout repository
uses: actions/checkout@v3
with:
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 @@ -15,7 +15,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
14 changes: 5 additions & 9 deletions .github/workflows/make-go-github-file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@ on:

jobs:
make-go-github-file:
name: Update cmd/version.go
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: "0"
- name: Make github.go file
uses: Senzing/github-action-make-go-github-file@main
uses: Senzing/build-resources/.github/workflows/make-go-github-file.yaml@main
secrets:
SENZING_GITHUB_GPG_PRIVATE_KEY: ${{ secrets.SENZING_GITHUB_GPG_PRIVATE_KEY }}
SENZING_GITHUB_GPG_PASSPHRASE: ${{ secrets.SENZING_GITHUB_GPG_PASSPHRASE }}
SENZING_GITHUB_ACTOR: ${{ secrets.SENZING_GITHUB_ACTOR }}
16 changes: 15 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 @@ -13,5 +16,16 @@

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work

# macOS artifacts
.DS_STORE

# Visual Studio code
.vscode
.history
target/

# Makefile
target/
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

-

## [0.4.14] - 2023-08-17

### Changed in 0.4.14

- In `go.mod` update to `go 1.21`
- In `Dockerfile` update to `golang:1.21.0-bullseye`
- Update dependencies
- github.com/senzing/g2-sdk-go-base v0.2.4
- github.com/senzing/go-cmdhelping v0.1.7
- github.com/senzing/go-common v0.2.13

## [0.4.13] - 2023-08-08

### Changed in 0.4.13
Expand Down
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
123 changes: 54 additions & 69 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Makefile that builds serve-grpc, a "go" program.
# Makefile for serve-grpc.

# 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 @@ -43,9 +43,6 @@ SENZING_TOOLS_DATABASE_URL ?= sqlite3://na:na@/tmp/sqlite/G2C.db

.EXPORT_ALL_VARIABLES:

-include Makefile.$(OSTYPE)
-include Makefile.$(OSTYPE)_$(OSARCH)

# -----------------------------------------------------------------------------
# The first "make" target runs as default.
# -----------------------------------------------------------------------------
Expand All @@ -54,8 +51,14 @@ SENZING_TOOLS_DATABASE_URL ?= sqlite3://na:na@/tmp/sqlite/G2C.db
default: help

# -----------------------------------------------------------------------------
# Build
# - The "build" target is implemented in Makefile.OS.ARCH files.
# Operating System / Architecture targets
# -----------------------------------------------------------------------------

-include Makefile.$(OSTYPE)
-include Makefile.$(OSTYPE)_$(OSARCH)

# -----------------------------------------------------------------------------
# Dependency management
# -----------------------------------------------------------------------------

.PHONY: dependencies
Expand All @@ -64,6 +67,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 @@ -72,20 +80,6 @@ $(PLATFORMS):
@GOOS=$(GO_OS) GOARCH=$(GO_ARCH) go build -o $(TARGET_DIRECTORY)/$(GO_OS)-$(GO_ARCH)/$(PROGRAM_NAME)


.PHONY: build-all $(PLATFORMS)
build-all: $(PLATFORMS)
@mv $(TARGET_DIRECTORY)/windows-amd64/$(PROGRAM_NAME) $(TARGET_DIRECTORY)/windows-amd64/$(PROGRAM_NAME).exe

# -----------------------------------------------------------------------------
# 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:
@docker build \
Expand All @@ -98,33 +92,17 @@ 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
# - The "run" target is implemented in Makefile.OS.ARCH files.
# -----------------------------------------------------------------------------

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


.PHONY: docker-run
docker-run:
@docker run \
Expand All @@ -134,20 +112,25 @@ docker-run:
$(DOCKER_IMAGE_NAME)

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

.PHONY: new-sqlite
new-sqlite:
@rm -rf /tmp/sqlite
@mkdir /tmp/sqlite
@cp testdata/sqlite/G2C.db /tmp/sqlite/G2C.db

.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 @@ -159,26 +142,28 @@ 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:
@rm -rf /tmp/sqlite
@mkdir /tmp/sqlite
@cp testdata/sqlite/G2C.db /tmp/sqlite/G2C.db

# -----------------------------------------------------------------------------
# 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)
12 changes: 4 additions & 8 deletions Makefile.darwin
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,14 @@ test:
# Run
# -----------------------------------------------------------------------------

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

.PHONY: package
package:
@echo "The 'package' target is not implemented for darwin"
.PHONY: run
run:
@go run -exec macos_exec_dyld.sh main.go

# -----------------------------------------------------------------------------
# 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."
12 changes: 7 additions & 5 deletions Makefile.linux
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# Makefile extensions for linux.

# -----------------------------------------------------------------------------
# Variables
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# Makefile targets supported by all platforms.
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -38,6 +34,11 @@ test:
# Run
# -----------------------------------------------------------------------------

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


.PHONY: run-serve-grpc
run-serve-grpc: build
@target/linux-amd64/serve-grpc
Expand All @@ -46,6 +47,7 @@ run-serve-grpc: build
.PHONY: run-serve-grpc-trace
run-serve-grpc-trace: build
@target/linux-amd64/serve-grpc --log-level TRACE --engine-log-level 1

# -----------------------------------------------------------------------------
# Package
# -----------------------------------------------------------------------------
Expand All @@ -63,4 +65,4 @@ package: docker-build-package

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

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

# -----------------------------------------------------------------------------
# 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."
Loading

0 comments on commit 326c6cc

Please sign in to comment.