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

fix(lint): honor the --since flag when checking for version increment #508

Closed
wants to merge 1 commit into from

Conversation

AlexandrePicosson
Copy link

What this PR does / why we need it:
With the current implementation ct lint does not use the existing --since flag when checking for a version increment.
This is problematic when you want to use ct lint to validate the difference between the checked out commit and a previous commit on the same branch. As ct lint tries to validate a difference between the current file and origin/main and these are the same files.

It is also misleading to have a different way of handling the --since flag between lint and list-changed.

I changed the code to use the same logic as in ct list-changed to determine the base of the change when validating the version increment.

Here are the verbose logs for before and after the change, we can see the difference in git commands issued:

Before
ct lint --target-branch main --since 6541404b08b5afb68974a8f41dedb764725f89ea --debug
Linting charts...
>>> helm version --template {{ .Version }}
>>> git rev-parse --is-inside-work-tree
>>> git merge-base origin/main 6541404b08b5afb68974a8f41dedb764725f89ea
>>> git diff --find-renames --name-only 6541404b08b5afb68974a8f41dedb764725f89ea -- charts

------------------------------------------------------------------------------------------------------------------------
 Charts to be processed:
------------------------------------------------------------------------------------------------------------------------
 service => (version: "0.2.0-alpha.1", path: "charts/service")
------------------------------------------------------------------------------------------------------------------------

>>> helm dependency build charts/service
Linting chart "service => (version: \"0.2.0-alpha.1\", path: \"charts/service\")"
Checking chart "service => (version: \"0.2.0-alpha.1\", path: \"charts/service\")" for a version bump...
>>> git cat-file -e origin/main:charts/service/Chart.yaml
>>> git show origin/main:charts/service/Chart.yaml
Old chart version: 0.2.0-alpha.2
New chart version: 0.2.0-alpha.1
------------------------------------------------------------------------------------------------------------------------
 ✖︎ service => (version: "0.2.0-alpha.1", path: "charts/service") > chart version not ok. Needs a version bump!
------------------------------------------------------------------------------------------------------------------------
Error: failed linting charts: failed processing charts
failed linting charts: failed processing charts
After
 ct lint --target-branch main --since 6541404b08b5afb68974a8f41dedb764725f89ea --debug
Linting charts...
>>> helm version --template {{ .Version }}
>>> git rev-parse --is-inside-work-tree
>>> git merge-base origin/main 6541404b08b5afb68974a8f41dedb764725f89ea
>>> git diff --find-renames --name-only 6541404b08b5afb68974a8f41dedb764725f89ea -- charts

------------------------------------------------------------------------------------------------------------------------
 Charts to be processed:
------------------------------------------------------------------------------------------------------------------------
 service => (version: "0.2.0-alpha.1", path: "charts/service")
------------------------------------------------------------------------------------------------------------------------

>>> helm dependency build charts/service
Linting chart "service => (version: \"0.2.0-alpha.1\", path: \"charts/service\")"
Checking chart "service => (version: \"0.2.0-alpha.1\", path: \"charts/service\")" for a version bump...
>>> git rev-parse --is-inside-work-tree
>>> git merge-base origin/main 6541404b08b5afb68974a8f41dedb764725f89ea
>>> git cat-file -e 6541404b08b5afb68974a8f41dedb764725f89ea:charts/service/Chart.yaml
>>> git show 6541404b08b5afb68974a8f41dedb764725f89ea:charts/service/Chart.yaml
Old chart version: 0.1.0-a9
New chart version: 0.2.0-alpha.1
Chart version ok.
>>> yamale --schema /usr/local/etc/ct/chart_schema.yaml charts/service/Chart.yaml
Validating /charts/service/Chart.yaml...
Validation success! 👍
>>> yamllint --config-file /usr/local/etc/ct/lintconf.yaml charts/service/Chart.yaml
------------------------------------------------------------------------------------------------------------------------
 ✖︎ service => (version: "0.2.0-alpha.1", path: "charts/service") > failed running process: exec: "yamllint": executable file not found in $PATH
------------------------------------------------------------------------------------------------------------------------
Error: failed linting charts: failed processing charts
failed linting charts: failed processing charts

@cpanato cpanato closed this Oct 27, 2023
@cpanato cpanato reopened this Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants