Skip to content

Commit

Permalink
65 dockter 1 (#68)
Browse files Browse the repository at this point in the history
* #65 Update dependencies

* #65 Working lint and tests

* #65 From engineconfiguration to settings

* #65 Prepare for versioned release

* #65 Install senzing in workflows

* #65 Break out Linux testing

* #65 Break out Linux testing

* #65 Break out Darwin/Windows testing

* #65 Break out Darwin/Windows testing

* #65 Change ErrorID to MessageID
  • Loading branch information
docktermj authored Jun 12, 2024
1 parent 2783fc1 commit 3597594
Show file tree
Hide file tree
Showing 35 changed files with 520 additions and 180 deletions.
2 changes: 2 additions & 0 deletions .github/linters/.checkov.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
quiet: true
skip-check: CKV_DOCKER_7
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
4 changes: 3 additions & 1 deletion .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"threshold": 3
"ignore": [
"**/*.go,**/go-test*.yaml"
]
}
25 changes: 21 additions & 4 deletions .github/workflows/go-test-darwin.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
name: go test darwin

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

permissions:
contents: read

jobs:
go-test-darwin:
name: "go test with OS: ${{ matrix.os }}; Go: ${{ matrix.go }}"
name: "go test with Senzing: ${{ matrix.senzingapi-version }}; OS: ${{ matrix.os }}; Go: ${{ matrix.go }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
go: ["1.21"]
os: [macos-latest]
os: [macos-13]
senzingapi-version: [staging-v4]

steps:
- name: checkout repository
Expand All @@ -25,5 +26,21 @@ jobs:
with:
go-version: ${{ matrix.go }}

- name: install Senzing API
uses: senzing-factory/github-action-install-senzing-api@v3
with:
senzingapi-version: ${{ matrix.senzingapi-version }}

- 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
21 changes: 19 additions & 2 deletions .github/workflows/go-test-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ permissions:

jobs:
go-test-linux:
name: "go test with OS: ${{ matrix.os }}; Go: ${{ matrix.go }}"
name: "go test with Senzing: ${{ matrix.senzingapi-version }}; OS: ${{ matrix.os }}; Go: ${{ matrix.go }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
go: ["1.21"]
os: [ubuntu-latest]
senzingapi-version: [staging-v4]

steps:
- name: checkout repository
Expand All @@ -25,5 +26,21 @@ jobs:
with:
go-version: ${{ matrix.go }}

- name: install Senzing API
uses: senzing-factory/github-action-install-senzing-api@v3
with:
senzingapi-runtime-version: ${{ matrix.senzingapi-version }}

- 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@v2
25 changes: 22 additions & 3 deletions .github/workflows/go-test-windows.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
name: go test windows

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

permissions:
contents: read

jobs:
go-test-windows:
name: "go test with OS: ${{ matrix.os }}; Go: ${{ matrix.go }}"
name: "go test with Senzing: ${{ matrix.senzingapi-version }}; OS: ${{ matrix.os }}; Go: ${{ matrix.go }}"
runs-on: ${{ matrix.os }}
strategy:
matrix:
go: ["1.21"]
os: [windows-latest]
senzingapi-version: [staging-v4]

steps:
- name: checkout repository
Expand All @@ -25,5 +26,23 @@ jobs:
with:
go-version: ${{ matrix.go }}

- name: install Senzing API
uses: senzing-factory/github-action-install-senzing-api@v3
with:
senzingapi-version: ${{ matrix.senzingapi-version }}

- name: run go test
run: go test -v -p 1 ./...
run: |
go test -v -p 1 -coverprofile=cover -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@v2
12 changes: 0 additions & 12 deletions .github/workflows/gofmt.yaml

This file was deleted.

27 changes: 0 additions & 27 deletions .github/workflows/gosec.yaml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ go.work

# Makefile
target/
coverage.html
49 changes: 49 additions & 0 deletions .testcoverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# (mandatory)
# Path to coverprofile file (output of `go test -coverprofile` command).
#
# For cases where there are many coverage profiles, such as when running
# unit tests and integration tests separately, you can combine all those
# profiles into one. In this case, the profile should have a comma-separated list
# of profile files, e.g., 'cover_unit.out,cover_integration.out'.
profile: cover.out

# (optional; but recommended to set)
# When specified reported file paths will not contain local prefix in the output
local-prefix: "github.com/org/project"

# Holds coverage thresholds percentages, values should be in range [0-100]
threshold:
# (optional; default 0)
# The minimum coverage that each file should have
file: 80

# (optional; default 0)
# The minimum coverage that each package should have
package: 80

# (optional; default 0)
# The minimum total coverage project should have
total: 80
# Holds regexp rules which will override thresholds for matched files or packages
# using their paths.
#
# First rule from this list that matches file or package is going to apply
# new threshold to it. If project has multiple rules that match same path,
# override rules should be listed in order from specific to more general rules.
#override:
# Increase coverage threshold to 100% for `foo` package
# (default is 80, as configured above in this example)
#- threshold: 100
# path: ^pkg/lib/foo$

# Holds regexp rules which will exclude matched files or packages
# from coverage statistics
#exclude:
# Exclude files or packages matching their paths
#paths:
# - \.pb\.go$ # excludes all protobuf generated files
# - ^pkg/bar # exclude package `pkg/bar`

# NOTES:
# - symbol `/` in all path regexps will be replaced by current OS file path separator
# to properly work on Windows
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

-

## [0.2.2] - 2024-06-11

### Changed in 0.2.2

- From `engineconfigurationjson` to `options`

## [0.2.1] - 2024-04-19

### Changed in 0.2.1
Expand Down
31 changes: 30 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,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 @@ -62,6 +63,12 @@ hello-world: hello-world-osarch-specific
# Dependency management
# -----------------------------------------------------------------------------

.PHONY: make-dependencies
make-dependencies:
@go install github.com/vladopajic/go-test-coverage/v2@latest
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.58.1


.PHONY: dependencies
dependencies:
@go get -u ./...
Expand Down Expand Up @@ -89,6 +96,28 @@ build: build-osarch-specific
.PHONY: test
test: test-osarch-specific

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

.PHONY: coverage
coverage: coverage-osarch-specific


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

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

.PHONY: run-golangci-lint
run-golangci-lint:
${GOBIN}/golangci-lint run --config=.github/linters/.golangci.yml

# -----------------------------------------------------------------------------
# Run
# -----------------------------------------------------------------------------
Expand Down
8 changes: 7 additions & 1 deletion cmdhelper/cmdhelper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
var contextVariables = []option.ContextVariable{
option.Configuration,
option.EngineLogLevel,
option.EnableSwaggerUi,
option.EnableSwaggerUI,
option.XtermArguments,
}

Expand All @@ -22,6 +22,7 @@ var contextVariables = []option.ContextVariable{
// ----------------------------------------------------------------------------

func TestInit(test *testing.T) {
_ = test
cobraCommand := &cobra.Command{
Use: "test-use",
Short: "test-short",
Expand All @@ -43,6 +44,7 @@ func TestOsLookupEnvString(test *testing.T) {
}

func TestPreRun(test *testing.T) {
_ = test
cobraCommand := &cobra.Command{
Use: "test-use",
Short: "test-short",
Expand All @@ -56,6 +58,10 @@ func TestVersion(test *testing.T) {
assert.Equal(test, "1.2.3-4", Version("1.2.3", "4"))
}

func TestVersion_noIteration(test *testing.T) {
assert.Equal(test, "1.2.3", Version("1.2.3", "0"))
}

// ----------------------------------------------------------------------------
// Examples for godoc documentation
// ----------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 3597594

Please sign in to comment.