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

🐛 Bug fix: check links test #26739

Merged
merged 2 commits into from
Feb 20, 2020

Conversation

ajwhatson
Copy link
Contributor

No description provided.

@amp-owners-bot amp-owners-bot bot requested a review from lannka February 11, 2020 17:10
@ajwhatson ajwhatson removed the request for review from lannka February 11, 2020 17:11
@ajwhatson
Copy link
Contributor Author

Before, links to files added by the PR would simply be skipped over in the search for dead links. Instead, by using relative links to markup files, all links are checked regardless.

Closes #26713

Copy link
Contributor

@rsimha rsimha left a comment

Choose a reason for hiding this comment

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

Yay, your first PR! 😃

Couple high-level comments here:

  1. This PR will break the common use-case where a PR adds a new .md file and also adds a full, non-relative link to that file from another file in the repo. See check-links.js should allow for links that are within the PR #9628 (comment) for the original motivation behind ignoring links to files added by the PR.
  2. Forcing all amphtml documentation to use relative links is not something we should aim to do. There are hundreds of files with a few hundred non-relative links in our codebase right now.

To address this, I think a good compromise would be to forgive any non-relative links to files added by the same PR if the relative portion of that link is correct. (See comment below).

WDYT?

@@ -134,10 +118,6 @@ function checkLinksInFile(file) {
}
let containsDeadLinks = false;
for (const {link, status, statusCode} of results) {
// Skip links to files that were introduced by the PR.
if (isLinkToFileIntroducedByPR(link)) {
continue;
Copy link
Contributor

@rsimha rsimha Feb 11, 2020

Choose a reason for hiding this comment

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

After restoring all the lines deleted, instead of doing a continue here, maybe you could remove the https://github.com/ampproject/amphtml/blob/master/ prefix from the link (if it exists), normalize the rest of the path, and see if the link resolves correctly file exists in the PR branch?

Edit: Fixed prefix, altered suggested action.

Copy link
Collaborator

@estherkim estherkim left a comment

Choose a reason for hiding this comment

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

So close! :)

@@ -134,9 +135,15 @@ function checkLinksInFile(file) {
}
let containsDeadLinks = false;
for (const {link, status, statusCode} of results) {
// Skip links to files that were introduced by the PR.
// Catch all files that were introduced by the PR.
if (isLinkToFileIntroducedByPR(link)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if the link is a relative path?

Suggested change
if (isLinkToFileIntroducedByPR(link)) {
if (isLinkToFileIntroducedByPR(link) && status == 'dead') {

@estherkim estherkim merged commit f56cdd4 into ampproject:master Feb 20, 2020
@estherkim
Copy link
Collaborator

Merged. Nice job on your first PR @ajwhatson 🎉

robinvanopstal added a commit to jungvonmatt/amphtml that referenced this pull request Feb 24, 2020
* master: (41 commits)
  custom-element: Minor test improvements (ampproject#26923)
  amp-pixel: Minor test improvements (ampproject#26918)
  viewer: Minor test improvements (ampproject#26906)
  dom: Minor test improvements (ampproject#26913)
  amp-action: Support whitelist lookup in AmpDocShadow (ampproject#26684)
  ✨ Update amp-access-scroll (ampproject#26810)
  🚀 Remove doc css and base css from ESM build (ampproject#26889)
  📖 [amp-story-player] Initial docs (ampproject#26606)
  Amp consent restrict fullscreen prod flag (ampproject#26909)
  📖 Clarify SXG duration minimum (ampproject#26890)
  Improve test vendor requests macros (ampproject#26828)
  🚀 Move scroll left and top macros out of url-replacement-impl (ampproject#25594)
  Update consent string maximum size to 200 bytes (ampproject#26741)
  ✨[amp-story-player] Adds tap-to-next/previous story (ampproject#26865)
  update owners file with correct syntax (ampproject#26899)
  amp-sticky-ad: Fix unit test (ampproject#26855)
  Add performance metrics to README (ampproject#26891)
  🐛 Bug fix: check links test (ampproject#26739)
  ✨Idealmedia uniq ad (ampproject#25838)
  📦 Update dependency jsdom to v16.2.0 (ampproject#26591)
  ...
alanorozco added a commit that referenced this pull request Mar 12, 2020
This breaks due to reassigning `const`, introduced in #26739
alanorozco added a commit that referenced this pull request Mar 12, 2020
This breaks due to reassigning `const`, introduced in #26739
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants