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

Remove capture shortcodes & warn on future use. #22175

Merged

Conversation

sftim
Copy link
Contributor

@sftim sftim commented Jun 29, 2020

After PR #21359 merged, some more capture shortcodes have crept in.

This PR

  • removes the extra capture shortcodes
  • emits a warning if someone uses a capture shortcode

I chose a warning rather than error to reduce the risk of a misguided merge breaking the site. There's no lint about broken shortcodes, and the CI tests the code from the fork, rather than testing the result of a simulated merge into master.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 29, 2020
@sftim
Copy link
Contributor Author

sftim commented Jun 29, 2020

Related to issue #20335

@k8s-ci-robot k8s-ci-robot added language/en Issues or PRs related to English language language/es Issues or PRs related to Spanish language labels Jun 29, 2020
@k8s-ci-robot k8s-ci-robot added language/fr Issues or PRs related to French language language/id Issues or PRs related to Indonesian language language/ko Issues or PRs related to Korean language language/ru Issues or PRs related to Russian language language/zh Issues or PRs related to Chinese language sig/docs Categorizes an issue or PR as relevant to SIG Docs. labels Jun 29, 2020
@sftim
Copy link
Contributor Author

sftim commented Jun 29, 2020

Also, this is across localizations - @kbhawkey / @onlydole (as tech leads) could you take a look?

@netlify
Copy link

netlify bot commented Jun 29, 2020

Deploy preview for kubernetes-io-master-staging ready!

Built with commit 325ba87

https://deploy-preview-22175--kubernetes-io-master-staging.netlify.app

@kbhawkey
Copy link
Contributor

@sftim,
One thing, is it time to remove the capture shortcode instead of adding a warning?
Did these changes create a non-failing deploy preview? I guess so.
Is there is a way to add a pre-check build to the deploy build that marks the build as fail (should fail if the capture shortcode is removed) plus adds a hold on the PR?

@kbhawkey
Copy link
Contributor

/kind cleanup

@k8s-ci-robot k8s-ci-robot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label Jun 29, 2020
@sftim
Copy link
Contributor Author

sftim commented Jun 29, 2020

One thing, is it time to remove the capture shortcode instead of adding a warning?

@kbhawkey I'm worried about the blast radius of a localization team merging a new PR that breaks the website because a page uses a missing shortcode. This way, the updated page doesn't render correctly but the build remains working.

I'd like to get Netlify to simulate a merge and then build a preview, which would detect that issue and block a merge, but making that change happen is not an easy ask.

@sftim
Copy link
Contributor Author

sftim commented Jun 29, 2020

We can implement additional checks (eg using GitHub Actions) that create a preview merge and then try to run Hugo. That seems to me like it's duplicating what Netlify already does, but it could be useful.

@kbhawkey
Copy link
Contributor

Instead, removing the capture shortcode will throw a build error.

@sftim
Copy link
Contributor Author

sftim commented Jun 29, 2020

removing the capture shortcode will throw a build error

I'm wary of having that error happen after a merge to master - it means prompt feedback but also more of a pain to fix.

{{ warnf "Invalid shortcode in %q" .Page.Path }}
Copy link
Contributor

@kbhawkey kbhawkey Jun 30, 2020

Choose a reason for hiding this comment

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

@sftim, What do you think about adding more information to the warning.
It would be helpful to provide the capture_id in the warning message.
I could see leaving lines 1-6 and adding the capture_id.
Also, add the prefix to identify with the page path:

{{ $_hugo_config := `{ "version": 1 }`}}
{{- $id := .Get 0 -}}
{{- if not $id -}}
{{- errorf "missing id in capture" -}}
{{- end -}}
{{- $capture_id := printf "capture %s" $id -}}
<!--
{{- .Page.Scratch.Set $capture_id .Inner -}}
-->
{{ warnf "Invalid shortcode: in %s, %q" $capture_id (relLangURL .Page.Path) }}

@sftim sftim force-pushed the 20200629_remove_capture_shortcodes branch from 957b2f1 to c380d08 Compare June 30, 2020 15:23
@zparnold
Copy link
Member

zparnold commented Jul 1, 2020

Seems fine to me, probably need some other tech lead to approve whilst I get back up to speed.
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 1, 2020
{{- $capture_id := printf "capture %s" $id -}}
<!--
Copy link
Contributor

@kbhawkey kbhawkey Jul 1, 2020

Choose a reason for hiding this comment

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

@sftim, Things look good. Would you remove the comment? I'd like to see a clean build/deploy preview
before merging. Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed!

@sftim
Copy link
Contributor Author

sftim commented Jul 4, 2020

Similar to PR #22321

If anyone uses the capture shortcode, emit a warning. The website
no longer uses capture shortcodes.
@sftim sftim force-pushed the 20200629_remove_capture_shortcodes branch from c380d08 to 325ba87 Compare July 4, 2020 10:11
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 4, 2020
@kbhawkey
Copy link
Contributor

kbhawkey commented Jul 4, 2020

/lgtm
This will help.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 4, 2020
{{- $capture_id := printf "capture %s" $id -}}
{{- .Page.Scratch.Set $capture_id .Inner -}}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: The Scratch set could be removed?

@kbhawkey
Copy link
Contributor

kbhawkey commented Jul 4, 2020

Let's move this forward.
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kbhawkey

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 4, 2020
@k8s-ci-robot k8s-ci-robot merged commit 4c19ec6 into kubernetes:master Jul 4, 2020
@sftim sftim deleted the 20200629_remove_capture_shortcodes branch July 6, 2020 21:40
@sftim
Copy link
Contributor Author

sftim commented Jul 6, 2020

“We got one”. This warning helped me find an issue and submit PR #22397.

@kbhawkey
Copy link
Contributor

kbhawkey commented Jul 6, 2020

Yes, I saw it in testing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. language/en Issues or PRs related to English language language/es Issues or PRs related to Spanish language language/fr Issues or PRs related to French language language/id Issues or PRs related to Indonesian language language/ko Issues or PRs related to Korean language language/ru Issues or PRs related to Russian language language/zh Issues or PRs related to Chinese language lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/docs Categorizes an issue or PR as relevant to SIG Docs. 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.

None yet

4 participants