Skip to content

Commit

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

* #245 Working tests

* #245 Savepoint

* #245 Working test and lint

* #245 Working minimal coverage

* #245 Prepare for versioned release

* #245 Prepare for versioned release

* #245 Prepare for versioned release
  • Loading branch information
docktermj authored Jul 8, 2024
1 parent e287f54 commit 435d11d
Show file tree
Hide file tree
Showing 38 changed files with 1,362 additions and 1,035 deletions.
68 changes: 68 additions & 0 deletions .github/coverage/testcoverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# (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: 30

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

# (optional; default 0)
# The minimum total coverage project should have
total: 30
# 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`

exclude:
paths:
- senzingchatapi/oas_cfg_gen.go
- senzingchatapi/oas_client_gen.go
- senzingchatapi/oas_handlers_gen.go
- senzingchatapi/oas_interfaces_gen.go
- senzingchatapi/oas_json_gen.go
- senzingchatapi/oas_labeler_gen.go
- senzingchatapi/oas_middleware_gen.go
- senzingchatapi/oas_parameters_gen.go
- senzingchatapi/oas_request_decoders_gen.go
- senzingchatapi/oas_request_encoders_gen.go
- senzingchatapi/oas_response_decoders_gen.go
- senzingchatapi/oas_response_encoders_gen.go
- senzingchatapi/oas_router_gen.go
- senzingchatapi/oas_schemas_gen.go
- senzingchatapi/oas_server_gen.go
- senzingchatapi/oas_unimplemented_gen.go
- senzingchatapi/oas_validators_gen.go
# NOTES:
# - symbol `/` in all path regexps will be replaced by current OS file path separator
# to properly work on Windows
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: 4 additions & 1 deletion .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"threshold": 9
"ignore": [
"**/*.go,**/go-test*.yaml"
],
"threshold": 20
}
4 changes: 2 additions & 2 deletions .github/workflows/go-proxy-pull.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:

steps:
- name: pull new module version
uses: andrewslotin/go-proxy-pull-action@v1.1.0
uses: andrewslotin/go-proxy-pull-action@v1.2.0
with:
import_path: github.com/senzing-garage/init-database
import_path: github.com/${{ github.repository }}
32 changes: 29 additions & 3 deletions .github/workflows/go-test-darwin.yaml.disabled
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 @@ -17,7 +17,7 @@ jobs:
strategy:
matrix:
go: ["1.21"]
os: [macos-latest]
os: [macos-13]
senzingapi-version: [staging-v4]

steps:
Expand All @@ -31,10 +31,36 @@ jobs:
with:
go-version: ${{ matrix.go }}

- name: Set up gotestfmt
uses: gotesttools/gotestfmt-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}

- 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 -exec /Users/runner/work/init-database/init-database/bin/macos_exec_dyld.sh -v -p 1 ./...
run: go test -exec /Users/runner/work/init-database/init-database/bin/macos_exec_dyld.sh -json -v -p 1 -coverprofile=./cover.out -covermode=atomic -coverpkg=./... ./... 2>&1 | tee /tmp/gotest.log | gotestfmt

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

- name: Upload test log
uses: actions/upload-artifact@v4
if: always()
with:
name: test-log
path: /tmp/gotest.log
if-no-files-found: error

coverage:
name: coverage
needs: go-test-darwin
uses: senzing-factory/build-resources/.github/workflows/go-coverage.yaml@v2
with:
coverage-config: ./.github/coverage/testcoverage.yaml
28 changes: 27 additions & 1 deletion .github/workflows/go-test-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ jobs:
with:
go-version: ${{ matrix.go }}

- name: Set up gotestfmt
uses: gotesttools/gotestfmt-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: copy /opt/senzing/g2/resources/ files
run: sudo cp --verbose --recursive rootfs/* /

Expand All @@ -39,4 +44,25 @@ jobs:
senzingapi-runtime-version: ${{ matrix.senzingapi-version }}

- name: run go test
run: go test -v -p 1 ./...
run: go test -json -v -p 1 -coverprofile=./cover.out -covermode=atomic -coverpkg=./... ./... 2>&1 | tee /tmp/gotest.log | gotestfmt

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

- name: Upload test log
uses: actions/upload-artifact@v4
if: always()
with:
name: test-log
path: /tmp/gotest.log
if-no-files-found: error

coverage:
name: coverage
needs: go-test-linux
uses: senzing-factory/build-resources/.github/workflows/go-coverage.yaml@v2
with:
coverage-config: ./.github/coverage/testcoverage.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: go test windows

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

env:
SENZING_TOOLS_DATABASE_URL: 'sqlite3://na:na@nowhere/C:\Temp\sqlite\G2C.db'
SENZING_TOOLS_LOG_LEVEL: TRACE
SENZING_TOOLS_DATABASE_URL: "sqlite3://na:na@nowhere/C:\\Temp\\sqlite\\G2C.db"

permissions:
contents: read
Expand All @@ -30,6 +29,11 @@ jobs:
with:
go-version: ${{ matrix.go }}

- name: Set up gotestfmt
uses: gotesttools/gotestfmt-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: install Senzing API
uses: senzing-factory/github-action-install-senzing-api@v3
with:
Expand All @@ -44,4 +48,27 @@ jobs:
New-Item -Path "C:\Temp\sqlite\G2C.db" -ItemType File

- name: run go test
run: go test -v -p 1 ./...
run: |
go test -json -v -p 1 -coverprofile=cover -covermode=atomic -coverpkg=./... ./... 2>&1 | tee "C:\Temp\gotest.log" | gotestfmt
cp cover cover.out

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

- name: Upload test log
uses: actions/upload-artifact@v4
if: always()
with:
name: test-log
path: "C:\\Temp\\gotest.log"
if-no-files-found: error

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

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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: Install Senzing API
uses: senzing-factory/github-action-install-senzing-api@v3
with:
senzingapi-runtime-version: staging-v4

- name: Copy Senzing headers
run: |
mkdir --parents ./szconfig/gohelpers
cp /opt/senzing/g2/sdk/c/*.h ./szconfig/
cp /opt/senzing/g2/sdk/c/gohelpers/*.h ./szconfig/gohelpers
mkdir --parents ./szconfigmanager/gohelpers
cp /opt/senzing/g2/sdk/c/*.h ./szconfigmanager/
cp /opt/senzing/g2/sdk/c/gohelpers/*.h ./szconfigmanager/gohelpers
mkdir --parents ./szdiagnostic/gohelpers
cp /opt/senzing/g2/sdk/c/*.h ./szdiagnostic/
cp /opt/senzing/g2/sdk/c/gohelpers/*.h ./szdiagnostic/gohelpers
mkdir --parents ./szengine/gohelpers
cp /opt/senzing/g2/sdk/c/*.h ./szengine/
cp /opt/senzing/g2/sdk/c/gohelpers/*.h ./szengine/gohelpers
mkdir --parents ./szproduct/gohelpers
cp /opt/senzing/g2/sdk/c/*.h ./szproduct/
cp /opt/senzing/g2/sdk/c/gohelpers/*.h ./szproduct/gohelpers
- 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.

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
Loading

0 comments on commit 435d11d

Please sign in to comment.