Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

GH-820: Strictly lint helm files #63

Merged
merged 15 commits into from
Jul 13, 2020
Merged

GH-820: Strictly lint helm files #63

merged 15 commits into from
Jul 13, 2020

Conversation

jack-r-warren
Copy link
Contributor

@jack-r-warren jack-r-warren commented Jul 9, 2020

Purpose

Changes

  • Deleted the older helmchart-test.yml
    • Deleted rather than rewritten because I needed both actions simultaneously during my testing and I don't want to lose my commit comments to the new file
    • Deleting commit references a commit for the new action, so someone really needing to can still follow history
  • Added a new action, pr-helm-lint.yml that's able to customize command line arguments to pass --strict
  • Edited helm/wfl/values.yaml to make helm/wfl/templates/_helpers.tpl pass linting
    • In a number of places, we used if statements for existence checks on things not in values.yaml, since nil is "empty"/falsy
    • Now, all keys are defined in values.yaml, just with empty strings, which are also "empty"/falsy (docs for default and if)

Review Instructions

  • For testing the action:
    • Fork WFL, merge this branch into master, and then make a branch with edits to files in helm/wfl and try to PR it
    • You'll have to specifically visit the actions page of your fork on GitHub to allow them to run before you make a PR
  • For regression testing the values.yaml file:
    • If we believe Helm's docs, this is a no-op change that just satisfies the linter
    • If there's no change in Helm's output and we can still customize fullnameOverride, nameOverride, and serviceAccount.name then it works
      • I need to get Kubernetes working in order to test this myself. I'll do that, I just figured I could get this in front of other folks' eyes since I'm pretty confident the code here is done. I've now done this, there's no change in behavior I can find (output is the same, arguments still work).

Jack Warren added 14 commits July 8, 2020 16:42
The benefit of being a separate action is we get to very
easily filter this to only run on applicable PRs/pushes.
We also get parallelization too, which we could get just
by using separate jobs in the same action. Accomplishing
the filtering, though, would require more complex logic
to do at step-time rather than action-time as done here.
This issue with --strict has been documented online:
helm/helm#5417
helm/helm#3766
The Helm developers essentially said they don't care,
but some other folks found they had a similar issue
with template files and came up with workarounds:
VirtusLab/render#11

One option is to use weird template syntax to
do some sort of non-checked existence test:
VirtusLab/render#11 (comment)
The cleaner solution I use here is to put
empty overrides in the values file since they'll
get actually overridden if needed:
VirtusLab/render#11 (comment)
This container is the same one used by the chart-test-action
itself. The three commands in sequence:
- helm lint:
 using --strict to fail on warning
 using --namespace to emulate our ct.yaml config
- yamale
 NOT using --strict because the schema doesn't include all
 optional fields, so --strict fails
- yamllint
 using --strict to fail on warning
 NOT recursively searching because templates don't pass
This file can be safely deleted:
- Functionality encoded in pr-helm-lint.yml
- The fetch here isn't something we need to
 replicate in pr-helm-lint.yml, since we are
 controlling via path triggers and don't need
 the git history anymore during the job (we
 actually never needed the fetch here, since
 this action also used a PR path trigger)
- I summarized the "hyphenated name" comment
 in the new action so we don't lose that
 knowledge
This file can be safely deleted:
- Functionality encoded in pr-helm-lint.yml
- I summarized the "hyphenated name" comment
 in the new action so we don't lose that
 knowledge
My new linting complains that there's no version bump,
and I suppose it is right
@jack-r-warren
Copy link
Contributor Author

Since the PR is coming from a fork, it is using my fork's GitHub Actions. This means:

  • I had to bump the chart version since the linting detects that
  • It won't pass the normal build because my repo's actions don't have the permissions that build expects

Comment on lines +7 to +10
version: 0.2.7

home: https://github.com/broadinstitute/wfl
appVersion: 0.2.6
appVersion: 0.2.7
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even though my change to values.yaml is a no-op, the linting wants a version bump here. If we want, we can revert afa751a to get rid of this version bump (linting will complain but it won't affect anything).

Comment on lines +5 to +13
on:
push:
branches:
- master
paths:
- helm/wfl/**
pull_request:
paths:
- helm/wfl/**
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'm targeting helm/wfl specifically because we'd have to reconfigure this action a bit if we added other charts. Basic linting (just errors) will work on everything because chart-testing has logic to find charts based on ct.yaml, but the strict linting is just done via command line and uses a working directory of helm/wfl.

Copy link
Contributor

@rexwangcc rexwangcc left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for improving this! I have confirmed https://github.com/rexwangcc/wfl/runs/859149051?check_suite_focus=true this works on my fork. It would be great to let helm be more tolerant on version bumps, but that's trivial to me and this PR already does a lot good.

@jack-r-warren
Copy link
Contributor Author

It would be great to let helm be more tolerant on version bumps, but that's trivial to me and this PR already does a lot good.

That’s something I have a bit of control over, actually. The version check and a “is there a maintainer” check both come from running ct lint, they’re actually the only reason we use ct here. I can’t configure the checks but if we don’t care for the version one I can easily remove ct from the action altogether.

@jack-r-warren
Copy link
Contributor Author

Discussed with folks after standup, determined that we like the version check. Merging.

@jack-r-warren jack-r-warren merged commit 3be4d5d into broadinstitute:master Jul 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants