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

Detect and fix broken links #3746

Merged
merged 15 commits into from
Jun 14, 2021
Merged

Detect and fix broken links #3746

merged 15 commits into from
Jun 14, 2021

Conversation

tobias-tengler
Copy link
Collaborator

@tobias-tengler tobias-tengler commented May 27, 2021

I essentially moved the code of gatsby-remark-check-links into this repository and made some changes. The original plugin has some flaws that make it incompatible with our website and it is also no longer maintained by the original author.

Changes

  • Add plugin to discover headings and links inside of markdown files
  • Add plugin to check for the validity of links between markdown pages
  • The slug field is now the actual slug (before: /hotchocolate/get-started/, now: /docs/hotchocolate/get-started)
  • Centralize slug generation (page creation now uses the generated slugs)
  • Fix dead links in the documentation and blog posts

@tobias-tengler tobias-tengler force-pushed the tte/catch-dead-links branch 3 times, most recently from 5ec39d0 to 3fab54a Compare May 28, 2021 13:44
@tobias-tengler tobias-tengler changed the title WIP: Catch dead links Detect broken links May 28, 2021
@tobias-tengler tobias-tengler marked this pull request as ready for review May 28, 2021 13:46
@ChilliCream ChilliCream deleted a comment from azure-pipelines bot May 28, 2021
@tobias-tengler tobias-tengler changed the base branch from tte/fix-toc to main May 28, 2021 13:48
@tobias-tengler tobias-tengler self-assigned this May 28, 2021
@tobias-tengler tobias-tengler force-pushed the tte/catch-dead-links branch from 3fab54a to 128897e Compare May 31, 2021 19:43
@tobias-tengler tobias-tengler added the 📚 documentation This issue is about working on our documentation. label May 31, 2021
@tobias-tengler tobias-tengler changed the title Detect broken links Detect and fix broken links May 31, 2021
@rstaib
Copy link
Member

rstaib commented Jun 1, 2021

@tobias-tengler could you please solve the conflicts so I can start the review 😄

@tobias-tengler tobias-tengler force-pushed the tte/catch-dead-links branch from 128897e to a546188 Compare June 1, 2021 15:37
@tobias-tengler tobias-tengler requested a review from rstaib June 1, 2021 15:38
@tobias-tengler tobias-tengler force-pushed the tte/catch-dead-links branch from 9a6aa53 to bf20c62 Compare June 1, 2021 16:11
@tobias-tengler
Copy link
Collaborator Author

Okay I've noticed two issues with this just now.

  1. When running yarn build it works as expected. But with yarn start it doesn't since the slug is not present on the fields.
  2. With yarn start it also struggles with .md files that aren't in the docs.json file. I think that's because I check for each file with an .md extension and not just the valid ones.

Will look into these problems tomorrow.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@tobias-tengler tobias-tengler changed the title Detect and fix broken links WIP: Detect and fix broken links Jun 2, 2021
@tobias-tengler tobias-tengler removed the request for review from rstaib June 2, 2021 18:27

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@tobias-tengler
Copy link
Collaborator Author

Okay I can't get it to work with yarn start. This is due to the "lazy" nature of gatsby in development. Not all pages are created at the same time, causing issues when trying to validate links. The markdown plugin is also always invoked before a slug for the node is generated, therefor we don't know under which URL the current markdown document will be available. This is not an issue with yarn build.

I think it is fine like it is though. It will discover broken links in CI and when yarn build is invoked locally and that's better than no indication at all.

I also significantly improved the performance in comparison to my initial attempt, by splitting the gathering of links and validation of those links into two separate local plugins.

@tobias-tengler tobias-tengler changed the title WIP: Detect and fix broken links Detect and fix broken links Jun 3, 2021
@tobias-tengler tobias-tengler requested a review from rstaib June 3, 2021 16:57
rstaib
rstaib previously approved these changes Jun 14, 2021
Copy link
Member

@rstaib rstaib left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you!

@rstaib
Copy link
Member

rstaib commented Jun 14, 2021

@tobias-tengler could you please fix the conflict then we could merge 👍

@tobias-tengler
Copy link
Collaborator Author

tobias-tengler commented Jun 14, 2021

@rstaib done! ✅

EDIT: One of the Hot Chocolate tests has been stuck for 17min 😭

@tobias-tengler
Copy link
Collaborator Author

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@tobias-tengler
Copy link
Collaborator Author

Not sure why the Website pipeline also ran 17min this time. It seems to have been stuck on the onPostBuild, which this PR doesn't modify. I tested locally again and the link validation is definitely not at fault here. I would attribute it to degraded Pipeline performance of DevOps at the moment...

@tobias-tengler tobias-tengler merged commit e083860 into main Jun 14, 2021
@tobias-tengler tobias-tengler deleted the tte/catch-dead-links branch June 14, 2021 21:07
@rstaib
Copy link
Member

rstaib commented Jun 14, 2021

@tobias-tengler Let's see if the perf issue is persistent and tackle it then in another issue.

@tobias-tengler
Copy link
Collaborator Author

tobias-tengler commented Jun 14, 2021

Happened again in the pipeline, while other PRs ran with a similar time. I'm not yet sure what's causing this, the link validation is already done, once the stalling hits. I'll look further into it tomorrow.
Can confirm this is also an actual issue on my dev machine. The onPostBuild takes around 100 seconds longer than on previous versions.

tobias-tengler added a commit that referenced this pull request Jun 16, 2021
* Detect dead links

* Fix broken links

* Link using the absolute path

* Fix dead blog post links (in theory)

* Use slug field as slug

* Support validation of non inline links

* Be more explicit about header discovery

* Fix some more links

* Fix broken links

* Split gathering and validation of links into two plugins

* Use reporter for output
Conflicts:
	website/package.json
	website/src/docs/hotchocolate/defining-a-schema/scalars.md
	website/src/docs/strawberryshake/performance/index.md
	website/yarn.lock
tobias-tengler added a commit that referenced this pull request Jun 19, 2021
* Detect dead links

* Fix broken links

* Link using the absolute path

* Fix dead blog post links (in theory)

* Use slug field as slug

* Support validation of non inline links

* Be more explicit about header discovery

* Fix some more links

* Fix broken links

* Split gathering and validation of links into two plugins

* Use reporter for output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📚 documentation This issue is about working on our documentation. 🌶️ website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants