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

add link_checker #1347

Merged
merged 9 commits into from
Feb 1, 2021
Merged

Conversation

priyanshuone6
Copy link
Member

@priyanshuone6 priyanshuone6 commented Jan 27, 2021

Description

Added workflow to test urls in the docs
Referred this

Testing

Tested this workflow locally using nektos/act

snapshot

Fixes #719

Type of change

Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.

  • New feature (non-breaking change which adds functionality)
  • Optimization (back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)

Key checklist:

  • No style issues: $ flake8
  • All tests pass: $ python run-tests.py --unit
  • The documentation builds: $ cd docs and then $ make clean; make html

You can run all three at once, using $ python run-tests.py --quick.

Further checks:

  • Code is commented, particularly in hard-to-understand areas
  • Tests added that prove fix is effective or that feature works

@codecov
Copy link

codecov bot commented Jan 27, 2021

Codecov Report

Merging #1347 (b789f5b) into develop (f8b58f2) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1347   +/-   ##
========================================
  Coverage    98.15%   98.15%           
========================================
  Files          272      272           
  Lines        15577    15577           
========================================
  Hits         15289    15289           
  Misses         288      288           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f8b58f2...389893c. Read the comment docs.

Copy link
Member

@valentinsulzer valentinsulzer left a comment

Choose a reason for hiding this comment

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

Thanks @priyanshuone6 ! Did you run this locally (adding a known broken link) to check whether it does pick up broken links? I am slightly surprised that there aren't any broken links, though of course it's possible that we got lucky

Comment on lines 19 to 20
use-quiet-mode: 'yes'
use-verbose-mode: 'yes'
Copy link
Member

Choose a reason for hiding this comment

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

these two options seem contradictory?

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind, I read the link you shared now. Can you leave quiet mode off so that we can check each file has been checked?

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, they both are quite contradictory, I'll remove the quiet mode.

@priyanshuone6
Copy link
Member Author

I tried to test this workflow locally by using nketos/act and found that when I try to pass more than one extension in file-extension, in our case it's .rst and .md, it stops checking links and instead passes them as all correct.

@priyanshuone6
Copy link
Member Author

priyanshuone6 commented Jan 28, 2021

I tried using https://github.com/urlstechie/urlchecker-action and found it to be better. It works with different file formats like .py, .rst, .md and it differentiates valid and invalid links using green and red.

@valentinsulzer
Copy link
Member

Ok great. Would be good to also test the notebooks (.ipynb)

@tlestang
Copy link
Contributor

Thanks @priyanshuone6 , I tried that workflow on my fork and I noticed the output from url_checker doesn't display colors, see https://github.com/tlestang/PyBaMM/runs/1782502527?check_suite_focus=true
This makes it impossible to separate valid links from broken links.

Another thing is that urls embedded links in SVG inside notebooks are picked up, but with a trailing backslash.
Example

/github/workspace/examples/notebooks/solution-data-and-processed-variables.ipynb 
 --------------------------------------------------------------------------------
https://matplotlib.org/
http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\
http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\
http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\
http://www.w3.org/1999/xlink\
http://www.w3.org/1999/02/22-rdf-syntax-ns#\

Could you maybe specify the exclude_patterns option to exclude such links for the search?

@priyanshuone6
Copy link
Member Author

@tlestang I searched about it and found that github actions do not currently support colors, but in the end, we do get all the invalid links together, look at line 1126
I will look into the embedded links in SVG and try to fix them using exclude pattern.

@valentinsulzer
Copy link
Member

This seems to be working now with a manageable number of broken links reported. Weirdly, some of the broken links seem to work fine, so I don't know why URL-checker is reporting they are broken. Let me know if you need help finding working links to replace the broken ones with

@valentinsulzer
Copy link
Member

You can ignore the failing benchmarks test. @tlestang can we exclude that test when it comes from a fork?

@priyanshuone6
Copy link
Member Author

Some urls starting with https://github.com/pybamm-team/PyBaMM/pull/ in CHANGELOG.md are being marked as invalid, I tested with different timeout settings to mark as many links valid as it can, and found 10 seconds to be perfect in terms of time and number of links.
Should I include https://github.com/pybamm-team/PyBaMM/pull/ in exclude_patterns or maybe exclude the whole CHANGELOG.md?
Also, should I remove the option to run this workflow in pull requests because every time someone will make a PR, and if it fails due to these unavoidable reasons, a red cross will appear in the PR due to that and it may confuse others?

@valentinsulzer
Copy link
Member

Yes, perhaps the way to go is to only run the url check on the cron job. The odds of someone adding a broken link are very low, what usually happens is a link changes and we don't update it because (until now) there was no automatic way of checking all the links. That way, you can also increase the timeout and it doesn't matter if the cron job takes a while. I wouldn't be totally against excluding CHANGELOG.md either since it is usually pretty easy to see if those links are broken.

However, there are some links here that are actually broken and need to be fixed before this branch can be merged. Most of them are from changes to pybamm branch names or file structure and it should be fairly easy to find where the file is now (e.g. control+p in VSCode)

@priyanshuone6
Copy link
Member Author

@valentinsulzer
Copy link
Member

Copy link
Member

@valentinsulzer valentinsulzer left a comment

Choose a reason for hiding this comment

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

Thanks! If all the broken links are fixed (can't see the test now) then I am happy to merge once the other tests pass

@priyanshuone6
Copy link
Member Author

I have changed the timeout back to 10 seconds, I observed that making it 20 seconds adds more valid links in the "not pass" category.
Please check this for the output

@valentinsulzer valentinsulzer merged commit 61122d9 into pybamm-team:develop Feb 1, 2021
@valentinsulzer
Copy link
Member

@all-contributors add @priyanshuone6 for tests

@allcontributors
Copy link
Contributor

@tinosulzer

I've put up a pull request to add @priyanshuone6! 🎉

@priyanshuone6 priyanshuone6 deleted the link_checker branch February 4, 2021 05:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test links in docs
3 participants