Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/linters/bearer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rule:
skip-rule: []
2 changes: 2 additions & 0 deletions .github/workflows/bearer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ jobs:

- name: Bearer
uses: bearer/bearer-action@v2
with:
config-file: .github/linters/bearer.yml
13 changes: 9 additions & 4 deletions .github/workflows/go-test-linux.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Go test linux

on: [push, workflow_dispatch]
on:
push:
pull_request:
branches: [main]
schedule:
- cron: "15 7 * * *"

env:
SENZING_LOG_LEVEL: TRACE
Expand Down Expand Up @@ -85,10 +90,10 @@ jobs:
coverage-config: ./.github/coverage/testcoverage.yaml

slack-notification:
needs: [go-test-linux, coverage]
if: ${{ always() && contains(fromJSON('["failure", "cancelled"]'), needs.go-test-linux.outputs.status ) && contains(fromJSON('["failure", "cancelled"]'), needs.coverage.outputs.job-status ) && github.ref_name == github.event.repository.default_branch }}
needs: [go-test-linux]
if: ${{ always() && contains(fromJSON('["failure", "cancelled"]'), needs.go-test-linux.outputs.status ) && (github.ref_name == github.event.repository.default_branch || github.event_name == 'schedule') }}
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
uses: senzing-factory/build-resources/.github/workflows/build-failure-slack-notification.yaml@v2
with:
job-status: ${{ needs.go-test-linux.outputs.status && needs.coverage.outputs.job-status }}
job-status: ${{ needs.go-test-linux.outputs.status }}
2 changes: 0 additions & 2 deletions .github/workflows/go-test-windows.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup go ${{ matrix.go }}
uses: actions/setup-go@v5
Expand Down
1 change: 1 addition & 0 deletions .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"**/*.go",
"**/*.mod",
"**/*.sum",
"bearer.ignore",
"Makefile"
]
}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# -----------------------------------------------------------------------------

ARG IMAGE_BUILDER=golang:1.24.1-bookworm
ARG IMAGE_FINAL=senzing/senzingsdk-runtime-beta:latest
ARG IMAGE_FINAL=senzing/senzingsdk-runtime:latest

# -----------------------------------------------------------------------------
# Stage: senzingsdk_runtime
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ dependencies-for-development: dependencies-for-development-osarch-specific
@go install github.com/vladopajic/go-test-coverage/v2@latest
@go install golang.org/x/tools/cmd/godoc@latest
@go install golang.org/x/vuln/cmd/govulncheck@latest
@go install mvdan.cc/gofumpt@latest
@sudo npm install -g cspell@latest


Expand Down Expand Up @@ -237,7 +238,7 @@ update-pkg-cache:

.PHONY: bearer
bearer:
@bearer scan .
@bearer scan --config-file .github/linters/bearer.yml .


.PHONY: cspell
Expand Down
2 changes: 1 addition & 1 deletion checkself/break.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (checkself *BasicCheckSelf) Break(
_ = ctx

if len(reportErrors) > 0 {
return reportChecks, reportInfo, reportErrors, wraperror.Errorf(errForPackage, "")
return reportChecks, reportInfo, reportErrors, wraperror.Errorf(errForPackage, wraperror.NoMessage)
}

return reportChecks, reportInfo, reportErrors, nil
Expand Down
34 changes: 16 additions & 18 deletions checkself/checklicense.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ func (checkself *BasicCheckSelf) checkExpiry(expireInDays int) ([]string, error)
if err != nil {
return result, wraperror.Errorf(
err,
"Could not parse SENZING_TOOLS_LICENSE_DAYS_LEFT information: %s. error: %w",
"Could not parse SENZING_TOOLS_LICENSE_DAYS_LEFT information: %s",
checkself.ErrorLicenseDaysLeft,
err,
)
}

Expand All @@ -112,7 +111,7 @@ func (checkself *BasicCheckSelf) checkExpiry(expireInDays int) ([]string, error)
)
}

return result, wraperror.Errorf(err, "checkself.checkExpiry error: %w", err)
return result, wraperror.Errorf(err, wraperror.NoMessage)
}

