Skip to content

Commit

Permalink
Merge pull request #20 from Senzing/18.dockter.1
Browse files Browse the repository at this point in the history
18.dockter.1
  • Loading branch information
docktermj authored Aug 5, 2023
2 parents 6165f18 + 805b084 commit 2c92002
Show file tree
Hide file tree
Showing 14 changed files with 193 additions and 287 deletions.
26 changes: 0 additions & 26 deletions .github/workflows/build-docker-container.yaml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/go-test-darwin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Based on
# - https://github.com/marketplace/actions/setup-go-environment

name: go-test-darwin.yaml

on: [push]

jobs:
build:
runs-on: macos-latest
strategy:
matrix:
go: ["1.20"]
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: Run go test
run: go test -v -p 1 ./...
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Based on
# - https://github.com/marketplace/actions/setup-go-environment

name: go-test.yaml
name: go-test-linux.yaml

on: [push]

Expand All @@ -11,12 +11,15 @@ jobs:
strategy:
matrix:
go: ["1.20"]
name: Go ${{ matrix.go }}
name: Go ${{ matrix.go }} - linux
steps:
- uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go }}
- run: pwd
- run: go test -v -p 1 ./...
- name: Run go test
run: go test -v -p 1 ./...
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
# Go workspace file
go.work
.history
target/
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

-

## [0.1.5] - 2023-08-05

### Changed in 0.1.5

- Refactored to `template-go`
- Updated dependencies
- github.com/senzing/go-common v0.2.11

## [0.1.4] - 2023-08-02

### Changed in 0.1.4
Expand Down
80 changes: 0 additions & 80 deletions Dockerfile

This file was deleted.

91 changes: 38 additions & 53 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# Makefile for go-cmdhelping.

# Detect the operating system and architecture

include Makefile.osdetect

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

# "Simple expanded" variables (':=')

# PROGRAM_NAME is the name of the GIT repository.
PROGRAM_NAME := $(shell basename `git rev-parse --show-toplevel`)
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MAKEFILE_DIRECTORY := $(dir $(MAKEFILE_PATH))
MAKEFILE_DIRECTORY := $(shell dirname $(MAKEFILE_PATH))
TARGET_DIRECTORY := $(MAKEFILE_DIRECTORY)/target
DOCKER_CONTAINER_NAME := $(PROGRAM_NAME)
DOCKER_IMAGE_NAME := senzing/$(PROGRAM_NAME)
Expand All @@ -15,6 +23,9 @@ BUILD_TAG := $(shell git describe --always --tags --abbrev=0 | sed 's/v//')
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|')
GO_OSARCH = $(subst /, ,$@)
GO_OS = $(word 1, $(GO_OSARCH))
GO_ARCH = $(word 2, $(GO_OSARCH))

# Recursive assignment ('=')

Expand All @@ -30,6 +41,9 @@ LD_LIBRARY_PATH ?= /opt/senzing/g2/lib

.EXPORT_ALL_VARIABLES:

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

# -----------------------------------------------------------------------------
# The first "make" target runs as default.
# -----------------------------------------------------------------------------
Expand All @@ -39,6 +53,7 @@ default: help

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

.PHONY: dependencies
Expand All @@ -48,52 +63,25 @@ dependencies:
@go mod tidy


.PHONY: build
build: build-linux


.PHONY: build-linux
build-linux:
@GOOS=linux \
GOARCH=amd64 \
go build \
-ldflags \
"-X 'main.buildIteration=${BUILD_ITERATION}' \
-X 'main.buildVersion=${BUILD_VERSION}' \
-X 'main.programName=${PROGRAM_NAME}' \
" \
-o $(GO_PACKAGE_NAME)
@mkdir -p $(TARGET_DIRECTORY)/linux || true
@mv $(GO_PACKAGE_NAME) $(TARGET_DIRECTORY)/linux


.PHONY: build-scratch
build-scratch:
@GOOS=linux \
GOARCH=amd64 \
CGO_ENABLED=0 \
go build \
-a \
-installsuffix cgo \
-ldflags \
"-s \
-w \
-X 'github.com/roncewind/move/cmd.buildIteration=${BUILD_ITERATION}' \
-X 'github.com/roncewind/move/cmd.buildVersion=${BUILD_VERSION}' \
-X 'github.com/roncewind/move/cmd.programName=${PROGRAM_NAME}' \
" \
-o $(GO_PACKAGE_NAME)
@mkdir -p $(TARGET_DIRECTORY)/scratch || true
@mv $(GO_PACKAGE_NAME) $(TARGET_DIRECTORY)/scratch
PLATFORMS := darwin/amd64 linux/amd64 windows/amd64
$(PLATFORMS):
@echo Building $(TARGET_DIRECTORY)/$(GO_OS)-$(GO_ARCH)/$(PROGRAM_NAME)
@mkdir -p $(TARGET_DIRECTORY)/$(GO_OS)-$(GO_ARCH) || true
@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
# -----------------------------------------------------------------------------

.PHONY: test
test:
# @go test -v -p 1 ./...
@go test -v ./engineconfiguration
@go test -v -p 1 ./...
# @go test -v ./engineconfiguration

# -----------------------------------------------------------------------------
# docker-build
Expand Down Expand Up @@ -125,17 +113,6 @@ docker-build-package:
--tag $(DOCKER_BUILD_IMAGE_NAME) \
.

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

.PHONY: package
package: docker-build-package
@mkdir -p $(TARGET_DIRECTORY) || true
@CONTAINER_ID=$$(docker create $(DOCKER_BUILD_IMAGE_NAME)); \
docker cp $$CONTAINER_ID:/output/. $(TARGET_DIRECTORY)/; \
docker rm -v $$CONTAINER_ID

# -----------------------------------------------------------------------------
# Run
# -----------------------------------------------------------------------------
Expand Down Expand Up @@ -186,5 +163,13 @@ print-make-variables:
.PHONY: help
help:
@echo "Build $(PROGRAM_NAME) version $(BUILD_VERSION)-$(BUILD_ITERATION)".
@echo "All targets:"
@$(MAKE) -pRrq -f $(lastword $(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
@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

# -----------------------------------------------------------------------------
# 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)
24 changes: 24 additions & 0 deletions Makefile.darwin
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Makefile extensions for darwin.

# -----------------------------------------------------------------------------
# Makefile targets supported by all platforms.
# -----------------------------------------------------------------------------

.PHONY: hello-world
hello-world:
@echo "Hello World, from darwin."

# -----------------------------------------------------------------------------
# Build
# -----------------------------------------------------------------------------

.PHONY: build
build: darwin/amd64

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

.PHONY: only-darwin
only-darwin:
@echo "Only darwin has this Makefile target."
24 changes: 24 additions & 0 deletions Makefile.linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Makefile extensions for linux.

# -----------------------------------------------------------------------------
# Makefile targets supported by all platforms.
# -----------------------------------------------------------------------------

.PHONY: hello-world
hello-world:
@echo "Hello World, from linux."

# -----------------------------------------------------------------------------
# Build
# -----------------------------------------------------------------------------

.PHONY: build
build: linux/amd64

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

.PHONY: only-linux
only-linux:
@echo "Only linux has this Makefile target."
Loading

0 comments on commit 2c92002

Please sign in to comment.