mochengqian commented on code in PR #964:
URL: https://github.com/apache/dubbo-go-pixiu/pull/964#discussion_r3644578988
##########
Makefile:
##########
@@ -68,6 +68,11 @@ test:
sh before_ut.sh
go test ./pkg/... -gcflags=-l -coverprofile=coverage.txt
-covermode=atomic
+lint:check-lint
+ @golangci-lint run
+check-lint:
+ @type golangci-lint >/dev/null 2>&1 || echo "golangci-lint is not
installed, please install it first by run 'go install
github.com/golangci/golangci-lint/v2/cmd/[email protected]'"
Review Comment:
Fixed. `check-lint` now exits non-zero when golangci-lint is missing (line
77: `exit 1`).
##########
.golangci.yaml:
##########
@@ -49,9 +49,6 @@ linters:
- linters:
- gosec
text: weak cryptographic primitive
- - linters:
- - staticcheck
- text: 'SA1019:'
- linters:
Review Comment:
Fixed in the latest commit. The root cause was that `issues.new: true` in
`.golangci.yaml` relies on `HEAD~` resolution, which fails on shallow clones
and only covers the last commit in a multi-commit push.
The fix moves the diff-base logic to the workflow:
- `.golangci.yaml` keeps `issues.new: true` for local use
- The workflow adds a `Resolve lint base` step that fetches the correct base
commit (`pull_request.base.sha` for PRs, `github.event.before` for pushes) and
passes it explicitly via `--new-from-rev`
- `git fetch --depth=1 origin "$base"` ensures the base commit is reachable
in the shallow clone, fixing the `fatal: bad revision` error
##########
.github/workflows/github-actions.yml:
##########
@@ -66,6 +66,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
+ with:
+ fetch-depth: 2
Review Comment:
Fixed. The workflow now explicitly resolves the lint base SHA and passes
`--new-from-rev` to golangci-lint:
- For `pull_request` events: uses `github.event.pull_request.base.sha`
- For `push` events: uses `github.event.before` (the correct pre-push SHA,
not `HEAD~`)
- Fetches the base commit with `git fetch --depth=1` to ensure it's
reachable in the shallow clone
- First-push on a new branch (`before` is all zeros) falls back to full
scan, which is the safe default
This ensures every commit in a multi-commit push is checked against the
correct base.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]