Skip to content

Commit

Permalink
✅ Add tests to check links
Browse files Browse the repository at this point in the history
  • Loading branch information
alrra committed Jun 14, 2021
1 parent f5269cb commit ed80705
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/CODE_OF_CONDUCT.md
Expand Up @@ -58,7 +58,7 @@ clarified by project maintainers.
## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior
may be reported by contacting Cătălin Mariș at <alrraa@gmail.com>.
may be reported by contacting Cătălin Mariș at <contact@catalinmaris.com>.
All complaints will be reviewed and investigated and will result in a
response that is deemed necessary and appropriate to the circumstances.
The project team is obligated to maintain confidentiality with regard
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/check_links.yml
@@ -0,0 +1,23 @@
# For more information about the configurations used
# in this file, please see the GitHub Actions documentation.
#
# https://docs.github.com/en/actions

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

jobs:
ubuntu:
runs-on: ubuntu-latest
steps:

- name: Checkout repository
uses: actions/checkout@v1

- name: Check links
run: ./tests/check_links.sh

name: Check links

on:
schedule:
- cron: "0 0 * * SAT"
9 changes: 6 additions & 3 deletions .github/workflows/macos.yml
@@ -1,7 +1,7 @@
# For more information about the configurations used
# in this file, please see the GitHub actions documentation.
# in this file, please see the GitHub Actions documentation.
#
# https://help.github.com/en/github/automating-your-workflow-with-github-actions/
# https://docs.github.com/en/actions

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Expand All @@ -16,9 +16,12 @@ jobs:
- name: Install dependencies
run: brew install shellcheck

- name: Run tests
- name: Lint
run: ./tests/shellcheck.sh

- name: Check links
run: ./tests/check_links.sh

name: macOS

on: push
9 changes: 6 additions & 3 deletions .github/workflows/ubuntu.yml
@@ -1,7 +1,7 @@
# For more information about the configurations used
# in this file, please see the GitHub actions documentation.
# in this file, please see the GitHub Actions documentation.
#
# https://help.github.com/en/github/automating-your-workflow-with-github-actions/
# https://docs.github.com/en/actions

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Expand All @@ -13,9 +13,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v1

- name: Run tests
- name: Lint
run: ./tests/shellcheck.sh

- name: Check links
run: ./tests/check_links.sh

name: Ubuntu

on: push
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -185,7 +185,7 @@ The code is available under the [MIT license][license].
[preferences ubuntu]: src/os/preferences/ubuntu
[repo]: https://github.com/alrra
[setup macos]: https://cloud.githubusercontent.com/assets/1223565/19314446/cd89a592-90a2-11e6-948d-9d75247088ba.gif
[setup script]: https://github.com/alrra/dotfiles/blob/2f53485df6be75d207d4c5c03c265730b416555a/src/os/setup.sh#L3
[setup script]: https://github.com/alrra/dotfiles/blob/main/src/os/setup.sh#L3
[setup ubuntu]: https://user-images.githubusercontent.com/1223565/101978032-d0791a80-3c06-11eb-8870-661d0eb3f543.gif
[setup]: src/os/setup.sh
[shell]: src/shell
Expand Down
41 changes: 41 additions & 0 deletions tests/check_links.sh
@@ -0,0 +1,41 @@
#!/bin/bash

cd "$(dirname "${BASH_SOURCE[0]}")" \
&& . "../src/os/utils.sh"

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

check_links() {

local MARKDOWN_FILES=$( \
find .. \
-name "*.md" \
-not -path "../node_modules/*" \
-not -path "../src/vim/vim/*"
);

local exitCode=0

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

for file in $MARKDOWN_FILES; do
npx markdown-link-check --quiet --retry "$file" \
|| exitCode=1
done

return $exitCode

}

main() {

if ! cmd_exists "npx"; then
print_error "'npx' command is not available."
return 1
fi

check_links

}

main

0 comments on commit ed80705

Please sign in to comment.