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

Run the link check for PRs and changes to master #1167

Merged
merged 4 commits into from
Jan 19, 2023

Conversation

wallrj
Copy link
Member

@wallrj wallrj commented Jan 19, 2023

There exists an npm run markdown-link-check script, which checks both internal markdown links and external links.

I've enabled it in CI and fixed a bunch of the broken internal links that it identified.

I've disabled the anchor checking because it is not reliable, due to:

Also disabled external link checks because sites like cloudflare seem to block robot http clients.
And also because there are some broken links in the cert-manager API.

Example failures:

References:

Signed-off-by: Richard Wall <richard.wall@jetstack.io>
Signed-off-by: Richard Wall <richard.wall@jetstack.io>
@jetstack-bot jetstack-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 19, 2023
@netlify
Copy link

netlify bot commented Jan 19, 2023

Deploy Preview for cert-manager-website ready!

Name Link
🔨 Latest commit e521164
🔍 Latest deploy log https://app.netlify.com/sites/cert-manager-website/deploys/63c9541e9b525e0007f1309f
😎 Deploy Preview https://deploy-preview-1167--cert-manager-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@jetstack-bot jetstack-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 19, 2023
Signed-off-by: Richard Wall <richard.wall@jetstack.io>
Checking external links is flaky due to network and rate limiting
Checking anchor links doesn't work when the anchors have been specified using
`<a name` syntax.
Checking /foo/bar/baz.png links doesn't work because they are served from a
virtual webserver directory mapped to public/

