Skip to content

Commit 2a2320a

Browse files
authored
Fix: update htmlproofer to ignore new files as broken links (#343)
* Fix: update htmlproofer * Fix:main branch needed * Add new page * Fix: remove bad link but it still has a new page * Fix: speed up with typheus * Fix: ssl 1 * Fix: print out errors * Fix: print out errors * Update _pages/home.md * Update build-site.yml * Removing caching * what happened to the key, buddy?
1 parent 277601b commit 2a2320a

File tree

6 files changed

+100
-68
lines changed

6 files changed

+100
-68
lines changed

.github/workflows/build-site.yml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,22 @@ on:
66
branches:
77
- main
88

9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
913
jobs:
10-
github-pages:
14+
build-site:
1115
runs-on: ubuntu-latest
1216
steps:
1317
- name: Check out the code
1418
uses: actions/checkout@v4
1519

20+
- name: Fetch main
21+
run: |
22+
git fetch origin main --depth 1
23+
git branch
24+
1625
# Use GitHub Actions' cache to shorten build times and decrease load on servers
1726
- name: Use cache to shorten build time
1827
uses: actions/cache@v4
@@ -28,11 +37,26 @@ jobs:
2837
build_only: true
2938
build_dir: _site
3039

31-
- name: Check HTML using htmlproofer
32-
uses: chabad360/htmlproofer@v2
40+
- name: Set up Ruby
41+
uses: ruby/setup-ruby@v1
3342
with:
34-
directory: "_site"
35-
arguments: |
36-
--ignore-urls "https://fonts.googleapis.com,https://fonts.gstatic.com,_site/_posts/README/index.html"
37-
--ignore-files "/.+\/_posts\/README.md"
38-
--ignore-status-codes "0, 200, 403, 429, 503, 999"
43+
ruby-version: 3
44+
- name: Install gems
45+
run: |
46+
gem install html-proofer
47+
gem install typhoeus
48+
49+
- name: Cache HTMLProofer
50+
id: cache-htmlproofer
51+
uses: actions/cache@v4
52+
with:
53+
path: tmp/.htmlproofer
54+
key: ${{ runner.os }}-htmlproofer
55+
56+
- name: Run htmlproofer
57+
run: |
58+
ruby scripts/htmlproofer.rb
59+
ls
60+
61+
- name: Error log
62+
run: cat html_proofer_errors.txt

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ images/full-images/
99
all_contribs.pickle
1010
.vale.ini
1111
styles/*
12+
tmp/*

_pages/home.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ peer-review:
4040
btn_class: btn--inverse
4141
---
4242

43+
4344
{% include feature_row id="mission" type="center" %}
4445

4546
## Peer review of Python software to support open science

_posts/2024-01-03-testme.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
layout: single
3+
title: "CZI Funds pyOpenSci"
4+
excerpt: "CZI has received funding from the Chan Zuckerberg Foundation. Learn more about how this funding will support pyOpenSci over the next 2 years."
5+
author: "Leah Wasser"
6+
permalink: /blog/czi-funds-pyOpenSci-2024.html
7+
header:
8+
overlay_color: "#666"
9+
overlay_filter: 0.6
10+
categories:
11+
- blog-post
12+
- community
13+
toc: true
14+
comments: true
15+
---
16+
17+
i am a new page with a no bad links

scripts/htmlproofer.rb

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
require "html-proofer"
2+
require "typhoeus"
3+
4+
begin
5+
directories = ['../_site']
6+
status_codes = [0, 200, 301, 403, 429, 503, 999]
7+
merge_base = %x(git merge-base origin/main HEAD).chomp
8+
diffable_files = %x(git diff -z --name-only --diff-filter=AC #{merge_base}).split("\0")
9+
diffable_files = diffable_files.select do |filename|
10+
next true if directories.include?(File.dirname(filename))
11+
12+
filename.end_with?(".md")
13+
end.map { |f| Regexp.new(File.basename(f, File.extname(f))) }
14+
15+
# Add urls for it to ignore
16+
diffable_files << %r{^https://fonts\.gstatic\.com.*}
17+
diffable_files << %r{^https://fonts\.googleapis\.com.*}
18+
19+
# Create a file to capture errors
20+
errors = StringIO.new
21+
HTMLProofer.check_directory(
22+
"./_site",
23+
{
24+
ignore_urls: diffable_files,
25+
ignore_status_codes: status_codes,
26+
cache: {
27+
timeframe: {
28+
external: "7d",
29+
internal: "7d"
30+
}
31+
},
32+
typhoeus: {
33+
verbose: false,
34+
ssl_verifyhost: 1
35+
}
36+
}
37+
).run { |message| errors.puts message }
38+
39+
# Write errors to a text file
40+
File.write("html_proofer_errors.txt", errors.string)
41+
42+
rescue StandardError => e
43+
# Print out the error message
44+
puts "An error occurred: #{e.message}"
45+
# Print out backtrace if needed
46+
puts e.backtrace.join("\n")
47+
# Exit with a non-zero status code to indicate failure
48+
exit 1
49+
end

scripts/parse-contributors.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)