diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index 9567b68..37f9047 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -7,12 +7,12 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v5 with: - go-version: 1.21 - - uses: actions/checkout@v3 + go-version: 1.22 + - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v4 with: version: v1.54.2 args: --verbose @@ -20,14 +20,14 @@ jobs: test: strategy: matrix: - go-version: [1.21] + go-version: [1.22] platform: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.platform }} steps: - name: Install Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} @@ -35,7 +35,7 @@ jobs: run: go install github.com/mattn/goveralls@latest - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - run: go test -v -coverprofile=coverage.out ./... diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index 07f6ca9..cb5f9f0 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -23,7 +23,7 @@ jobs: - name: Setup uses: actions/setup-go@v3 with: - go-version: ">=1.21" + go-version: ">=1.22" cache: true - name: Generate Changelog Only uses: goreleaser/goreleaser-action@v4 diff --git a/.gitignore b/.gitignore index 6d621e2..da93394 100644 --- a/.gitignore +++ b/.gitignore @@ -18,8 +18,12 @@ coverage coverage.out ginkgo.report - +dist/ .task/ src/i18n/out/en-US/active.en-GB.json +test/data/research/scientist/ +.DS_Store +thumbs.db +*.log diff --git a/.golangci.yml b/.golangci.yml index 267ed5d..4fd87fe 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -63,3 +63,4 @@ linters: run: issues-exit-code: 1 + timeout: 5m diff --git a/.vscode/settings.json b/.vscode/settings.json index 562f4ba..15ece21 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,7 @@ ], "cSpell.words": [ "bodyclose", + "cobrass", "coverprofile", "cubiest", "deadcode", @@ -21,6 +22,7 @@ "gofmt", "goimports", "golangci", + "gomega", "gomnd", "goreleaser", "gosec", @@ -33,17 +35,21 @@ "linters", "mattn", "nakedret", + "nolint", "nolintlint", "nosec", + "onsi", "pixa", "prealloc", "repotoken", "shogo", "sidewalk", + "snivilised", "staticcheck", "structcheck", "stylecheck", "thelper", + "toplevel", "tparallel", "typecheck", "unconvert", diff --git a/src/app/command/bootstrap_test.go b/src/app/command/bootstrap_test.go index 2893f34..e6d6255 100644 --- a/src/app/command/bootstrap_test.go +++ b/src/app/command/bootstrap_test.go @@ -1,8 +1,8 @@ package command_test import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" + . "github.com/onsi/ginkgo/v2" //nolint:revive // ok for testing + . "github.com/onsi/gomega" //nolint:revive // ok for testing "github.com/snivilised/arcadia/src/app/command" "github.com/snivilised/arcadia/src/internal/helpers" "github.com/snivilised/extendio/xfs/utils" @@ -30,7 +30,7 @@ var _ = Describe("Bootstrap", Ordered, func() { ) BeforeAll(func() { - repo = helpers.Repo("../..") + repo = helpers.Repo("") l10nPath = helpers.Path(repo, "test/data/l10n") Expect(utils.FolderExists(l10nPath)).To(BeTrue()) }) diff --git a/src/app/command/command_suite_test.go b/src/app/command/command_suite_test.go index c76f359..a78c824 100644 --- a/src/app/command/command_suite_test.go +++ b/src/app/command/command_suite_test.go @@ -3,11 +3,11 @@ package command_test import ( "testing" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" ) func TestCommand(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "Command Suite") + gomega.RegisterFailHandler(ginkgo.Fail) + ginkgo.RunSpecs(t, "Command Suite") } diff --git a/src/app/command/root-cmd_test.go b/src/app/command/root-cmd_test.go index bf7f2e1..7a8abdc 100644 --- a/src/app/command/root-cmd_test.go +++ b/src/app/command/root-cmd_test.go @@ -1,8 +1,8 @@ package command_test import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" + . "github.com/onsi/ginkgo/v2" //nolint:revive // ok for testing + . "github.com/onsi/gomega" //nolint:revive // ok for testing "github.com/snivilised/arcadia/src/app/command" "github.com/snivilised/arcadia/src/internal/helpers" @@ -16,7 +16,7 @@ var _ = Describe("RootCmd", Ordered, func() { ) BeforeAll(func() { - repo = helpers.Repo("../..") + repo = helpers.Repo("") l10nPath = helpers.Path(repo, "test/data/l10n") Expect(utils.FolderExists(l10nPath)).To(BeTrue()) }) diff --git a/src/app/command/widget-cmd.go b/src/app/command/widget-cmd.go index 9e82fdc..9f30ee8 100644 --- a/src/app/command/widget-cmd.go +++ b/src/app/command/widget-cmd.go @@ -83,11 +83,13 @@ func (b *Bootstrap) buildWidgetCommand(container *assistant.CobraContainer) *cob if value == defaultDirectory { return nil } + if _, err := os.Stat(value); err != nil { if os.IsNotExist(err) { return err } } + return nil }, ) @@ -101,6 +103,7 @@ func (b *Bootstrap) buildWidgetCommand(container *assistant.CobraContainer) *cob if domain.OutputFormatEnumInfo.En(value) == domain.XMLFormatEn { return nil } + return fmt.Errorf( "only xml format is currently supported, other formats available in future release", ) diff --git a/src/app/command/widget_cmd_test.go b/src/app/command/widget_cmd_test.go index 0acc431..2e0af44 100644 --- a/src/app/command/widget_cmd_test.go +++ b/src/app/command/widget_cmd_test.go @@ -3,8 +3,8 @@ package command_test import ( "fmt" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" + . "github.com/onsi/ginkgo/v2" //nolint:revive // ok for testing + . "github.com/onsi/gomega" //nolint:revive // ok for testing "github.com/spf13/cobra" "github.com/snivilised/arcadia/src/app/command" @@ -25,8 +25,8 @@ var _ = Describe("WidgetCmd", Ordered, func() { ) BeforeAll(func() { - repo = helpers.Repo("../../..") - l10nPath = helpers.Path(repo, "src/test/data/l10n") + repo = helpers.Repo("") + l10nPath = helpers.Path(repo, "test/data/l10n") Expect(utils.FolderExists(l10nPath)).To(BeTrue(), fmt.Sprintf("💥 l10Path: '%v' does not exist", l10nPath), ) diff --git a/src/i18n/i18n_suite_test.go b/src/i18n/i18n_suite_test.go index 4cc92d2..17dd065 100644 --- a/src/i18n/i18n_suite_test.go +++ b/src/i18n/i18n_suite_test.go @@ -3,11 +3,11 @@ package i18n_test import ( "testing" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" + "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" ) func TestI18n(t *testing.T) { - RegisterFailHandler(Fail) - RunSpecs(t, "I18n Suite") + gomega.RegisterFailHandler(ginkgo.Fail) + ginkgo.RunSpecs(t, "I18n Suite") } diff --git a/src/internal/helpers/test-utilities.go b/src/internal/helpers/test-utilities.go index 0064ad0..23732d0 100644 --- a/src/internal/helpers/test-utilities.go +++ b/src/internal/helpers/test-utilities.go @@ -3,9 +3,11 @@ package helpers import ( "fmt" "os" + "os/exec" "path/filepath" - "runtime" "strings" + + "github.com/pkg/errors" ) func Path(parent, relative string) string { @@ -43,8 +45,19 @@ func Root() string { } func Repo(relative string) string { - _, filename, _, _ := runtime.Caller(0) //nolint:dogsled // use of 3 _ is out of our control - return Path(filepath.Dir(filename), relative) + cmd := exec.Command("git", "rev-parse", "--show-toplevel") + bytes, err := cmd.Output() + + if err != nil { + panic(errors.Wrap(err, "couldn't get repo root")) + } + + segments := strings.Split(relative, "/") + output := strings.TrimSuffix(string(bytes), "\n") + path := []string{output} + path = append(path, segments...) + + return filepath.Join(path...) } func Log() string { diff --git a/src/internal/log/new-logger.go b/src/internal/log/new-logger.go index ce604d9..8ec332e 100644 --- a/src/internal/log/new-logger.go +++ b/src/internal/log/new-logger.go @@ -16,6 +16,7 @@ func NewLogger(info *LoggerInfo) Ref { if info.Path == "" { panic(i18n.NewInvalidConfigEntryError(info.Path, "-")) } + ws := zapcore.AddSync(&lumberjack.Logger{ Filename: info.Path, MaxSize: info.Rotation.MaxSizeInMb, @@ -29,6 +30,7 @@ func NewLogger(info *LoggerInfo) Ref { ws, info.Level, ) + return zap.New(core) }, func() Logger { return zap.NewNop() diff --git a/src/test/data/l10n/test.arcadia.active.en-US.json b/test/data/l10n/test.arcadia.active.en-US.json similarity index 100% rename from src/test/data/l10n/test.arcadia.active.en-US.json rename to test/data/l10n/test.arcadia.active.en-US.json diff --git a/src/test/data/l10n/test.graffico.active.en-US.json b/test/data/l10n/test.graffico.active.en-US.json similarity index 100% rename from src/test/data/l10n/test.graffico.active.en-US.json rename to test/data/l10n/test.graffico.active.en-US.json diff --git a/src/test/helpers/cobra.go b/test/helpers/cobra.go similarity index 100% rename from src/test/helpers/cobra.go rename to test/helpers/cobra.go