Signed-off-by: Richard Wall <richard.wall@jetstack.io>
@jetstack-bot jetstack-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 19, 2023
@wallrj wallrj changed the title WIP: Run the link check for PRs and changes to master Run the link check for PRs and changes to master Jan 19, 2023
@jetstack-bot jetstack-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 19, 2023
> ℹ️ All these checks are also run automatically for pull requests.
> The results will be reported in the [checks summary](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/about-status-checks) at the bottom of your GitHub PR.
> Read the [cert-manager-website-presubmits.yaml prow configuration file](https://github.com/jetstack/testing/blob/master/config/jobs/cert-manager/website/cert-manager-website-presubmits.yaml) and the [check.yaml workflow file](.github/workflows/check.yaml) for more details.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a couple of paragraphs about these npm scripts and a note to explain how they are run by CI.

@@ -4,19 +4,19 @@ description: ''
---

approver-policy is a cert-manager
[approver](https://cert-manager.io/docs/concepts/certificaterequest/#approval)
[approver](../concepts/certificaterequest.md#approval)
Copy link
Member Author

Choose a reason for hiding this comment

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

There were a bunch of absolute links which I converted to internal links. Probably because this content was copy - pasted from the README file of the project.

@@ -269,7 +269,7 @@ CertificateRequestPolicies against CertificateRequests for evaluation. A
CertificateRequestPolicy must select, and therefore match, a CertificateRequest
for it to be considered for evaluation of the request.

> ⚠️ Note that the user must still be bound by [RBAC](#Configuration) for
> ⚠️ Note that the user must still be bound by [RBAC](#configuration) for
Copy link
Member Author

Choose a reason for hiding this comment

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

The link checker picked this up before I disabled the #anchor checks.
It seems that the autogenerated markdown anchors are always lower case.

@@ -145,12 +145,12 @@ For users of Kubernetes `v1.15` we keep offering support for the `v1beta1` Kuber
For this release we upgraded our logging library to `klog/v2` analog to Kubernetes `v1.19`.
We also reviewed every log we write to assign it an appropriate log level.

We followed the (Kubernetes logging guidelines)[https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md]. To come up with 5 log levels ranging from `Error` (level 0) which only prints important errors to `Trace` (level 5) which can help you to know exactly what is gong on.
We followed the [Kubernetes logging guidelines](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md). To come up with 5 log levels ranging from `Error` (level 0) which only prints important errors to `Trace` (level 5) which can help you to know exactly what is gong on.
Copy link
Member Author

Choose a reason for hiding this comment

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

This link was marked up incorrectly.

"pattern": "^https://developers.cloudflare.com"
"description": "Ignore external links which may fail due to network flakiness and rate limits on foreign servers",
"pattern": "^https?://"
},
Copy link
Member Author

Choose a reason for hiding this comment

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

For example

FILE: content/docs/tutorials/getting-started-aks-letsencrypt/README.md
  [✖] https://www.cloudflare.com/en-gb/learning/dns/glossary/what-is-a-domain-name-registrar/
  [✖] https://www.cloudflare.com/en-gb/learning/dns/dns-server-types/
  [✖] clusterissuer-selfsigned.yaml
  [✖] certificate.yaml

  ERROR: 11 dead links found!
  [✖] deployment.yaml
  [✖] service.yaml
  [✖] https://www.cloudflare.com/en-gb/learning/dns/dns-records/dns-cname-record/
  [✖] ../../configuration/acme/dns01/azuredns/README.md
  [✖] values.yaml
  [✖] clusterissuer-lets-encrypt-staging.yaml
  [✖] clusterissuer-lets-encrypt-production.yaml

  34 links checked.
  [✖] https://www.cloudflare.com/en-gb/learning/dns/glossary/what-is-a-domain-name-registrar/ → Status: 403
  [✖] https://www.cloudflare.com/en-gb/learning/dns/dns-server-types/ → Status: 403
  [✖] clusterissuer-selfsigned.yaml → Status: 400

@@ -1,13 +1,21 @@
{
"ignorePatterns": [
{
"pattern": "^https://github.com"
"description": "Ignore root relative links to images which markdown-link-check is unable to verify",
"pattern": "^/"
Copy link
Member Author

Choose a reason for hiding this comment

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

For example:

FILE: content/docs/troubleshooting/webhook.md
  [✖] https://web.archive.org/web/20210903183221/https://serverfault.com/questions/1076563/creating-issuer-for-kubernetes-cert-manager-is-causing-404-and-500-error
  [✖] #io-timeout
  [✖] #context-deadline-exceeded
  [✖] #gke-private-cluster
  [✖] #diagram
  [✖] /images/troubleshooting/webhook-pod-networking-diagram.png

  48 links checked.

  ERROR: 6 dead links found!
  [✖] https://web.archive.org/web/20210903183221/https://serverfault.com/questions/1076563/creating-issuer-for-kubernetes-cert-manager-is-causing-404-and-500-error → Status: 0
  [✖] #io-timeout → Status: 404
  [✖] #context-deadline-exceeded → Status: 404
  [✖] #gke-private-cluster → Status: 404
  [✖] #diagram → Status: 404
  [✖] /images/troubleshooting/webhook-pod-networking-diagram.png → Status: 400

Copy link
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

I added suggestions, but I'm not even gonna add a hold. I'm generally super concerned about developing two parallel CI pipelines, but I don't want to get in the way of progress.

Comment on lines +17 to +26
link-check:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
cache: npm
- run: npm ci
- run: npm run markdown-link-check
Copy link
Member

Choose a reason for hiding this comment

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

suggestion (non-blocking): I think proliferating a pattern where some jobs are run in github actions and some are run in prow will lead to everything being harder to maintain in the future.

I'd rather not use github actions at all, personally, but more important than "actions vs prow" is consistency.

I don't think it's a blocker, because I don't want to get in the way of a good PR... but I think it's a concern.

Comment on lines +157 to +171

```bash
npm run lint
```

To check the links in all pages, run [markdown-link-check](https://github.com/tcort/markdown-link-check):

```bash
npm run markdown-link-check
```

> ℹ️ All these checks are also run automatically for pull requests.
> The results will be reported in the [checks summary](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/about-status-checks) at the bottom of your GitHub PR.
> Read the [cert-manager-website-presubmits.yaml prow configuration file](https://github.com/jetstack/testing/blob/master/config/jobs/cert-manager/website/cert-manager-website-presubmits.yaml) and the [check.yaml workflow file](.github/workflows/check.yaml) for more details.

Copy link
Member

Choose a reason for hiding this comment

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

suggestion (non-blocking): It would be nice to have a single script which can be run to check everything locally, and to have the CI environment call that script. Doesn't really matter though

markdown-link-check.json Show resolved Hide resolved
@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 19, 2023
@jetstack-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SgtCoDFish, wallrj

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

@jetstack-bot jetstack-bot merged commit 99a5d62 into cert-manager:master Jan 19, 2023
@wallrj wallrj deleted the link-check branch January 19, 2023 15:42
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. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. 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.

3 participants