Skip to content
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

Cannot lint charts in pipeline #186

Closed
g0blin79 opened this issue Nov 12, 2019 · 11 comments
Closed

Cannot lint charts in pipeline #186

g0blin79 opened this issue Nov 12, 2019 · 11 comments

Comments

@g0blin79
Copy link

This probably is not a bug, but only a problem I have and I don't understand why. I'm asking an help.

I start using ct for our company chart repository.
Our charts are into a "stable" directory at the root of the repo.

If I try to lint my chart in local environment I do it with success.
But when I use the same command in my CI Environment (Gitlab Pipeline) I had this error:

Linting charts...
Using config file:  .bmeme/config.yaml
------------------------------------------------------------------------------------------------------------------------
 Configuration
------------------------------------------------------------------------------------------------------------------------
Remote: origin
TargetBranch: master
BuildId: 
LintConf: /etc/ct/lintconf.yaml
ChartYamlSchema: /etc/ct/chart_schema.yaml
ValidateMaintainers: false
ValidateChartSchema: true
ValidateYaml: true
CheckVersionIncrement: true
ProcessAllCharts: false
Charts: []
ChartRepos: []
ChartDirs: [stable]
ExcludedCharts: []
HelmExtraArgs: --timeout 600
HelmRepoExtraArgs: []
Debug: false
Upgrade: false
SkipMissingValues: false
Namespace: 
ReleaseLabel: 
------------------------------------------------------------------------------------------------------------------------
Error linting charts: Error identifying charts to process: Error running process: exit status 128
------------------------------------------------------------------------------------------------------------------------
No chart changes detected.
------------------------------------------------------------------------------------------------------------------------

Some infos:

  • I'm using this yaml configuration:
target-branch: master
chart-dirs:
  - stable
