Skip to content

Helm chart testing#648

Merged
tegioz merged 18 commits intoartifacthub:masterfrom
dirtycajunrice:master
Sep 16, 2020
Merged

Helm chart testing#648
tegioz merged 18 commits intoartifacthub:masterfrom
dirtycajunrice:master

Conversation

@dirtycajunrice
Copy link
Contributor

fixes #535

Separated workflow to allow filtering trigger by file changes without needing multiple step workarounds

@dirtycajunrice dirtycajunrice force-pushed the master branch 2 times, most recently from 15f7741 to de2bc1e Compare September 13, 2020 10:50
@tegioz
Copy link
Collaborator

tegioz commented Sep 14, 2020

Hi @scottrigby 👋

Could you please review this PR when you have some time? You mentioned recently #535 (comment) about using Chart Releaser as well, not sure if you'd like suggesting it as part of this or as a separate PR.

Thanks, much appreciated!

Copy link

@scottrigby scottrigby left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. This is something I planned to get to very soon. In general, have you seen https://github.com/helm/charts-repo-actions-demo?

Comment on lines 11 to 12
- '!chart/README.md'
- '!chart/.helmignore'

Choose a reason for hiding this comment

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

Changes to any file within the chart – including the README etc – should trigger linting. The main reason is chart version packages must be immutable, and linting checks version bumping among other things.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah. I have seen varying opinions on whether or not a readme change justified a version bump. Yall are the boss and i have no opinion on it haha. I will fix.

.ct.yaml Outdated
@@ -0,0 +1,4 @@
helm-extra-args: --timeout 600s
charts: chart

Choose a reason for hiding this comment

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

I would recommend changing this:

Suggested change
charts: chart
chart-dirs: chart
- charts

Mainly because the charts option "disables changed charts detection and version increment checking". Whereas chart-dirs retains those checks, which are very useful.

I would change the current chart dir to be a charts dir, and inside add another directory for the chart. Like:

.
└── charts
    └── hub

This may seem redundant but it makes path-based checking easier. This is what I was planning to do when I opened a PR for this.

Alternatively, without changing the file tree you could set chart-dirs: "." (see helm/chart-testing#71), but you would then need to exclude all the files in the git repo root if you don't want to trigger Action runs for every change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you have a moment to test yourself, maybe you will be able to come to another verdict than i was able to! I have found the chart-dirs option to be extremely inconsistent and buggy when specifying anything other than charts. I attempted to use chart-dirs and point to the current directory, which failed catastrophically. I was not going to move the chart directory without the express approval of yall. Now that it is suggessted I can take care of that.

All of that said, if you know some secret about the chart-dirs function that all of my guys are oblivious to.. please drop some knowledge on me!

Choose a reason for hiding this comment

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

I haven't seen an issue for that in the chart-testing repo, but would appreciate one if you can remember problems you've seen. As an example, I can say that this does work for the stable and incubator chart repos – this is the ct config file where those dirs are defined: https://github.com/helm/charts/blob/master/test/ct.yaml#L3-L5

@@ -0,0 +1,41 @@
name: Helm CI

Choose a reason for hiding this comment

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

I'd rename this file from helm.yml to something more specific, like chart-testing.yaml, since as @tegioz said we also want to add another workflow for chart-releaser (I'll do that in a separate PR).

@@ -0,0 +1,41 @@
name: Helm CI
on:
push:

Choose a reason for hiding this comment

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

Don't we instead only want to run this check when pushing to a PR fork/branch? If so, the pull_request config below should suffice. That is the most common workflow I've seen.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ive seen unfortunate merges where master does not reflect the pr branch after merge. It was added as a "does no harm but can potentially help". Ill remove it :)

- '!chart/.helmignore'
pull_request:
paths:
- 'chart/**'

Choose a reason for hiding this comment

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

This is interesting. Chart-testing already does an internal check for changed charts, but might be nice in that it would limit unneeded Action runs that just say "no chart changed detected". Would you be interested in making a PR to add this to the helm actions demo here? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is exactly the purpose. As github is undoubtedly going to enforce minutes on actions sooner rather than later, this is just a safe default

Choose a reason for hiding this comment

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

Love it. And if you feel motivated I'd support a PR to add this to the lint-test workflow in the Helm Actions demo repo 😉

changed: ${{ steps.lint.outputs.changed }}
steps:
- name: Checkout code
uses: actions/checkout@v2

Choose a reason for hiding this comment

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

For the changed check, it's important to get git history, like this:

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

See https://github.com/helm/charts-repo-actions-demo/blob/master/.github/workflows/lint-test.yaml#L11-L12 for reference.

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 done it a significantly more verbose way in the past. Good catch - I am going to have to go clean up a few workflows because of this

Choose a reason for hiding this comment

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

Same here 😄 You can see we updated it recently helm/charts-repo-actions-demo#25 Props to @davidkarlsen for initially pointing out the cleaner syntax in checkout action v2.

uses: helm/[email protected]
with:
command: install
config: .ct.yaml No newline at end of file

Choose a reason for hiding this comment

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

Needs newline at EOF

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 am a huge proponent of pre-commit. Would you be opposed to me adding a minimal pre-commit config to the repo as well? (this would ensure the aforementioned is a non-issue, and could ensure things like sign offs are done)

Choose a reason for hiding this comment

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

I think this is up to @mattfarina, @tegioz and @cynthia-sg as maintainers of this project. I don't have an opinion.

Though this can also be caught in CI, and maybe it should? I haven't checked if the GitHub Superlinter Action does newline at EOF checks, but may be worth looking into.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's better if all this kind of checks are centralized in CI.

Comment on lines 17 to 18
outputs:
changed: ${{ steps.lint.outputs.changed }}

Choose a reason for hiding this comment

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

Are you adding this because you have separated test into its own job? Just a note that this isn't necessary if you keep these combined into a single lint-test job. Combined may also be a little faster as well, and less repeated step definitions.

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 initially had this in the same workflow as the ci.yml file. Fixing :)

@dirtycajunrice dirtycajunrice force-pushed the master branch 2 times, most recently from cdcced9 to 85e0287 Compare September 14, 2020 15:58
@scottrigby
Copy link

@dirtycajunrice Looks like DCO is failing because you accepted my commit suggestion. This is a common problem on DCO-required repos. I made this browser plugin to help if you're interested: https://github.com/scottrigby/dco-gh-ui

You could also just paste your signoff line into the UI, but this helps automate that, make sure it's properly formatted etc.

@@ -0,0 +1 @@
fullnameOverride: hub No newline at end of file

Choose a reason for hiding this comment

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

Needs newline at EOF

Choose a reason for hiding this comment

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

Ah but also, I just said hub as an example, I see the chart name is artifact-hub. I personally think we should keep the chart directory name the same as the chart name for clarity to end users.

At risk of bikeshedding here, this brings up a question to me: should the chart name be artifact-hub or artifacthub to be consistent with the github org name? This is probably a question for @mattfarina, @tegioz and @cynthia-sg as they maintain this project.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We can rename it to artifacthub, sounds good to me 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to condense replies: All above issues are resolved (i believe). I also fixed the secret to match the newer template of host for postgresql. I changed the name of the chart to artifacthub as decided, and fixed the commit issue. I leave the Resolve conversation buttons to the creators so i dont step on any toes. Lemme know if you see anything else!.

dirtycajunrice and others added 9 commits September 14, 2020 12:46
Signed-off-by: Nicholas St. Germain <[email protected]>
Signed-off-by: Nicholas St. Germain <[email protected]>
Signed-off-by: Nicholas St. Germain <[email protected]>
Signed-off-by: Nicholas St. Germain <[email protected]>
Signed-off-by: Nicholas St. Germain <[email protected]>
Co-authored-by: Scott Rigby <[email protected]>
Signed-off-by: Nicholas St. Germain <[email protected]>
Signed-off-by: Nicholas St. Germain <[email protected]>
…and bump Chart.yaml

Signed-off-by: Nicholas St. Germain <[email protected]>
…and bump Chart.yaml

Signed-off-by: Nicholas St. Germain <[email protected]>
Copy link

@scottrigby scottrigby 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 this 😄

USER hub
WORKDIR /home/hub
COPY --from=backend-builder /hub ./
COPY --from=backend-builder /charts/artifacthub ./
Copy link
Collaborator

@tegioz tegioz Sep 15, 2020

Choose a reason for hiding this comment

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

Could you please leave this one as /hub? This is one of the cmd names, not the chart, and that path is where the resulting binary is located. Otherwise the binary won't be copied when building the images. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tegioz That was a mass sed casualty. Fixing now.

Signed-off-by: Nicholas St. Germain <[email protected]>
@tegioz
Copy link
Collaborator

tegioz commented Sep 15, 2020

Regarding the chart renaming, there are some more things we may need to update (and I was wondering if we really should change it now as part of this PR):

  • Chart README.md: artifact-hub is used there both for the repo and for the chart itself.
  • Workflow ci.yml: artifact-hub is used there too for staging and production deployments.
  • Charts index and packages in docs/chart directory: artifact-hub is used in all packages Chart.yaml files as well as in the index. All of them would need to be updated as well. Otherwise reindexing as is would list two different packages (with and without the dash).
  • The chart with the dash is also deployed in staging and production, would need to change that as well.
  • Once all of that is changed, in Artifact Hub, the package name artifact-hub will be deleted and a new one named artifacthub will be added. This means some entities will be deleted in cascade, like users subscriptions to that package, for example.
  • Links to Artifact Hub package will be broken.

Maybe we can just step back and leave the chart renaming for a different PR if we really want to go ahead with it and think about all the implications carefully. I should have thought about all of this yesterday before agreeing to the name change, my bad.

@tegioz
Copy link
Collaborator

tegioz commented Sep 15, 2020

Other than that everything looks great! So if we go back to naming the chart artifact-hub we can go ahead and merge.

Thanks for your work @dirtycajunrice 👍

…itespace / end-of-files lint on the repo

Signed-off-by: Nicholas St. Germain <[email protected]>
Signed-off-by: Nicholas St. Germain <[email protected]>
@scottrigby
Copy link

scottrigby commented Sep 15, 2020

Actually that is correct. What we would want to do before we name change is make a release where we mark the old name deprecated so it no longer appears in the hub. Then afterwards git move to the new name and "un-deprecate" the chart then so the new release appears in the hub. But yes this should probably be done in a separate PR

@tegioz
Copy link
Collaborator

tegioz commented Sep 15, 2020

Hi @dirtycajunrice

Could you please revert the mass new line change commit? It has broken some tests in the frontend as some snapshots don't match anymore.

Thanks!

@dirtycajunrice
Copy link
Contributor Author

@tegioz oop went to sleep after and didnt wait for the tests. Yeah ill revert and exclude the ui

…iling-whitespace / end-of-files lint on the repo"

This reverts commit 09086f6

Signed-off-by: Nicholas St. Germain <[email protected]>
Signed-off-by: Nicholas St. Germain <[email protected]>
Signed-off-by: Nicholas St. Germain <[email protected]>
Copy link
Collaborator

@tegioz tegioz 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!

@tegioz tegioz merged commit 0b6750a into artifacthub:master Sep 16, 2020
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

Successfully merging this pull request may close these issues.

Perform chart testing

3 participants