Skip to content

Commit

Permalink
#146 inherit from sz-sdk-go and sz-sdk-go-core
Browse files Browse the repository at this point in the history
  • Loading branch information
docktermj committed May 29, 2024
1 parent 19f5a2b commit 4269f55
Show file tree
Hide file tree
Showing 15 changed files with 198 additions and 58 deletions.
47 changes: 47 additions & 0 deletions .github/linters/.golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
run:
modules-download-mode: readonly
show-stats: true

output:
print-linter-name: false
sort-results: true

linters:
enable:
# List generated from: https://golangci-lint.run/usage/linters/
# We are enabling all defaults as well as any bug/security related
- asasalint
- asciicheck
- bidichk
- bodyclose
- contextcheck
- durationcheck
- errcheck
- errchkjson
- errorlint
- exhaustive
- exportloopref
- gocheckcompilerdirectives
- gochecksumtype
- gocritic
- gofmt
- gosec
- gosimple
- gosmopolitan
- govet
- ineffassign
- loggercheck
- makezero
- musttag
- nilerr
- noctx
- protogetter
- reassign
- revive
- rowserrcheck
- spancheck
- sqlclosecheck
- staticcheck
- testifylint
- unused
- zerologlint
5 changes: 5 additions & 0 deletions .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"ignore": [
"**/*.go,**/go-test*.yaml"
]
}
7 changes: 4 additions & 3 deletions .github/workflows/dependabot-approve-and-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ on:
pull_request:
branches: [main]

permissions:
contents: write
pull-requests: write

jobs:
dependabot-approve-and-merge:
permissions:
contents: write
pull-requests: write
secrets:
SENZING_GITHUB_CODEOWNER_PR_RW_TOKEN: ${{ secrets.SENZING_GITHUB_CODEOWNER_PR_RW_TOKEN }}
uses: senzing-factory/build-resources/.github/workflows/dependabot-approve-and-merge.yaml@v1
17 changes: 14 additions & 3 deletions .github/workflows/go-test-darwin.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: go test darwin

on: [push]
on: [pull_request, workflow_dispatch]

env:
DYLD_LIBRARY_PATH: /opt/senzing/g2/lib:/opt/senzing/g2/lib/macos
Expand All @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
go: ["1.21"]
os: [macos-latest]
os: [macos-13]

steps:
- name: checkout repository
Expand All @@ -30,4 +30,15 @@ jobs:
go-version: ${{ matrix.go }}

- name: run go test
run: go test -v -p 1 ./...
run: go test -v -p 1 ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./...

- name: Store coverage file
uses: actions/upload-artifact@v4
with:
name: cover.out
path: ./cover.out

coverage:
name: coverage
needs: go-test-darwin
uses: senzing-factory/build-resources/.github/workflows/go-coverage.yaml@v2
13 changes: 12 additions & 1 deletion .github/workflows/go-test-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,15 @@ jobs:
go-version: ${{ matrix.go }}

- name: run go test
run: go test -v -p 1 ./...
run: go test -v -p 1 ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./...

- name: Store coverage file
uses: actions/upload-artifact@v4
with:
name: cover.out
path: ./cover.out

coverage:
name: coverage
needs: go-test-linux
uses: senzing-factory/build-resources/.github/workflows/go-coverage.yaml@main
17 changes: 15 additions & 2 deletions .github/workflows/go-test-windows.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: go test windows

on: [push]
on: [pull_request, workflow_dispatch]

permissions:
contents: read
Expand All @@ -26,4 +26,17 @@ jobs:
go-version: ${{ matrix.go }}

- name: run go test
run: go test -v -p 1 ./...
run: |
go test -v -p 1 ./... -coverprofile=cover.out -covermode=atomic -coverpkg=./...
cp cover cover.out
- name: Store coverage file
uses: actions/upload-artifact@v4
with:
name: cover.out
path: cover.out

coverage:
name: coverage
needs: go-test-windows
uses: senzing-factory/build-resources/.github/workflows/go-coverage.yaml@main
12 changes: 0 additions & 12 deletions .github/workflows/gofmt.yaml

This file was deleted.

36 changes: 36 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: golangci-lint

on:
push:
branches-ignore: [main]
pull_request:
branches: [main]

permissions:
# Required: allow read access to the content for analysis.
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
pull-requests: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest

steps:
- name: checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: setup go
uses: actions/setup-go@v5
with:
go-version: 1.21

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
args: --config=${{ github.workspace }}/.github/linters/.golangci.yml
only-new-issues: false
version: latest
27 changes: 0 additions & 27 deletions .github/workflows/gosec.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/lint-workflows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ permissions:

jobs:
lint-workflows:
uses: senzing-factory/build-resources/.github/workflows/lint-workflows.yaml@v1
uses: senzing-factory/build-resources/.github/workflows/lint-workflows.yaml@v2
2 changes: 1 addition & 1 deletion .github/workflows/make-go-github-file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
SENZING_GITHUB_ACTOR: ${{ secrets.SENZING_GITHUB_ACTOR }}
SENZING_GITHUB_GPG_PASSPHRASE: ${{ secrets.SENZING_GITHUB_GPG_PASSPHRASE }}
SENZING_GITHUB_GPG_PRIVATE_KEY: ${{ secrets.SENZING_GITHUB_GPG_PRIVATE_KEY }}
uses: senzing-factory/build-resources/.github/workflows/make-go-github-file.yaml@v1
uses: senzing-factory/build-resources/.github/workflows/make-go-github-file.yaml@v2
29 changes: 28 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ GO_ARCH = $(word 2, $(GO_OSARCH))

