From f48cbd1964b57ff7c17e2f233feb49c03efe6417 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Thu, 9 Jan 2025 01:25:58 +0100 Subject: [PATCH 1/3] add github actions Signed-off-by: Mark Sagi-Kazar --- .editorconfig | 12 ++++++++ .github/.editorconfig | 2 ++ .github/dependabot.yaml | 12 ++++++++ .github/workflows/ci.yaml | 60 +++++++++++++++++++++++++++++++++++++++ .golangci.yaml | 4 +++ 5 files changed, 90 insertions(+) create mode 100644 .editorconfig create mode 100644 .github/.editorconfig create mode 100644 .github/dependabot.yaml create mode 100644 .github/workflows/ci.yaml create mode 100644 .golangci.yaml diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..4492e9f9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 4 +indent_style = space +insert_final_newline = true +trim_trailing_whitespace = true + +[*.go] +indent_style = tab diff --git a/.github/.editorconfig b/.github/.editorconfig new file mode 100644 index 00000000..0902c6ae --- /dev/null +++ b/.github/.editorconfig @@ -0,0 +1,2 @@ +[{*.yml,*.yaml}] +indent_size = 2 diff --git a/.github/dependabot.yaml b/.github/dependabot.yaml new file mode 100644 index 00000000..73aa36fa --- /dev/null +++ b/.github/dependabot.yaml @@ -0,0 +1,12 @@ +version: 2 + +updates: + - package-ecosystem: gomod + directory: / + schedule: + interval: daily + + - package-ecosystem: github-actions + directory: / + schedule: + interval: daily diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..292c29e0 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,60 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + +jobs: + test: + name: Test + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + go: ["1.21", "1.22", "1.23"] + + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Set up Go + uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 + with: + go-version: ${{ matrix.go }} + + - name: Test + # Cannot enable shuffle for now because some tests rely on global state and order + # run: go test -race -v -shuffle=on ./... + run: go test -race -v ./... + + lint: + name: Lint + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Set up Go + uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0 + with: + go-version: "1.23" + + - name: Lint + uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1 + with: + version: v1.63.4 + + dependency-review: + name: Dependency review + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Dependency Review + uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0 diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 00000000..b274f248 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,4 @@ +linters: + disable-all: true + enable: + - nolintlint From a0f4ddd9fe01ac8fece07be6e3f3ae5dcd7ceec0 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Thu, 9 Jan 2025 01:34:01 +0100 Subject: [PATCH 2/3] fix govet Signed-off-by: Mark Sagi-Kazar --- flag_test.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/flag_test.go b/flag_test.go index 58a5d25a..643f0999 100644 --- a/flag_test.go +++ b/flag_test.go @@ -433,7 +433,7 @@ func testParseWithUnknownFlags(f *FlagSet, t *testing.T) { "-u=unknown3Value", "-p", "unknown4Value", - "-q", //another unknown with bool value + "-q", // another unknown with bool value "-y", "ee", "--unknown7=unknown7value", @@ -899,7 +899,7 @@ func TestChangingArgs(t *testing.T) { // Test that -help invokes the usage message and returns ErrHelp. func TestHelp(t *testing.T) { - var helpCalled = false + helpCalled := false fs := NewFlagSet("help test", ContinueOnError) fs.Usage = func() { helpCalled = true } var flag bool @@ -998,6 +998,7 @@ func getDeprecatedFlagSet() *FlagSet { f.MarkDeprecated("badflag", "use --good-flag instead") return f } + func TestDeprecatedFlagInDocs(t *testing.T) { f := getDeprecatedFlagSet() @@ -1134,7 +1135,6 @@ func TestMultipleNormalizeFlagNameInvocations(t *testing.T) { } } -// func TestHiddenFlagInUsage(t *testing.T) { f := NewFlagSet("bob", ContinueOnError) f.Bool("secretFlag", true, "shhh") @@ -1149,7 +1149,6 @@ func TestHiddenFlagInUsage(t *testing.T) { } } -// func TestHiddenFlagUsage(t *testing.T) { f := NewFlagSet("bob", ContinueOnError) f.Bool("secretFlag", true, "shhh") @@ -1239,7 +1238,7 @@ func TestPrintDefaults(t *testing.T) { got := buf.String() if got != defaultOutput { fmt.Println("\n" + got) - fmt.Println("\n" + defaultOutput) + fmt.Printf("\n" + defaultOutput) t.Errorf("got %q want %q\n", got, defaultOutput) } } From 100ab0eb250792014fc1594d94f7fb5c5f0dee37 Mon Sep 17 00:00:00 2001 From: Mark Sagi-Kazar Date: Thu, 9 Jan 2025 01:35:44 +0100 Subject: [PATCH 3/3] disable unsupported dependency graph for now Signed-off-by: Mark Sagi-Kazar --- .github/workflows/ci.yaml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 292c29e0..42f7614a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -46,15 +46,3 @@ jobs: uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1 with: version: v1.63.4 - - dependency-review: - name: Dependency review - runs-on: ubuntu-latest - if: github.event_name == 'pull_request' - - steps: - - name: Checkout repository - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: Dependency Review - uses: actions/dependency-review-action@3b139cfc5fae8b618d3eae3675e383bb1769c019 # v4.5.0