helm-extra-args: --timeout 600
validate-maintainers: false
  • In local development environment I run lint command using docker image, in this way:
    `docker run -v $(pwd):/workdir gcr.io/kubernetes-charts-ci/test-image:v3.4.0 sh -c "ct lint --config .bmeme/config.yaml"

  • In pipeline, I tried running this command both native and with docker-in-docker: in both case I had the same error.

If I try to run same command with --debug option, I noticed the following differences about git commands:

local execution:

------------------------------------------------------------------------------------------------------------------------
>>> git rev-parse --is-inside-work-tree
>>> git merge-base origin/master HEAD
>>> git diff --find-renames --name-only f34b8dae2977eb310860a145f8b429567128ebc7 -- stable

------------------------------------------------------------------------------------------------------------------------

pipeline execution

------------------------------------------------------------------------------------------------------------------------
>>> git rev-parse --is-inside-work-tree
>>> git merge-base origin/master HEAD
Error linting charts: Error identifying charts to process: Error running process: exit status 128
------------------------------------------------------------------------------------------------------------------------

Can you help me to debug this problem?

@lenardchristopher
Copy link

Hi @g0blin79. I started experiencing the same issue today. It is not specific to my computer/user and abruptly started happening about 6 hours ago.

Did you ever find a fix?

@coreywagehoft
Copy link

Having a similar problem when running inside of a GitHub action. Here is the output.

/usr/bin/docker run --name <redacted> --label f6cdeb --workdir /github/workspace --rm -e INPUT_ARGS -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/helm-charts/helm-charts":"/github/workspace" <redacted> lint --target-branch develop --chart-dirs . --chart-yaml-schema .github/actions/chart-testing-action/etc/chart_schema.yaml --lint-conf .github/actions/chart-testing-action/etc/lintconf.yaml --validate-maintainers=false --debug
Linting charts...
------------------------------------------------------------------------------------------------------------------------
 Configuration
------------------------------------------------------------------------------------------------------------------------
Remote: origin
TargetBranch: develop
BuildId:
LintConf: .github/actions/chart-testing-action/etc/lintconf.yaml
ChartYamlSchema: .github/actions/chart-testing-action/etc/chart_schema.yaml
ValidateMaintainers: false
ValidateChartSchema: true
ValidateYaml: true
CheckVersionIncrement: true
ProcessAllCharts: false
Charts: []
ChartRepos: []
ChartDirs: [.]
ExcludedCharts: []
HelmExtraArgs: 
HelmRepoExtraArgs: []
Debug: true
Upgrade: false
SkipMissingValues: false
Namespace: 
ReleaseLabel: 
------------------------------------------------------------------------------------------------------------------------
>>> git rev-parse --is-inside-work-tree
>>> git merge-base origin/develop HEAD
Error linting charts: Error identifying charts to process: Error running process: exit status 128
------------------------------------------------------------------------------------------------------------------------
No chart changes detected.
------------------------------------------------------------------------------------------------------------------------

@unguiculus
Copy link
Member

git merge-base failed in these cases. It probably complained because the given remote branch doesn't exist. Please verify the remote is there and fetched.

@coreywagehoft
Copy link

git merge-base failed in these cases. It probably complained because the given remote branch doesn't exist. Please verify the remote is there and fetched.

Thanks for the insight on this @unguiculus. This turned my attention to the actions/checkout action that gets our helm charts to lint. Turns out yesterday a breaking change release came out and we were previously targeting the master branch.

https://github.com/actions/checkout/releases/tag/v2-beta

If you are using chart-testing with GitHub actions make sure to only use actions/checkout:v1.2.0 for use with helm chart testing & linting.

@evannorstrand
Copy link

I can confirm this issue happens in gitlab as well.

ct lint --debug --remote origin --target-branch master --chart-dirs stable --chart-repos xxx=yyy

@cprovencher
Copy link

cprovencher commented Feb 13, 2020

@unguiculus I added a "git fetch" per your recommendation. Now I no longer get a 128 exit code, but instead an exit code 1 with no logs at all. Any idea how to debug this? When would git merge-base return 1 with no logs? GIT_TRACE=1 didn't help either.

------------------------------------------------------------------------------------------------------------------------
>>> git rev-parse --is-inside-work-tree
>>> git merge-base origin/master HEAD
Error linting charts: Error identifying charts to process: Error running process: exit status 1
------------------------------------------------------------------------------------------------------------------------
No chart changes detected.
------------------------------------------------------------------------------------------------------------------------

@joejulian
Copy link
Contributor

This issue is caused by your SCM creating a shallow clone. This leads to two git errors.

error 128

This is because there is no master branch with the shallow clone that most scm's create.

$ git clone git@github.com:example/project --branch pullrequest --depth 1 work
$ cd work
$ git merge-base origin/master HEAD ; echo $?
fatal: Not a valid object name origin/master
128

As it says, origin/master doesn't exist.

$ git branch -a                                                                 
* pullrequest
  remotes/origin/pullrequest

As has been discovered, you can overcome that by pulling in master:

git fetch origin '+refs/heads/master:refs/remotes/origin/master'

error 1

merge-base will still return errno 1 because this branch of your shallow clone is what's known as "grafted" meaning as far as git's concerned, it has no parents

$ git reflog show --decorate
cf5a1df (grafted, HEAD -> pullrequest, origin/pullrequest) HEAD@{0}: clone: from git@github.com:example/project

To overcome that obsticle, you'll need to "unshallow" the branch checked out by CI

git fetch --unshallow

This will now allow merge-base to work

$ git merge-base origin/master HEAD
2f7422522c60f2bc4325362d7e4b5996c4b7720f

@unguiculus
Copy link
Member

@coreywagehoft actions/checkout@v2 does a shallow checkout by default. This can be reconfigured as follows

uses: actions/checkout@v2
with:
  fetch-depth: "0"

@lsowen
Copy link

lsowen commented Apr 19, 2020

For someone else running into the exit 128 error in Jenkins, you have to disable shallow cloning:

image

For some reason, to actually disable shallow cloning you must set Shallow clone depth to 0 (just having Shallow clone unchecked doesn't actually fix anything.)

gitirabassi added a commit to influxdata/helm-charts that referenced this issue Apr 22, 2020
gitirabassi added a commit to influxdata/helm-charts that referenced this issue Apr 22, 2020
adding more details on charts manifest

finalixing chart

removed dependency on cert-manager

removed blank lines and trailing spaces

testing with different CI conf from helm/chart-testing#186

fix: helm testing library requires maintainers be configured

addressing review comments

fix: don't require cert-manager by default

removing namespace reference

re-adding namespace with reference to release

fixying app version

adding dependency cert-manager and added ci values

trying to add a repo in ct conf"

testing more

removing trailing space

removed ci.yml

trying getting some more debug

more testing and reading in https://github.com/helm/chart-testing/blob/master/doc/ct_install.md

fixes trailing spaces"

trying using helm native function for tls certificates
rawkode pushed a commit to influxdata/helm-charts that referenced this issue Apr 23, 2020
adding more details on charts manifest

finalixing chart

removed dependency on cert-manager

removed blank lines and trailing spaces

testing with different CI conf from helm/chart-testing#186

fix: helm testing library requires maintainers be configured

addressing review comments

fix: don't require cert-manager by default

removing namespace reference

re-adding namespace with reference to release

fixying app version

adding dependency cert-manager and added ci values

trying to add a repo in ct conf"

testing more

removing trailing space

removed ci.yml

trying getting some more debug

more testing and reading in https://github.com/helm/chart-testing/blob/master/doc/ct_install.md

fixes trailing spaces"

trying using helm native function for tls certificates
@dminca
Copy link

dminca commented Feb 16, 2022

@coreywagehoft actions/checkout@v2 does a shallow checkout by default. This can be reconfigured as follows

uses: actions/checkout@v2
with:
  fetch-depth: "0"

This worked for me in GitLab CI as well, by setting:

  variables:
    GIT_DEPTH: "0"

@pathob
Copy link

pathob commented Jan 10, 2023

Took me some time to find the solution so I want to add it here:

I'm also using Jenkins and in my case I had to add the following ref spec for the Git(Lab) branch source (so the main branch as the target branch is also available locally):

+refs/heads/main:refs/remotes/origin/main

Also related to helm/chart-testing-action#25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants