-
Notifications
You must be signed in to change notification settings - Fork 402
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
Conversation
…lpha.1' into npolshak/lint-yaml-workflow
Adding label 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. |
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.
thanks for working on this
a few comments
- name: Check out code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: '0' |
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.
do you need to fetch the entire history?
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.
As we edit the release notes, we usually keep the history: #2542
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") |
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.
here should exit with error
os.Exit(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.
I think we want to print all the invalid files, and then exit after the loop.
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.
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) |
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.
for this part you maybe can use this action that get all you need: https://github.com/tj-actions/changed-files
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.
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 |
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 works? not 100% sure that this works
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.
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
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.
Release action from today's release meeting for reference : https://github.com/kubernetes-sigs/release-actions
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 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 ?
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Checksumz 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 |
/hold |
Yep I agree, thank you for the effort into this @Checksumz 🙏 |
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? |
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>
…umz/sig-release into lint-yaml-workflow-update
@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 ? |
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: