Skip to content

Commit

Permalink
#186 Working tests
Browse files Browse the repository at this point in the history
  • Loading branch information
docktermj committed Jun 28, 2024
1 parent 4f81c84 commit 003c051
Show file tree
Hide file tree
Showing 25 changed files with 372 additions and 136 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
6 changes: 6 additions & 0 deletions .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ignore": [
"**/*.go,**/go-test*.yaml"
],
"threshold": 20
}
2 changes: 1 addition & 1 deletion .github/workflows/add-labels-standardized.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
secrets:
ORG_MEMBERSHIP_TOKEN: ${{ secrets.ORG_MEMBERSHIP_TOKEN }}
SENZING_MEMBERS: ${{ secrets.SENZING_MEMBERS }}
uses: senzing-factory/build-resources/.github/workflows/add-labels-to-issue.yaml@v1
uses: senzing-factory/build-resources/.github/workflows/add-labels-to-issue.yaml@v2
2 changes: 1 addition & 1 deletion .github/workflows/add-to-project-garage-dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ jobs:
add-to-project-dependabot:
secrets:
SENZING_GITHUB_PROJECT_RW_TOKEN: ${{ secrets.SENZING_GITHUB_PROJECT_RW_TOKEN }}
uses: senzing-factory/build-resources/.github/workflows/add-to-project-dependabot.yaml@v1
uses: senzing-factory/build-resources/.github/workflows/add-to-project-dependabot.yaml@v2
with:
project: ${{ vars.SENZING_PROJECT_GARAGE }}
2 changes: 1 addition & 1 deletion .github/workflows/add-to-project-garage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
add-to-project:
secrets:
SENZING_GITHUB_PROJECT_RW_TOKEN: ${{ secrets.SENZING_GITHUB_PROJECT_RW_TOKEN }}
uses: senzing-factory/build-resources/.github/workflows/add-to-project.yaml@v1
uses: senzing-factory/build-resources/.github/workflows/add-to-project.yaml@v2
with:
classic: false
project-number: ${{ vars.SENZING_PROJECT_GARAGE }}
Expand Down
9 changes: 5 additions & 4 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
uses: senzing-factory/build-resources/.github/workflows/dependabot-approve-and-merge.yaml@v2
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/go-rest-api-service
import_path: github.com/${{ github.repository }}
30 changes: 27 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,6 +31,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 @@ -43,4 +48,23 @@ jobs:
run: mkdir /tmp/sqlite && cp testdata/sqlite/G2C.db /tmp/sqlite/G2C.db

- name: run go test
run: go test -exec /Users/runner/work/go-rest-api-service/go-rest-api-service/bin/macos_exec_dyld.sh -v -p 1 ./...
run: go test -exec /Users/runner/work/go-rest-api-service/go-rest-api-service/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
26 changes: 25 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: install Senzing API
uses: senzing-factory/github-action-install-senzing-api@v3
with:
Expand All @@ -42,4 +47,23 @@ jobs:
run: mkdir /tmp/sqlite && cp testdata/sqlite/G2C.db /tmp/sqlite/G2C.db

- 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
30 changes: 28 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]

env:
SENZING_TOOLS_DATABASE_URL: 'sqlite3://na:na@nowhere/C:\Temp\sqlite\G2C.db'
Expand Down Expand Up @@ -29,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 +49,25 @@ jobs:
run: mkdir "C:\Temp\sqlite" && copy testdata/sqlite/G2C.db "C:\Temp\sqlite\G2C.db"

- 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
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/move-pr-to-done-dependabot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
move-pr-to-done-dependabot:
secrets:
SENZING_GITHUB_PROJECT_RW_TOKEN: ${{ secrets.SENZING_GITHUB_PROJECT_RW_TOKEN }}
uses: senzing-factory/build-resources/.github/workflows/move-pr-to-done-dependabot.yaml@v1
uses: senzing-factory/build-resources/.github/workflows/move-pr-to-done-dependabot.yaml@v2
with:
project: ${{ vars.SENZING_PROJECT_GARAGE }}
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: 70

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

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

0 comments on commit 003c051

Please sign in to comment.