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

Add krel release notes validation workflow #2698

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

npolshakova
Copy link
Contributor

What type of PR is this:

/kind feature

What this PR does / why we need it:

Adds a GitHub Action to setup krel.

This is required to setup a presubmit job for PRs like: #2659. The current requirement is to add validation using:

$ krel release-notes validate --help
krel release-notes validate

The 'validate' subcommand of krel has been developed to:

  1. Check release notes maps for valid yaml.

  2. Check release notes maps for valid punctuation.

Usage:
  krel release-notes validate [flags]

Flags:
  -h, --help                           help for validate
      --path-to-release-notes string   The path to the release notes to validate. Can be a top level directory or a specific file.

The release notes team is blocked whenever invalid yaml is merged into sig-release:

#2589
#2541

Invalid yaml can be introduced during the review process when people apply changes or manually edit the maps (not through krel, but in an editor). This workflow automates preventing invalid yaml from merging into sig-release.

Which issue(s) this PR fixes:

Fixes kubernetes/release#2753

Special notes for your reviewer:

Based on @Vyom-Yadav's GitHub workflow: kubernetes-sigs/release-actions#101

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Dec 17, 2024
@k8s-ci-robot k8s-ci-robot added needs-priority sig/release Categorizes an issue or PR as relevant to SIG Release. labels Dec 17, 2024
@npolshakova npolshakova added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. sig/release Categorizes an issue or PR as relevant to SIG Release. needs-priority labels Dec 17, 2024
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/release-team Issues or PRs related to the release-team subproject sig/release Categorizes an issue or PR as relevant to SIG Release. labels Dec 17, 2024
@Vyom-Yadav
Copy link
Member

/assign

@Vyom-Yadav Vyom-Yadav force-pushed the npolshak/release-notes-validation-github-workflow branch from c469b5e to cc3bf07 Compare January 5, 2025 08:47
Comment on lines 49 to 50

KREL_VERSION=v0.17.12
Copy link
Member

Choose a reason for hiding this comment

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

I've pinned this to v0.17.12, if and when we do a new release of krel, we'd need to update this. (I think there may be some automated job to do that, or we can add this to the handbook (for the lead to update it).

Alternatively, do we want to fetch the latest release?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, currently the handbook suggests the docs team uses the lastest krel, so maybe it's fine just fetching the latest release? https://github.com/kubernetes/sig-release/blob/ff03da9043cdd4cfd63f4c06c901909a744f2daa/release-team/role-handbooks/docs/README.md#tools

Copy link
Member

Choose a reason for hiding this comment

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

Done, I changed to latest.

@Vyom-Yadav Vyom-Yadav force-pushed the npolshak/release-notes-validation-github-workflow branch 2 times, most recently from dea0462 to 83d5f96 Compare January 11, 2025 10:43
@Vyom-Yadav
Copy link
Member

@Vyom-Yadav
Copy link
Member

/remove hold

@Vyom-Yadav Vyom-Yadav removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 11, 2025
@Vyom-Yadav
Copy link
Member

/assign @npolshakova

@npolshakova
Copy link
Contributor Author

npolshakova commented Jan 12, 2025

Changes look good @Vyom-Yadav!
Uploading image.png…

Is there a way to make this workflow required when merging release notes changes in? @kubernetes/sig-release-leads

It should only trigger on release notes changed conditions, but I think we might need admin permissions in GitHub to make it required?

@Vyom-Yadav
Copy link
Member

I think required workflows might not be supported anymore (for new workflows - https://docs.github.com/en/enterprise-server@3.11/actions/sharing-automations/required-workflows), but a github admin can check that for us. Anyways, that can only be enabled after merging this action.

@stmcginnis
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 14, 2025
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.

some comments

thanks for doing this

- releases/**/release-notes/**.yml
# Allow manual triggering
workflow_dispatch: { }

Copy link
Member

Choose a reason for hiding this comment

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

add

permissions: {}

this will drop all permissions for the workflow, as we dont need

Copy link
Member

Choose a reason for hiding this comment

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

Added.

krel_release_notes_validate_action:
name: Validate release notes with krel
runs-on: ubuntu-latest
if: ${{ !github.event.pull_request.draft }}
Copy link
Member

Choose a reason for hiding this comment

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

add

permissions:
   contents: read

we might just need the contents read to be able to clone

Copy link
Member

Choose a reason for hiding this comment

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

Since, it is a public repo, I don't think this is required. actions/checkout directly uses git, so I don't think we need to add any permission to the github_token

- uses: sigstore/cosign-installer@dc72c7d5c4d10cd6bcb8cf6e3fd625a9e5e537da # v3.7.0
with:
use-sudo: false
- id: install-krel
Copy link
Member

Choose a reason for hiding this comment

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

i think this is fine for now, we can add install krel action in the release-actions repo.

Copy link
Member

Choose a reason for hiding this comment

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

It was discussed that krel install should not be exportable. Ref: kubernetes-sigs/release-actions#101 (comment)

issue_number: context.issue.number,
body: `❌ YAML validation failed for the following files:\n\n${invalidFiles}`
});
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: new line

Copy link
Member

Choose a reason for hiding this comment

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

Added a new line at the end.

else
echo "No YAML files changed under /releases/*"
fi
- name: Comment on PR if invalid yaml detected
Copy link
Member

Choose a reason for hiding this comment

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

i think this will not work as expected because in fork PRs we dont have the write permission for the github token

i would add this as job summary and then we can see this in the checks tab

https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#adding-a-job-summary

Copy link
Member

Choose a reason for hiding this comment

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

I agree. It only needs pull-requests but I'd prefer to keep the token with less permissions. Just fail it and we can check the results on the workflow run.

Copy link
Member

Choose a reason for hiding this comment

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

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 15, 2025
- name: Check out code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
# we need to fetch the full history in order to check changes across all commits on the branch
Copy link
Member

Choose a reason for hiding this comment

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

I think this comment is from another workflow :)

Suggested change
# we need to fetch the full history in order to check changes across all commits on the branch

Copy link
Member

Choose a reason for hiding this comment

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

We do CHANGED_FILES=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} -- releases/ | grep -E '\.ya?ml$' || true), so need fetch-depth 0. I removed the comment though (I think that is just extra)

Comment on lines 17 to 22
push:
branches:
- master
paths:
- releases/**/release-notes/**.yaml
- releases/**/release-notes/**.yml
Copy link
Member

Choose a reason for hiding this comment

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

Since we're gating on the PR I think we can drop the run on push as we know the YAMLs are already valid.

Suggested change
push:
branches:
- master
paths:
- releases/**/release-notes/**.yaml
- releases/**/release-notes/**.yml

Copy link
Member

Choose a reason for hiding this comment

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

Removed.

else
echo "No YAML files changed under /releases/*"
fi
- name: Comment on PR if invalid yaml detected
Copy link
Member

Choose a reason for hiding this comment

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

I agree. It only needs pull-requests but I'd prefer to keep the token with less permissions. Just fail it and we can check the results on the workflow run.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: npolshakova
Once this PR has been reviewed and has the lgtm label, please ask for approval from cpanato. For more information see the 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

@Vyom-Yadav Vyom-Yadav force-pushed the npolshak/release-notes-validation-github-workflow branch 2 times, most recently from f9e3293 to 032ca70 Compare January 16, 2025 09:42
Co-authored-by: npolshakova <nina.polshakova@solo.io>
Signed-off-by: Vyom-Yadav <jackhammervyom@gmail.com>
@Vyom-Yadav Vyom-Yadav force-pushed the npolshak/release-notes-validation-github-workflow branch from 032ca70 to 1e65e4f Compare January 16, 2025 09:48
@Vyom-Yadav
Copy link
Member

@Vyom-Yadav Vyom-Yadav requested review from puerco and cpanato January 16, 2025 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/release-team Issues or PRs related to the release-team subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. 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.

krel can not handle backticks at the beginning of text field
6 participants