-
Notifications
You must be signed in to change notification settings - Fork 16.8k
Enhancing lint.sh with additional checks for Chart.yaml #4161
Conversation
/assign @unguiculus |
test/circle/lint.sh
Outdated
# include the semvercompare function | ||
curDir="$(dirname "$0")" | ||
source "$curDir/../semvercompare.sh" | ||
|
||
git remote add k8s https://github.com/kubernetes/charts | ||
#git remote add k8s https://github.com/kubernetes/charts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this removed intentionally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified the file for local testing. this is post revert leftovers
test/circle/lint.sh
Outdated
git fetch k8s master | ||
CHANGED_FOLDERS=`git diff --find-renames --name-only $(git merge-base k8s/master HEAD) stable/ incubator/ | awk -F/ '{print $1"/"$2}' | uniq` | ||
|
||
# Exit early if no charts have changed | ||
Exit early if no charts have changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was uncommented for some reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I like the additional checks and where this is going. Thanks for putting this together. I just have a little feedback.
test/circle/install.sh
Outdated
|
||
# Install a yq bash yaml cli tool | ||
# Pinning to a version for consistency | ||
sudo pip install yq==2.1.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tool installed below (https://github.com/mikefarah/yaml
) is also a yaml query tool. It's been renamed yq (we're still using an older version). We should install one yaml querying tool and use that consistently.
I'm indifferent to the one we use.
test/circle/lint.sh
Outdated
|
||
for name in $(yq -r '.maintainers|.[]|.name' ${1}/Chart.yaml); do | ||
if [ $(curl -s -o /dev/null -w "%{http_code}\n" -If https://github.com/${name}) -ne 200 ]; then | ||
echo "Error: ${name} is not valid GitHub account" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this check. Would it be possible to add some polite language letting people know we have that as a requirement on the charts repo so that we can contact chart maintainers in issues/PRs.
test/circle/lint.sh
Outdated
git remote add k8s https://github.com/kubernetes/charts | ||
git fetch k8s master | ||
CHANGED_FOLDERS=`git diff --find-renames --name-only $(git merge-base k8s/master HEAD) stable/ incubator/ | awk -F/ '{print $1"/"$2}' | uniq` | ||
|
||
# Exit early if no charts have changed | ||
#Exit early if no charts have changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The space before Exit
was removed?
test/circle/yaml-schemas/Chart.yaml
Outdated
--- | ||
maintainer: | ||
name: str() | ||
email: str(required=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are more than just these that can be in a chart. The options are described in a proto file. Could we get more of the properties added to the schema?
removing yq installetion chaning yq with yaml for Chart.yaml parsing. modifing Erro message for not github account check. also modifing lint.sh so it can be used locally
I've modified lint.sh so it can be used locally. it can be removed and added as separate, better-structured PR. I was trying to add something like lint_my_chart.sh, but got stuck with questions: where to place it, where should readme go, what execution to support etc
|
/approve |
/ok-to-test |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: depohmel, mattfarina, viglesiasce The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
* Enhancing lint.sh with additional checks * reverting post local testing changes * addressing reviews. removing yq installetion chaning yq with yaml for Chart.yaml parsing. modifing Erro message for not github account check. also modifing lint.sh so it can be used locally
* Enhancing lint.sh with additional checks * reverting post local testing changes * addressing reviews. removing yq installetion chaning yq with yaml for Chart.yaml parsing. modifing Erro message for not github account check. also modifing lint.sh so it can be used locally
* Enhancing lint.sh with additional checks * reverting post local testing changes * addressing reviews. removing yq installetion chaning yq with yaml for Chart.yaml parsing. modifing Erro message for not github account check. also modifing lint.sh so it can be used locally Signed-off-by: voron <av@arilot.com>
This PR is enhancing current CirckeCi initial linter.
It looks like most of the time submitted Chart.yaml (a super common case for new charts) has missing fields. this PR is enabling field validation against yaml-schemas/Chart.yaml schema file with https://github.com/23andMe/Yamale CLI tool.
Also, this change will allow adding schema[s] for values.yaml.
Maintainer GitHub account validation is another new test. List of maintainers got parsed with yq tool and validated via curl against https://github.com/<account_name>
this should make @unguiculus life slightly easy.
Examples of outputs:
Successful validation
Missing field in Chart.yaml
incorrect maintainer name