From f313b3c04a269c591233719d08cf617b55e857c8 Mon Sep 17 00:00:00 2001 From: kat <28567881+hk21702@users.noreply.github.com> Date: Tue, 14 Jan 2025 15:51:01 -0500 Subject: [PATCH 1/3] Fix constants test to pass on windows --- internal/constants/constants_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/constants/constants_test.go b/internal/constants/constants_test.go index 3181da3..e8e62b0 100644 --- a/internal/constants/constants_test.go +++ b/internal/constants/constants_test.go @@ -2,7 +2,7 @@ package constants_test import ( "fmt" - "os" + "path/filepath" "testing" "github.com/stretchr/testify/require" @@ -18,7 +18,7 @@ func Test_GetDefaultConfigPath(t *testing.T) { mock func() (string, error) }{ "os.UserConfigDir success": { - want: "abc/def" + string(os.PathSeparator) + constants.DefaultAppFolder, + want: filepath.Join("abc", "def", constants.DefaultAppFolder), mock: func() (string, error) { return "abc/def", nil }, @@ -32,7 +32,7 @@ func Test_GetDefaultConfigPath(t *testing.T) { "os.UserConfigDir error 2": { want: constants.DefaultAppFolder, mock: func() (string, error) { - return "abc", fmt.Errorf("os.UserCacheDir error") + return filepath.Join("abc", "def"), fmt.Errorf("os.UserCacheDir error") }, }, } @@ -55,9 +55,9 @@ func Test_GetDefaultCachePath(t *testing.T) { mock func() (string, error) }{ "os.UserCacheDir success": { - want: "def/abc" + string(os.PathSeparator) + constants.DefaultAppFolder, + want: filepath.Join("abc", "def", constants.DefaultAppFolder), mock: func() (string, error) { - return "def/abc", nil + return filepath.Join("abc", "def"), nil }, }, "os.UserCacheDir error": { From b2da456c09e6e13dc1b120b245fdeca36742240d Mon Sep 17 00:00:00 2001 From: kat <28567881+hk21702@users.noreply.github.com> Date: Tue, 14 Jan 2025 15:51:20 -0500 Subject: [PATCH 2/3] Linter fixes --- cmd/insights/commands/root_test.go | 3 ++- cmd/insights/commands/upload.go | 2 +- internal/collector/collector.go | 2 ++ internal/consent/consent.go | 2 ++ internal/constants/constants_test.go | 2 -- internal/uploader/uploader.go | 2 ++ 6 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cmd/insights/commands/root_test.go b/cmd/insights/commands/root_test.go index 061a6d0..bceed6c 100644 --- a/cmd/insights/commands/root_test.go +++ b/cmd/insights/commands/root_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" "github.com/ubuntu/ubuntu-insights/internal/constants" ) @@ -49,7 +50,7 @@ func TestSetVerbosity(t *testing.T) { func TestUsageError(t *testing.T) { app, err := New() - assert.NoError(t, err) + require.NoError(t, err) // Test when SilenceUsage is true app.rootCmd.SilenceUsage = true diff --git a/cmd/insights/commands/upload.go b/cmd/insights/commands/upload.go index 0764afc..6f680c3 100644 --- a/cmd/insights/commands/upload.go +++ b/cmd/insights/commands/upload.go @@ -26,7 +26,7 @@ func installUploadCmd(app *App) { app.uploadConfig = defaultUploadConfig uploadCmd := &cobra.Command{ - Use: "upload upload [sources](optional arguments)", + Use: "upload [sources](optional arguments)", Short: "Upload metrics to the Ubuntu Insights server", Long: "Upload metrics to the Ubuntu Insights server", Args: cobra.ArbitraryArgs, diff --git a/internal/collector/collector.go b/internal/collector/collector.go index 66f94de..8995073 100644 --- a/internal/collector/collector.go +++ b/internal/collector/collector.go @@ -1 +1,3 @@ +// Package collector is the implementation of the collector component. +// The collector component is responsible for collecting data from sources, merging it into a report, and then writing the report to disk. package collector diff --git a/internal/consent/consent.go b/internal/consent/consent.go index 42d2f3b..cfa37d9 100644 --- a/internal/consent/consent.go +++ b/internal/consent/consent.go @@ -1 +1,3 @@ +// Package consent is the implementation of the consent manager component. +// The consent manager is responsible for managing consent files, which are used to store the consent state for a source or the global consent state. package consent diff --git a/internal/constants/constants_test.go b/internal/constants/constants_test.go index e8e62b0..e8e46a6 100644 --- a/internal/constants/constants_test.go +++ b/internal/constants/constants_test.go @@ -9,7 +9,6 @@ import ( "github.com/ubuntu/ubuntu-insights/internal/constants" ) -//nolint:dupl //Tests for GetDefaultConfigPath is very similar to GetDefaultCachePath. func Test_GetDefaultConfigPath(t *testing.T) { t.Parallel() @@ -46,7 +45,6 @@ func Test_GetDefaultConfigPath(t *testing.T) { } } -//nolint:dupl //Tests for GetDefaultConfigPath is very similar to GetDefaultCachePath. func Test_GetDefaultCachePath(t *testing.T) { t.Parallel() diff --git a/internal/uploader/uploader.go b/internal/uploader/uploader.go index 01aafa6..b1c189e 100644 --- a/internal/uploader/uploader.go +++ b/internal/uploader/uploader.go @@ -1 +1,3 @@ +// Package uploader implements the uploader component. +// The uploader component is responsible for uploading reports to the Ubuntu Insights server. package uploader From 2076c301ee5ccfca2b191bb0619e9e57a32d636b Mon Sep 17 00:00:00 2001 From: kat <28567881+hk21702@users.noreply.github.com> Date: Wed, 15 Jan 2025 10:53:50 -0500 Subject: [PATCH 3/3] Add dependabot --- .github/dependabot.yml | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..c955d2c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,45 @@ +version: 2 +updates: + # Infrastructure + ## GitHub Actions + - package-ecosystem: "github-actions" + # Workflow files stored in the + # default location of `.github/workflows` + directory: "/" + schedule: + interval: "weekly" + day: "thursday" + time: "09:00" + groups: + gh-actions: + #applies-to: version-updates + patterns: ["*"] + commit-message: + prefix: "deps(ci)" + + ## Go dependencies + - package-ecosystem: "gomod" + directory: "/" # Location of package manifests + schedule: + interval: "weekly" + day: "thursday" + time: "09:00" + groups: + minor-updates: + #applies-to: version-updates + update-types: ["minor", "patch"] + commit-message: + prefix: "deps(go)" + + - package-ecosystem: "gomod" + directory: "/tools" + schedule: + interval: "weekly" + day: "thursday" + time: "09:00" + groups: + minor-updates: + #applies-to: version-updates + update-types: ["minor", "patch"] + commit-message: + prefix: "deps(go-tools)"