Skip to content

Conversation

viveksinghggits
Copy link
Contributor

@viveksinghggits viveksinghggits commented Sep 12, 2025

Summary

Whenever we raised PR in to helm chart repo CI failed there because we had linting issues in our helm chart. A previous PR that I raised fixed the linting problem. But we should have a linting mechanism in our CI that would consistently check if we have made any mistake in our charts. This PR does that.

The chart_schema.yaml and lintconf.yaml are the default yaml files using which ct should be run. And ct is the tool that is used for linting in our helm charts repo.

Proof of Work

Passing lint_repo task here https://spruce.mongodb.com/version/68c43aae1d5d5d000770c624/tasks?sorts=STATUS%3AASC%3BBASE_STATUS%3ADESC and in this PR as well.

Checklist

  • Have you linked a jira ticket and/or is the ticket in the title?
  • Have you checked whether your jira ticket required DOCSP changes?
  • Have you added changelog file?

@viveksinghggits viveksinghggits requested a review from a team as a code owner September 12, 2025 15:42
@viveksinghggits viveksinghggits added the skip-changelog Use this label in Pull Request to not require new changelog entry file label Sep 12, 2025
Copy link

github-actions bot commented Sep 12, 2025

⚠️ (this preview might not be accurate if the PR is not rebased on current master branch)

MCK 1.4.1 Release Notes

Copy link
Collaborator

@MaciejKaras MaciejKaras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, still I have one general ask.

When we add or change logic in our linting requirements we should also consider adding them to .githooks/pre-commit. Otherwise there is no way locally to lint the helm charts.

Secondly we should make scripts that are run in EVG CI easy to run locally as well. I wouldn't put them in scripts/evergreen/ directory, but in scripts/helm and make them available for developers. I think also .githooks/pre-commit takes care of installing all prerequisite applications.

Somehow all the efforts to set path env var using below code

```
- command: subprocess.exec
      type: test
      params:
        add_to_path:
          - ${workdir}/bin
          - ${workdir}/venv/bin
        working_dir: src/github.com/mongodb/mongodb-kubernetes
        binary: scripts/evergreen/lint_helm_chart.sh
```
I even tried to remove `subprocess.exec` and use `shell.exec` and used
`env:` for params, that didn't work as well. that's why we are finally
settling on to setting path at the lowest level. Otherwise `ct` CLI resulted
into `yamale` and `yamllint` are not found.
- ${workdir}/venv/bin
working_dir: src/github.com/mongodb/mongodb-kubernetes
binary: scripts/evergreen/check_precommit.sh
- command: subprocess.exec
Copy link
Contributor

@lsierant lsierant Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer this to be part of pre-commit script instead

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we didn't discuss this in last discuss meeting @lsierant. Is it ok if we handle this comment later after the discussion, so that we can merge this PR? Right now I have added a way to run this script locally.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also prefer it to be part of our pre-commit script, otherwise i need to chase-down scripts

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer:

  1. To be able easily to run this separately (make lint-chart is perfect). So I can run it separately from everything else.
  2. Have a separate CI job for it (so not part of lint_repo) because when lint_repo fails it you need to go through other logs because it is not immediately clear it is an issue with Python linting or Go linting or Bash linting or maybe an issue with licenses?

I'm good for it to be included in a pre-commit if it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made this part of the pre-commit and have kept lint-chart as well.

@m1kola for the second point that you mentioned, when we make this script part of pre-commit it would be automatically be part of the lint_repo task because it eventually just runs the pre-commit script. And I think it makes sense as well considering, we are actually linting the helm chart under lint_repo.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is the issue - I think lint_repo is too loaded with checks so the output became overly difficult to comprehend for a linting task. Today when I see lint_repo failed it takes me more time than it should to find out what linting I messed up.

lint_repo checks (probably not the full list):

  1. Release json/generated yamls
  2. Licenses
  3. Go linting
  4. Python linting
  5. Bash linting
  6. Now helm chart as well.

I think each of these things should be a separate task so we can quickly glance at them and understand what has failed instead of going through logs searching for specific failures. It gets worse when you mess up multiple things at the same time (e.g. Python and bash linting).

That is why I was suggesting not to add more to this complexity. I was hoping that the new checks can go into separate jobs and we will eventually split existing linting into separate jobs.

I don't want to block this PR on this - feel free to merge. But I think this is the direction we should be going with our linting jobs.

Copy link
Collaborator

@MaciejKaras MaciejKaras Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that it makes sense to separate those tasks, but setting new evergreen job per each linting tasks seems overkill. I would rather have them separated in bash scripts and then call them in separate evergreen commands/functions. This will help navigate in the task output and make it easier find the offending bash script/linting task.

- ${workdir}/venv/bin
working_dir: src/github.com/mongodb/mongodb-kubernetes
binary: scripts/evergreen/check_precommit.sh
- command: subprocess.exec
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also prefer it to be part of our pre-commit script, otherwise i need to chase-down scripts

@viveksinghggits viveksinghggits merged commit be29e59 into master Sep 23, 2025
37 checks passed
@viveksinghggits viveksinghggits deleted the lint-chart-in-ci branch September 23, 2025 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Use this label in Pull Request to not require new changelog entry file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants