diff --git a/.github/.golangci.yml b/.github/.golangci.yml index f57a238b..8153585c 100644 --- a/.github/.golangci.yml +++ b/.github/.golangci.yml @@ -1,89 +1,78 @@ -linters-settings: - dupl: - threshold: 100 - errcheck: - check-type-assertions: true - ignore: fmt:.*,io/ioutil:^Read.*,io:Close,os:Close,io/fs:Close - goconst: - min-len: 2 - min-occurrences: 2 - goimports: - local-prefixes: github.com/golangci/golangci-lint - golint: - min-confidence: 0 - govet: - check-shadowing: true - misspell: - locale: US - ignore-words: [] - +version: "2" +run: + go: "1.24" linters: - disable-all: true + default: none enable: - # HTTPリクエストで閉じられていないものを検出 - bodyclose - # 使われていないコードを検出 - - deadcode - # _, _ := x() のようなものを検出 - dogsled - # 同一コードの検出 - dupl - # エラーを未チェックのものを検出 - errcheck - # 定数化できるものを検出 - goconst - # gofmt - - gofmt - # goimports - - goimports - # alternative to golint - - revive - # 引数がフォーマット文字列と一致しないものを検出 - govet - # 意味のない再代入を検出 - ineffassign - # スペルチェック - misspell - # for中などで固定されてない変数を検出(alternative to scopelint) - - exportloopref - # 構造体の未使用フィールドを検出 - - structcheck - # 不要な型変換を検出 + - revive - unconvert - # 未使用のものを検出 - unused - # 未使用のグローバル変数・定数を検出 - - varcheck - # 前後の余計な空白を検出 - whitespace - -issues: - exclude: - - declaration of "(err|ctx)" shadows declaration at - exclude-use-default: false - exclude-rules: - - path: cmd/api_gen/client/.*\.go - linters: - - dupl - - - path: _test\.go - linters: - - gomnd - - dupl - - - linters: - - lll - source: "//go:generate " - -run: - go: 1.18 - skip-dirs: - - test/testdata_etc - - internal/cache - - internal/renameio - - internal/robustio - -service: - golangci-lint-version: 1.23.x - prepare: - - echo "here I can run custom commands, but no preparation needed for this repo" + settings: + dupl: + threshold: 100 + errcheck: + check-type-assertions: true + exclude-functions: + - fmt.* + - io/ioutil.Read.* + - io.Close + - os.Close + - io/fs.Close + goconst: + min-len: 2 + min-occurrences: 2 + govet: + enable: + - shadow + misspell: + locale: US + exclusions: + generated: lax + rules: + - linters: + - dupl + path: cmd/api_gen/client/.*\.go + - linters: + - dupl + - mnd + path: _test\.go + - linters: + - lll + source: '//go:generate ' + - path: (.+)\.go$ + text: declaration of "(err|ctx)" shadows declaration at + paths: + - test/testdata_etc + - internal/cache + - internal/renameio + - internal/robustio + - third_party$ + - builtin$ + - examples$ +formatters: + enable: + - gofmt + - goimports + settings: + goimports: + local-prefixes: + - github.com/golangci/golangci-lint + exclusions: + generated: lax + paths: + - test/testdata_etc + - internal/cache + - internal/renameio + - internal/robustio + - third_party$ + - builtin$ + - examples$ diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 21acf194..10ce56ad 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -14,12 +14,12 @@ jobs: GO111MODULE: on steps: - - name: Set up Go 1.18 + - name: Set up Go 1.25 uses: actions/setup-go@v5 with: - go-version: 1.18 + go-version: '1.25' id: go - + - uses: actions/checkout@v4 - uses: actions/cache@v4 @@ -40,14 +40,14 @@ jobs: GO111MODULE: on steps: - - name: Set up Go 1.18 + - name: Set up Go 1.25 uses: actions/setup-go@v5 with: - go-version: 1.18 + go-version: '1.25' id: go - uses: actions/setup-node@v4 with: - node-version: '16' + node-version: '20' - uses: dart-lang/setup-dart@v1 with: sdk: "2.14.4" @@ -70,9 +70,12 @@ jobs: TZ: Asia/Tokyo run: | make gen_samples - - clean=$(git status | grep "nothing to commit" || true) - if [ -z "$clean" ]; then + + # Exclude "generated version:" / "api_gen version:" comment lines from the diff check. + # These lines embed the binary version at build time and are expected to differ + # between a tagged release build and a local/CI build of an untagged commit. + real_diff=$(git diff | grep "^[+-]" | grep -v "^---\|^+++" | grep -v "generated version:\|api_gen version:" || true) + if [ -n "$real_diff" ]; then git diff echo 'Please run "make gen_samples"' exit 1 diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index c4b1ab6e..9460189a 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -9,7 +9,7 @@ jobs: uses: actions/checkout@v4 - uses: actions/setup-go@v5 with: - go-version: 1.18 + go-version: '1.25' - name: Install dependencies run: | go install golang.org/x/tools/cmd/goimports@latest @@ -19,18 +19,20 @@ jobs: TZ: Asia/Tokyo run: | make gen_samples - - clean=$(git status | grep "nothing to commit" || true) - if [ -z "$clean" ]; then + + # Exclude "generated version:" / "api_gen version:" comment lines from the diff check. + # These lines embed the binary version at build time and are expected to differ + # between a tagged release build and a local/CI build of an untagged commit. + real_diff=$(git diff | grep "^[+-]" | grep -v "^---\|^+++" | grep -v "generated version:\|api_gen version:" || true) + if [ -n "$real_diff" ]; then git diff echo 'Please run "make gen_samples"' exit 1 fi - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v7 with: args: "--config=.github/.golangci.yml" - version: v1.45.0 - skip-go-installation: true - skip-pkg-cache: true - skip-build-cache: true + version: v2.12.1 + only-new-issues: true + skip-cache: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index acd95a97..2cc7a627 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: 1.17 + go-version: '1.25' - name: Run GoReleaser for api_gen uses: goreleaser/goreleaser-action@v5.0.0 diff --git a/e2e/e2eutil/selenium.go b/e2e/e2eutil/selenium.go index efc6df5d..3c517ffc 100644 --- a/e2e/e2eutil/selenium.go +++ b/e2e/e2eutil/selenium.go @@ -27,7 +27,14 @@ func NewSeleniumUtil(t *testing.T) *SeleniumUtil { } chrCaps := chrome.Capabilities{ - Args: []string{"--headless"}, + Args: []string{ + "--headless", + // Chrome 112+ new headless mode enforces stricter CSP in about:blank context, + // which causes fetch() to fail with "TypeError: Failed to fetch" when + // ExecuteScriptAsync is called without first navigating to a page. + // --disable-web-security allows cross-origin fetch in headless test context. + "--disable-web-security", + }, } caps := selenium.Capabilities{"browserName": "chrome"} diff --git a/go.mod b/go.mod index 1362c38c..2423fcdd 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/go-generalize/api_gen/v2 -go 1.18 +go 1.25.0 require ( github.com/go-generalize/go2go v0.2.1 @@ -10,9 +10,8 @@ require ( github.com/google/go-cmp v0.6.0 github.com/iancoleman/strcase v0.2.0 github.com/spf13/cobra v1.8.0 - golang.org/x/sync v0.6.0 - golang.org/x/sys v0.4.0 // indirect - golang.org/x/tools v0.5.0 // indirect + golang.org/x/sync v0.20.0 + golang.org/x/tools v0.44.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 ) @@ -29,6 +28,6 @@ require ( github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect - golang.org/x/mod v0.7.0 // indirect + golang.org/x/mod v0.35.0 // indirect golang.org/x/text v0.3.8 // indirect ) diff --git a/go.sum b/go.sum index 3e0c563b..5da3fbf5 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM= +golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= @@ -71,8 +71,8 @@ golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= -golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.20.0 h1:e0PTpb7pjO8GAtTs2dQ6jYa5BWYlMuX047Dco/pItO4= +golang.org/x/sync v0.20.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -81,8 +81,6 @@ golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18= -golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= @@ -93,8 +91,8 @@ golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200918232735-d647fc253266/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= -golang.org/x/tools v0.5.0 h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4= -golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= +golang.org/x/tools v0.44.0 h1:UP4ajHPIcuMjT1GqzDWRlalUEoY+uzoZKnhOjbIPD2c= +golang.org/x/tools v0.44.0/go.mod h1:KA0AfVErSdxRZIsOVipbv3rQhVXTnlU6UhKxHd1seDI= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=