# Conditional assignment. ('?=')
# Can be overridden with "export"
# Example: "export LD_LIBRARY_PATH=/path/to/my/senzing/g2/lib"
# Example: "export LD_LIBRARY_PATH=/path/to/my/senzing-garage/g2/lib"

LD_LIBRARY_PATH ?= /opt/senzing/g2/lib
GOBIN ?= $(shell go env GOPATH)/bin

# Export environment variables.

Expand Down Expand Up @@ -118,6 +119,32 @@ docker-build:
.PHONY: test
test: test-osarch-specific

# -----------------------------------------------------------------------------
# Coverage
# -----------------------------------------------------------------------------

.PHONY: install-go-test-coverage
install-go-test-coverage:
go install github.com/vladopajic/go-test-coverage/v2@latest


.PHONY: coverage
coverage: coverage-osarch-specific


.PHONY: check-coverage
check-coverage: install-go-test-coverage
go test ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./...
${GOBIN}/go-test-coverage --config=./.testcoverage.yml

# -----------------------------------------------------------------------------
# Lint
# -----------------------------------------------------------------------------

.PHONY: run-golangci-lint
run-golangci-lint:
golangci-lint run --config=.github/linters/.golangci.yml

# -----------------------------------------------------------------------------
# Run
# -----------------------------------------------------------------------------
Expand Down
15 changes: 12 additions & 3 deletions makefiles/darwin.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@ DYLD_LIBRARY_PATH := $(LD_LIBRARY_PATH)

.PHONY: clean-osarch-specific
clean-osarch-specific:
@docker rm --force $(DOCKER_CONTAINER_NAME) 2> /dev/null || true
@docker rm --force $(DOCKER_CONTAINER_NAME) 2> /dev/null || true
@docker rmi --force $(DOCKER_IMAGE_NAME) $(DOCKER_BUILD_IMAGE_NAME) 2> /dev/null || true
@rm -rf $(TARGET_DIRECTORY) || true
@rm -f $(GOPATH)/bin/$(PROGRAM_NAME) || true
@rm -f $(GOPATH)/bin/$(PROGRAM_NAME) || true
@rm -f $(MAKEFILE_DIRECTORY)/coverage.html || true
@rm -f $(MAKEFILE_DIRECTORY)/coverage.out || true
@rm -fr $(TARGET_DIRECTORY) || true


.PHONY: coverage-osarch-specific
coverage-osarch-specific:
@go test -v -coverprofile=coverage.out -p 1 ./...
@go tool cover -html="coverage.out" -o coverage.html
@open file://$(MAKEFILE_DIRECTORY)/coverage.html


.PHONY: hello-world-osarch-specific
Expand Down
16 changes: 13 additions & 3 deletions makefiles/linux.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@

.PHONY: clean-osarch-specific
clean-osarch-specific:
@docker rm --force $(DOCKER_CONTAINER_NAME) 2> /dev/null || true
@docker rm --force $(DOCKER_CONTAINER_NAME) 2> /dev/null || true
@docker rmi --force $(DOCKER_IMAGE_NAME) $(DOCKER_BUILD_IMAGE_NAME) 2> /dev/null || true
@rm -rf $(TARGET_DIRECTORY) || true
@rm -f $(GOPATH)/bin/$(PROGRAM_NAME) || true
@rm -f $(GOPATH)/bin/$(PROGRAM_NAME) || true
@rm -f $(MAKEFILE_DIRECTORY)/coverage.html || true
@rm -f $(MAKEFILE_DIRECTORY)/coverage.out || true
@rm -fr $(TARGET_DIRECTORY) || true


.PHONY: coverage-osarch-specific
coverage-osarch-specific: export SENZING_LOG_LEVEL=TRACE
coverage-osarch-specific:
@go test -v -coverprofile=coverage.out -p 1 ./...
@go tool cover -html="coverage.out" -o coverage.html
@xdg-open $(MAKEFILE_DIRECTORY)/coverage.html


.PHONY: hello-world-osarch-specific
Expand Down
11 changes: 10 additions & 1 deletion makefiles/windows.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@

.PHONY: clean-osarch-specific
clean-osarch-specific:
del /F /S /Q $(TARGET_DIRECTORY)
del /F /S /Q $(GOPATH)/bin/$(PROGRAM_NAME)
del /F /S /Q $(MAKEFILE_DIRECTORY)/coverage.html
del /F /S /Q $(MAKEFILE_DIRECTORY)/coverage.out
del /F /S /Q $(TARGET_DIRECTORY)


.PHONY: coverage-osarch-specific
coverage-osarch-specific:
@go test -v -coverprofile=coverage.out -p 1 ./...
@go tool cover -html="coverage.out" -o coverage.html
@xdg-open file://$(MAKEFILE_DIRECTORY)/coverage.html


.PHONY: hello-world-osarch-specific
Expand Down

0 comments on commit 4269f55

Please sign in to comment.