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

Lint yaml workflow update #2547

Closed
wants to merge 11 commits into from
Closed

Lint yaml workflow update #2547

wants to merge 11 commits into from

Conversation

Checksumz
Copy link
Contributor

What type of PR is this:

/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:

Special notes for your reviewer:

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 2, 2024
@k8s-ci-robot
Copy link
Contributor

Adding label do-not-merge/contains-merge-commits because PR contains merge commits, which are not allowed in this repository.
Use git rebase to reapply your commits on top of the target branch. Detailed instructions for doing so can be found here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added do-not-merge/contains-merge-commits cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 2, 2024
@k8s-ci-robot k8s-ci-robot requested a review from cici37 July 2, 2024 12:22
@k8s-ci-robot k8s-ci-robot added the sig/release Categorizes an issue or PR as relevant to SIG Release. label Jul 2, 2024
@k8s-ci-robot k8s-ci-robot requested a review from puerco July 2, 2024 12:22
@k8s-ci-robot k8s-ci-robot added needs-priority size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 2, 2024
Copy link
Member

@cpanato cpanato 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 working on this
a few comments

.github/workflows/yaml-lint-checker.yaml Outdated Show resolved Hide resolved
.github/workflows/yaml-lint-checker.yaml Outdated Show resolved Hide resolved
.github/workflows/yaml-lint-checker.yaml Outdated Show resolved Hide resolved
.github/workflows/yaml-lint-checker.yaml Outdated Show resolved Hide resolved
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: '0'
Copy link
Member

Choose a reason for hiding this comment

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

do you need to fetch the entire history?

Copy link
Contributor

Choose a reason for hiding this comment

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

As we edit the release notes, we usually keep the history: #2542
image

But then before we merge into the sig-release repo, we clean up everything into a single commit.

I thought fetch-depth: 1 only fetches the latest commit? So unless we get the entire history, the workflow will only run on a single commit (which might be fine since the last commit will have the entire diff, but makes it a little harder to identify the invalid yaml during the release notes review).

fmt.Println("YAML Validation Failed:\n")
for _, errorMsg := range invalidFiles {
fmt.Println(errorMsg)
fmt.Println("\n" + strings.Repeat("-", 40) + "\n")
Copy link
Member

Choose a reason for hiding this comment

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

here should exit with error

os.Exit(1)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want to print all the invalid files, and then exit after the loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As Nina mentioned, this is to gather all the output into the variable on failure

INVALID_FILES=""
# check diff for invalid yaml files
git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} -- releases/ | grep -E '\.ya?ml$'
CHANGED_FILES=$(git diff --name-only $(git merge-base origin/master HEAD) -- releases/ | grep -E '\.ya?ml$' || true)
Copy link
Member

Choose a reason for hiding this comment

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

for this part you maybe can use this action that get all you need: https://github.com/tj-actions/changed-files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

checking this

# allows you to set env variables for subsequent steps in the same job
echo "invalid_files<<EOF" >> $GITHUB_ENV
echo "$OUTPUT" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
Copy link
Member

Choose a reason for hiding this comment

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

this works? not 100% sure that this works

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Verified on my local branch that this allows to create a multiline variable for use in the next step. Will send a screenshot with echo later

Copy link
Contributor

Choose a reason for hiding this comment

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

Release action from today's release meeting for reference : https://github.com/kubernetes-sigs/release-actions

Copy link
Member

@cpanato cpanato left a comment

Choose a reason for hiding this comment

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

i think this should go to the release-actions repo we have and then re-use here, to avoid having code in this repo.

wdyt @saschagrunert @puerco @xmudrii ?

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Checksumz
Once this PR has been reviewed and has the lgtm label, please ask for approval from cpanato. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cpanato
Copy link
Member

cpanato commented Jul 2, 2024

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 2, 2024
@saschagrunert
Copy link
Member

i think this should go to the release-actions repo we have and then re-use here, to avoid having code in this repo.

wdyt @saschagrunert @puerco @xmudrii ?

Yep I agree, thank you for the effort into this @Checksumz 🙏

@npolshakova
Copy link
Contributor

npolshakova commented Jul 2, 2024

i think this should go to the release-actions repo we have and then re-use here, to avoid having code in this repo.

wdyt @saschagrunert @puerco @xmudrii ?

Are these the release actions workflows? We'd want to be able to run this on release notes PRs going into sig-release and block if there's any invalid yaml in the diff. That would prevent having to create a separate PR to unblock the release notes like this one. If this workflow lives in the release-actions repo, can we still require it for PRs going into the sig-release repo?

Checksumz and others added 6 commits July 3, 2024 19:38
Co-authored-by: Carlos Tadeu Panato Junior <ctadeu@gmail.com>
Co-authored-by: Carlos Tadeu Panato Junior <ctadeu@gmail.com>
Co-authored-by: Carlos Tadeu Panato Junior <ctadeu@gmail.com>
@Checksumz
Copy link
Contributor Author

@cpanato i have implemented most of your suggestions apart from exit(0).

@npolshakova @cpanato @saschagrunert Just want to confirm if i need to close this PR and reopen it with https://github.com/kubernetes-sigs/release-actions and update it to be a reusable workflow ?

@Checksumz Checksumz closed this by deleting the head repository Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/contains-merge-commits do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/feature Categorizes issue or PR as related to a new feature. needs-priority sig/release Categorizes an issue or PR as relevant to SIG Release. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants