-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Error using --new-from-rev in Google Build Cloud #1088
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, |
Thank you for your answer @jirfag |
it should have a |
No sorry, it is no public. I tried several configurations:
But I got the same result, it works in my local environment but it doesn't work in google cloud build.
Thank you in advance for any help :-) |
@jirfag I got a solucion at the end: I am using this: https://github.com/golangci/golangci-lint-action But it works fine for me with this configuration:
Because If I use for example push option and args to compare with master or HEAD~: I got again the same error with all the issues in the application:
Error:
|
I'm having the same issue, unfortunately, the repo is not public.
.github/workflows/test.yml name: test
on: push
env:
go_version: 1.16.0
jobs:
backend-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2
with:
go-version: ${{ env.go_version }}
- uses: actions/checkout@v2
- name: Run linters
uses: golangci/golangci-lint-action@v2
with:
version: v1.31.0
skip-go-installation: true
working-directory: backend/src
only-new-issues: true .golangci.yml output:
format: github-actions
issues:
new-from-rev: a32ce..382b
linters:
disable-all: true
enable:
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
- varcheck |
Some changes has been done in v1.37.0 about that topic, could you try with this version? |
@ldez I've tried v1.37.0 and I've got the same result :/ |
facing similar issue any update? |
Just to keep the issue in the right way.
These previous error messages can mean:
If the command If the commits are missing, you have to configure your CI to get those commits. With GitHub ActionsYou have to define steps:
- name: Check out code
uses: actions/checkout@v2
with:
fetch-depth: 0 https://github.com/actions/checkout#fetch-all-history-for-all-tags-and-branches With TravisYou have to define git:
depth: false https://docs.travis-ci.com/user/customizing-the-build#git-clone-depth For the other CI or platform, you have to check the documentation of your CI or platform about git fetching configuration. To solve this issue, the error message must be improved if possible to get more context. |
I modified the configuration of @ldez is correct. I used to limit the depth of git cloning in order to speed up the clone speed, but this resulted in golangci-lint not being able to obtain enough information (the commits are missing). Now I will allow the depth of git clone to be 15,However, there may be potential risks in doing so. If you change more than 15 commit, there will be problems. |
* Upgrade the golangci version to 1.39 * Changed the checkout depth golangci/golangci-lint#1088 (comment)
* Upgrade the golangci version to 1.39 * Changed the checkout depth golangci/golangci-lint#1088 (comment)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Since it's on the front page of Google, it's a good place to share my experience with Sometimes the command golangci-lint run --new-from-rev=master crashes inside the Gitlab CI with the error
The reason is that GitLab only checkout commits without downloading branches. In order to use the master, you need to download it explicitly git fetch origin master && git branch master remotes/origin/master |
👆 Oleg's comment was very helpful - builds in TeamCity also crash with the same error. Even using |
For Google Cloud Build specifically, you'd need to fetch unshallow. This is because cloudbuild by default performs shallow clone. - id: gitFetch
waitFor: ['-']
name: 'gcr.io/cloud-builders/git'
entrypoint: git
args: ['fetch', '--unshallow', '--quiet']
- id: lint
waitFor: ['gitFetch']
name: 'golangci/golangci-lint:${_GOLANGCI_VERSION}'
entrypoint: golangci-lint
args: ['run', '--new-from-rev=master'] For GitLab runners, I think configuring the git strategy would work although I cannot verify it as I don't use GitLab https://docs.gitlab.com/ee/ci/pipelines/settings.html#choose-the-default-git-strategy. |
Thank you for creating the issue!
Please include the following information:
Version of golangci-lint
Config file
Verbose output of running
In my local environment this works fine:
golangci-lint run --config .golangci.yml -v --new-from-rev=HEAD~
but in Google Build Cloud I got this error:
level=warning msg="[runner] Can't process result by diff processor: can't prepare diff by revgrep: could not read git repo: error executing git diff \"HEAD~\" \"\": exit status 128"
The text was updated successfully, but these errors were encountered: