Skip to content

Commit

Permalink
Add aws.amazon.com and cloud.google.com to ignore list. Ignore now al…
Browse files Browse the repository at this point in the history
…so applied to anchors
  • Loading branch information
JohnTurnerNIH committed Sep 18, 2024
1 parent bbbc543 commit 8dfe920
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ jobs:
run: |
python3 ${GITHUB_WORKSPACE}/reusable-workflow-repo/.github/workflows/check_links.py
env:
LINK_IGNORE_LIST: https://www.sciencedirect.com,https://portlandpress.com
LINK_IGNORE_LIST: https://www.sciencedirect.com,https://portlandpress.com,cloud.google.com,aws.amazon.com
PAT: ${{ secrets.PAT }}
30 changes: 19 additions & 11 deletions .github/workflows/check_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,36 +97,44 @@ def add_link(loc,link):
# store where the link is so we can fix it
link_file_map[link_stripped] = loc
def check_link(link):
#should we ignore the failure
ignore = False
# try and get the url, if its 404 or 500 then its invalid, let us know and trigger the error flag
code = getResponseCode(link)
loc =link_file_map[link]
# If the link failed, but we are ignoring it then just mention that
for ignored_link in link_ignore_list:
if ignored_link in link:
ignore = True
break
if code[0] in [404, 403, 500]:

# If the link failed, but we are ignoring it then just mention that
for ignored_link in link_ignore_list:
if ignored_link in link:
print(
loc + ", " + link + ", Ignored")
return False

if ignore:
print(
loc + " , " + link + " , Ignored")
return False
# print(file+" Code:"+str(code[0])+" Line "+str(line_num)+"("+str(char)+"):"+item_stripped)
print(
loc + ", " + link + ", Failed")
loc + " , " + link + " , Failed")
return True

# check for missing anchors
elif "#" in link and \
code[1] is not None \
and 'href=\"' + link[link.find("#"):] + '\"' not in \
code[1]:
if ignore:
print(
loc + ", " + link + ", Ignored")
return False
print(
loc + ", " + link + ", Failed - Anchor")
loc + " , " + link + " , Failed - Anchor")
return True
# print(file + " Missing Anchor Line " + str(
# line_num) + "(" + str(
# char) + "):" + item_stripped)
elif print_valid:
print(
loc + ", " + link + ", Valid")
loc + " , " + link + " , Valid")
return True


Expand Down

0 comments on commit 8dfe920

Please sign in to comment.