:white_check_mark: Validate links in awesome projects
:white_check_mark: Validate links in awesome projects
Verify links in awesome projects
awesome_bot checks for valid URLs in a file, it can be used to verify pull requests updating a README.
$ gem install awesome_bot…You can check multiple files (comma separated or * pattern, look below for details).
By default, duplicate URLs or any status code other than 200 are flagged as failures.
--allow-dupe to allow duplicates.--allow-redirect to allow redirects.--allow to allow specific status code errors.--white-list (-w for short) to prevent links from being flagged: -w domain1.com/post/article,domain2.com white lists domain1.com/post/article and all links matching domain2.com.………If you do not want to install Ruby or its dependencies you can simply use Docker and Docker image.
Here is an example for checking the links in the Markdown files in your current directory/subdirectories:
docker run -ti --rm -v $PWD:/mnt:ro dkhamsing/awesome_bot --white-list "test.com" --allow-dupe --allow-redirect --skip-save-results `find . -name "*.md"`or just check the links in a single file located at ./templates/ubuntu.md:
docker run -ti --rm -v $PWD:/mnt:ro dkhamsing/awesome_bot --allow-dupe --allow-redirect --skip-save-results ./templates/ubuntu.mdYou always need to specify the path to the file so you cannot simply use *.md; instead use ls *.md":
docker run -ti --rm -v $PWD:/mnt:ro dkhamsing/awesome_bot --white-list "test.com" --allow-dupe --allow-redirect --skip-save-results `ls *.md`irb(main):001:0> require 'awesome_bot'
=> true
irb(main):002:0> content = File.read 'README.md'
=> "..."
irb(main):003:0> result = AwesomeBot.check content
=> #
# AwesomeBot Result with success, statuses_issues, dupes and more
irb(main):004:0> puts result.success ? 'No errors' : ':-('
:-(More information at rubydoc.
Does your GitHub README contain a lot of links? awesome_bot can help you validate them when a pull request is created (or a commit is pushed). It is used by:
and more.
Tips
To use awesome_bot with GitHub Actions (workflows), here is an example:
name: Ruby
on:
push:
branches: [ '*' ]
pull_request:
branches: [ '*' ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Ruby 2.6
uses: ruby/setup-ruby@v1
with:
ruby-version: '2.6'
- name: Checks
run: |
gem install awesome_bot
awesome_bot check-unique.txt --allow-ssl -a 302,429 -w xbmc/xbmcTo use awesome_bot with Travis CI, connect your repo and create a .travis.yml file.
language: ruby
rvm: 2.4.1
before_script: gem install awesome_bot
script: awesome_bot README.mdTo turn off email notifications, add the lines below
notifications:
email: falseIn case you want to use the docker image inside Travis CI follow this example which will check broken links in all *.md files in your repository:
sudo: required
services:
- docker
script:
# Link Checks
- docker run -ti --rm -v $PWD:/mnt:ro dkhamsing/awesome_bot --allow-dupe --allow-redirect --skip-save-results `find . -name "*.md"`CircleCI, Codeship, and Semaphore CI support running tests without adding a file to the repo (a public configuration file can however help others contribute).
# Codeship
Setup
rvm use 2.4.1 --install
gem install awesome_bot
Test
awesome_bot README.md# Semaphore CI
Language: Ruby
Ruby version: 2.4.1
Databases for: don't generate
Setup:
gem install awesome_bot
awesome_bot README.mdTo add the Travis CI build status badge above to your project, use the following code
i.e.As it happens, the default code snippet provided contains a redirect so adding a badge could fail your status :sob:.. one way to fix this is to white list travis-ci, i.e.
- awesome_bot README.md --white-list travis-ciYou can also add a badge for other CI tools, check out .
Integrate awesome_bot with Danger and have results reported back to the pull request.
Here's the step in your Dangerfile:
# Check links
require 'json'
results = File.read 'ab-results-README.md-markdown-table.json'
j = JSON.parse results
if j['error']==true
fail j['title']
markdown j['message']
endThis project is available under the MIT license. See the LICENSE file for more info.
No open issues yet, or sync has not completed.