func (checkself *BasicCheckSelf) getLicense(ctx context.Context) (string, error) {
Expand All @@ -123,15 +122,15 @@ func (checkself *BasicCheckSelf) getLicense(ctx context.Context) (string, error)

szProduct, err := checkself.getSzProduct(ctx)
if err != nil {
return result, wraperror.Errorf(err, "Could not create szProduct. error: %w", err)
return result, wraperror.Errorf(err, "Could not create szProduct")
}

result, err = szProduct.GetLicense(ctx)
if err != nil {
return result, wraperror.Errorf(err, "Could not get license information. error: %w", err)
return result, wraperror.Errorf(err, "Could not get license information")
}

return result, wraperror.Errorf(err, "checkself.getLicense error: %w", err)
return result, wraperror.Errorf(err, wraperror.NoMessage)
}

func (checkself *BasicCheckSelf) checkRecordPercent(
Expand All @@ -148,9 +147,8 @@ func (checkself *BasicCheckSelf) checkRecordPercent(
if err != nil {
return result, wraperror.Errorf(
err,
"Could not parse SENZING_TOOLS_LICENSE_RECORDS_PERCENT information: %s. error: %w",
"Could not parse SENZING_TOOLS_LICENSE_RECORDS_PERCENT information: %s.",
checkself.ErrorLicenseRecordsPercent,
err,
)
}

Expand All @@ -164,7 +162,7 @@ func (checkself *BasicCheckSelf) checkRecordPercent(
)
}

return result, wraperror.Errorf(err, "checkself.checkRecordPercent error: %w", err)
return result, wraperror.Errorf(err, wraperror.NoMessage)
}

func (checkself *BasicCheckSelf) getRecordCount(
Expand All @@ -177,7 +175,7 @@ func (checkself *BasicCheckSelf) getRecordCount(

databaseConnector, err := checkself.getDatabaseConnector(ctx)
if err != nil {
return result, wraperror.Errorf(err, "Could not connect to database. Error %w", err)
return result, wraperror.Errorf(err, "Could not connect to database.")
}

checker := &checker.BasicChecker{
Expand All @@ -186,10 +184,10 @@ func (checkself *BasicCheckSelf) getRecordCount(

result, err = checker.RecordCount(ctx)
if err != nil {
return result, wraperror.Errorf(err, "Could not get count of records. Error %w", err)
return result, wraperror.Errorf(err, "Could not get count of records.")
}

return result, wraperror.Errorf(err, "checkself.getRecordCount error: %w", err)
return result, wraperror.Errorf(err, wraperror.NoMessage)
}

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -221,35 +219,35 @@ func getExpireInDays(productLicenseResponse *ProductLicenseResponse) (int, error

licenseExpireDate, err := time.Parse(time.DateOnly, productLicenseResponse.ExpireDate)
if err != nil {
return result, wraperror.Errorf(err, "Could not parse expireDate information. error %w", err)
return result, wraperror.Errorf(err, "Could not parse expireDate information.")
}

duration := time.Until(licenseExpireDate)
result = int(duration.Hours() / hoursPerDay)

return result, wraperror.Errorf(err, "checkself.getExpireInDays error: %w", err)
return result, wraperror.Errorf(err, wraperror.NoMessage)
}

func getPrettyJSON(license string) (bytes.Buffer, error) {
var result bytes.Buffer

err := json.Indent(&result, []byte(license), "", "\t")
if err != nil {
return result, wraperror.Errorf(err, "Could not parse license information. Error %w", err)
return result, wraperror.Errorf(err, "Could not parse license information.")
}

return result, wraperror.Errorf(err, "checkself.getPrettyJSON error: %w", err)
return result, wraperror.Errorf(err, wraperror.NoMessage)
}

func getProductLicenseResponse(license string) (*ProductLicenseResponse, error) {
result := &ProductLicenseResponse{}

err := json.Unmarshal([]byte(license), result)
if err != nil {
return result, wraperror.Errorf(err, "Could not parse license information into structure. Error %w", err)
return result, wraperror.Errorf(err, "Could not parse license information into structure.")
}

return result, wraperror.Errorf(err, "checkself.getProductLicenseResponse error: %w", err)
return result, wraperror.Errorf(err, wraperror.NoMessage)
}

func returnValues(
Expand Down
14 changes: 6 additions & 8 deletions checkself/checkself.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ func (checkself *BasicCheckSelf) CheckSelf(ctx context.Context) error {

outputf("%s\n\n\n\n\n", strings.Repeat("-", horizontalRuleLength))

return err
return wraperror.Errorf(err, wraperror.NoMessage)
}

// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -188,22 +188,20 @@ func (checkself *BasicCheckSelf) getDatabaseConnector(ctx context.Context) (driv
if err != nil {
return result, wraperror.Errorf(
err,
"Unable to locate Database URL For more information, visit https://hub.senzing.com/... Error: %w",
err,
"Unable to locate Database URL For more information, visit https://hub.senzing.com/...",
)
}

result, err = connector.NewConnector(ctx, databaseURL)
if err != nil {
return result, wraperror.Errorf(
err,
"Database URL '%s' is misconfigured. Could not create a database connector. For more information, visit https://hub.senzing.com/... Error: %w",
"Database URL '%s' is misconfigured. Could not create a database connector. For more information, visit https://hub.senzing.com/...",
databaseURL,
err,
)
}

return result, wraperror.Errorf(err, "checkself.getDatabaseURL error: %w", err)
return result, wraperror.Errorf(err, wraperror.NoMessage)
}

func (checkself *BasicCheckSelf) getInstanceName(ctx context.Context) string {
Expand Down Expand Up @@ -241,7 +239,7 @@ func (checkself *BasicCheckSelf) getSzConfigManager(ctx context.Context) (senzin
checkself.szConfigManagerSingleton, err = checkself.getSzFactory(ctx).CreateConfigManager(ctx)
})

return checkself.szConfigManagerSingleton, wraperror.Errorf(err, "checkself.getSzConfigManager error: %w", err)
return checkself.szConfigManagerSingleton, wraperror.Errorf(err, wraperror.NoMessage)
}

func (checkself *BasicCheckSelf) getSzFactory(ctx context.Context) senzing.SzAbstractFactory {
Expand Down Expand Up @@ -271,7 +269,7 @@ func (checkself *BasicCheckSelf) getSzProduct(ctx context.Context) (senzing.SzPr
checkself.szProductSingleton, err = checkself.getSzFactory(ctx).CreateProduct(ctx)
})

return checkself.szProductSingleton, wraperror.Errorf(err, "checkself.getSzProduct error: %w", err)
return checkself.szProductSingleton, wraperror.Errorf(err, wraperror.NoMessage)
}

func (checkself *BasicCheckSelf) getTestFunctions() []func(ctx context.Context, reportChecks []string, reportInfo []string, reportErrors []string) ([]string, []string, []string, error) {
Expand Down
4 changes: 2 additions & 2 deletions checkself/checkself_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestBasicCheckSelf_CheckSelf_Paths(test *testing.T) {
func TestBasicCheckSelf_CheckDatabaseSchema_noSchemaInstalled(test *testing.T) {
test.Parallel()
ctx := test.Context()
expected := "Senzing database schema has not been installed in sqlite3://na:na@/tmp/sqlite/G2C-empty.db. For more information, visit https://hub.senzing.com/... Error: checker.IsSchemaInstalled.row.Scan error: no such table: DSRC_RECORD"
expected := `Senzing database schema has not been installed in sqlite3://na:na@/tmp/sqlite/G2C-empty.db. For more information, visit https://hub.senzing.com/... Error: {"function": "checker.(*BasicChecker).IsSchemaInstalled", "text": "row.Scan", "error": "no such table: DSRC_RECORD"}`
testObject := getTestObject(ctx, test)
badReportErrors := []string{}
testObject.DatabaseURL = "sqlite3://na:na@/tmp/sqlite/G2C-empty.db"
Expand All @@ -52,7 +52,7 @@ func TestBasicCheckSelf_CheckDatabaseSchema_noSchemaInstalled(test *testing.T) {
func TestBasicCheckSelf_CheckLicense_badGetLicense(test *testing.T) {
test.Parallel()
ctx := test.Context()
expected := "Could not get count of records. Error checker.RecordCount.row.Scan error: no such table: DSRC_RECORD"
expected := `{"function": "checkself.(*BasicCheckSelf).getRecordCount", "text": "Could not get count of records.", "error": {"function": "checker.(*BasicChecker).RecordCount", "text": "row.Scan", "error": "no such table: DSRC_RECORD"}}`
testObject := getTestObject(ctx, test)
testObject.Settings = `
{
Expand Down
4 changes: 2 additions & 2 deletions checkself/checkself_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func TestBasicCheckSelf_CheckDatabaseSchema(test *testing.T) {
func TestBasicCheckSelf_CheckDatabaseSchema_badDatabaseURL(test *testing.T) {
test.Parallel()
ctx := test.Context()
expected := "SENZING_TOOLS_DATABASE_URL = bad-database-URL is misconfigured. Could not create a database connector. For more information, visit https://hub.senzing.com/... Error: connector.NewConnector error: unknown database scheme: error: connector"
expected := `SENZING_TOOLS_DATABASE_URL = bad-database-URL is misconfigured. Could not create a database connector. For more information, visit https://hub.senzing.com/... Error: {"function": "connector.NewConnector", "error": {"function": "connector.NewConnector", "text": "unknown database scheme: ", "error": "connector"}}`
testObject := getTestObject(ctx, test)
badReportErrors := []string{}
testObject.DatabaseURL = "bad-database-URL"
Expand Down Expand Up @@ -210,7 +210,7 @@ func TestBasicCheckSelf_CheckSettings(test *testing.T) {
func TestBasicCheckSelf_CheckSettings_badSettings(test *testing.T) {
test.Parallel()
ctx := test.Context()
expected := "SENZING_TOOLS_ENGINE_SETTINGS - incorrect JSON syntax in }{"
expected := `SENZING_TOOLS_ENGINE_SETTINGS - {"function": "settingsparser.New", "text": "incorrect JSON syntax in }{", "error": "settingsparser"}`
testObject := getTestObject(ctx, test)
testObject.Settings = badJSON
newReportChecks, newReportInfo, newReportErrors, err := testObject.CheckSettings(
Expand Down
4 changes: 3 additions & 1 deletion cmd/cmd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ func Test_CompletionCmd(test *testing.T) {
require.NoError(test, err)
}

func Test_docsCmd(test *testing.T) {
func Test_DocsCmd(test *testing.T) {
test.Parallel()

err := cmd.DocsCmd.Execute()
require.NoError(test, err)
err = cmd.DocsCmd.RunE(cmd.DocsCmd, []string{})
Expand Down
6 changes: 3 additions & 3 deletions cmd/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
package cmd

import (
"fmt"
"io"
"os"

"github.com/senzing-garage/go-helpers/wraperror"
"github.com/spf13/cobra"
)

Expand All @@ -17,7 +17,7 @@ var CompletionCmd = &cobra.Command{
Long: `To load completions, run:
source < (check-self completion)

To load completions automaticallon on login, add this line to your .bashrc file:
To load completions automatically on login, add this line to your .bashrc file:
source < (check-self completion)
`,
RunE: func(cmd *cobra.Command, args []string) error {
Expand All @@ -34,7 +34,7 @@ func init() {

func completionAction(out io.Writer) error {
if err := RootCmd.GenBashCompletion(out); err != nil {
return fmt.Errorf("completionAction: %w", err)
return wraperror.Errorf(err, wraperror.NoMessage)
}

return nil
Expand Down
9 changes: 5 additions & 4 deletions cmd/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"io"
"os"

"github.com/senzing-garage/go-helpers/wraperror"
"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
)
Expand All @@ -19,11 +20,11 @@ var DocsCmd = &cobra.Command{
_ = args
dir, err := cmd.Flags().GetString("dir")
if err != nil {
return fmt.Errorf("getting 'dir' value: %w", err)
return wraperror.Errorf(err, "getting 'dir' value")
}
if dir == "" {
if dir, err = os.MkdirTemp("", "check-self"); err != nil {
return fmt.Errorf("constructing cobra.Command: %w", err)
return wraperror.Errorf(err, "constructing cobra.Command")
}
}

Expand All @@ -38,11 +39,11 @@ func init() {

func DocsAction(out io.Writer, dir string) error {
if err := doc.GenMarkdownTree(RootCmd, dir); err != nil {
return fmt.Errorf("DocsAction: %w", err)
return wraperror.Errorf(err, "DocsAction")
}

if _, err := fmt.Fprintf(out, "Documentation successfully created in %s\n", dir); err != nil {
return fmt.Errorf("printing succsss: %w", err)
return wraperror.Errorf(err, "printing succsss")
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func RunE(_ *cobra.Command, _ []string) error {

err := checkSelf.CheckSelf(ctx)

return wraperror.Errorf(err, "RunE error: %w", err)
return wraperror.Errorf(err, wraperror.NoMessage)
}

// Used in construction of cobra.Command.
Expand Down
Loading
Loading