Skip to content

Commit af8f495

Browse files
authored
DTSPO-17131: Add link checker (#437)
* DTSPO-17131: Add link checker
1 parent a1e55d8 commit af8f495

File tree

13 files changed

+113
-17
lines changed

13 files changed

+113
-17
lines changed

.github/actions/spelling/allow.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,9 @@ snyk
287287
CFTSBOX
288288
nonprod
289289
plpgsql
290+
afm
291+
bigdecimal
292+
ethon
293+
gsub
294+
ttfunk
295+
zeitwerk

.github/workflows/deploy.yaml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,9 @@ jobs:
2121
cspell:software-terms/dict/softwareTerms.txt
2222
cspell:npm/dict/npm.txt
2323
cspell:node/dict/node.txt
24-
# cspell:cpp/src/cpp.txt
25-
# cspell:php/php.txt
26-
# cspell:python/src/python/python-lib.txt
27-
# cspell:software-terms/src/software-tools.txt
28-
# cspell:python/src/python/python.txt
29-
3024
build:
3125
runs-on: ubuntu-latest
32-
name: Deploy
26+
name: 'Build and Test'
3327
steps:
3428
- uses: actions/checkout@v4
3529
- name: Setup Ruby
@@ -40,6 +34,22 @@ jobs:
4034
bundler-cache: true
4135
- name: Build
4236
run: bundle exec middleman build
37+
- name: 'Check for broken links'
38+
run: bundle exec rake check_urls
39+
env:
40+
GH_TOKEN: ${{ secrets.GH_TOKEN }}
41+
publish:
42+
runs-on: ubuntu-latest
43+
needs: build
44+
name: 'Publish Site'
45+
steps:
46+
- uses: actions/checkout@v4
47+
- name: Setup Ruby
48+
uses: ruby/setup-ruby@v1
49+
with:
50+
ruby-version: 3.1.1
51+
architecture: 'x64'
52+
bundler-cache: true
4353
- name: Publish
4454
run: |
4555
rm -rf build

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ gem 'tzinfo-data', platforms: [:mswin, :mingw, :jruby]
1212
gem 'govuk_tech_docs'
1313

1414
gem 'middleman-gh-pages'
15+
gem 'html-proofer'

Gemfile.lock

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,24 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4+
Ascii85 (1.1.0)
45
activesupport (7.0.7.2)
56
concurrent-ruby (~> 1.0, >= 1.0.2)
67
i18n (>= 1.6, < 2)
78
minitest (>= 5.1)
89
tzinfo (~> 2.0)
910
addressable (2.8.4)
1011
public_suffix (>= 2.0.2, < 6.0)
12+
afm (0.2.2)
13+
async (2.10.1)
14+
console (~> 1.10)
15+
fiber-annotation
16+
io-event (~> 1.5, >= 1.5.1)
17+
timers (~> 4.1)
1118
autoprefixer-rails (10.4.13.0)
1219
execjs (~> 2)
1320
backports (3.24.1)
21+
bigdecimal (3.1.7)
1422
chronic (0.10.2)
1523
chunky_png (1.4.0)
1624
coffee-script (2.4.1)
@@ -31,17 +39,25 @@ GEM
3139
compass-import-once (1.0.5)
3240
sass (>= 3.2, < 3.5)
3341
concurrent-ruby (1.2.2)
42+
console (1.23.6)
43+
fiber-annotation
44+
fiber-local
45+
json
3446
contracts (0.17)
3547
dotenv (2.8.1)
3648
em-websocket (0.5.3)
3749
eventmachine (>= 0.12.9)
3850
http_parser.rb (~> 0)
3951
erubis (2.7.0)
52+
ethon (0.16.0)
53+
ffi (>= 1.15.0)
4054
eventmachine (1.2.7)
4155
execjs (2.8.1)
4256
fast_blank (1.0.1)
4357
fastimage (2.2.7)
4458
ffi (1.15.5)
59+
fiber-annotation (0.2.0)
60+
fiber-local (1.0.0)
4561
govuk_tech_docs (3.4.0)
4662
autoprefixer-rails (~> 10.2)
4763
chronic (~> 0.10.2)
@@ -61,10 +77,22 @@ GEM
6177
tilt
6278
hamster (3.0.0)
6379
concurrent-ruby (~> 1.0)
80+
hashery (2.1.2)
6481
hashie (3.6.0)
82+
html-proofer (5.0.8)
83+
addressable (~> 2.3)
84+
async (~> 2.1)
85+
nokogiri (~> 1.13)
86+
pdf-reader (~> 2.11)
87+
rainbow (~> 3.0)
88+
typhoeus (~> 1.3)
89+
yell (~> 2.0)
90+
zeitwerk (~> 2.5)
6591
http_parser.rb (0.8.0)
6692
i18n (1.6.0)
6793
concurrent-ruby (~> 1.0)
94+
io-event (1.5.1)
95+
json (2.7.2)
6896
kramdown (2.4.0)
6997
rexml
7098
listen (3.8.0)
@@ -141,18 +169,26 @@ GEM
141169
padrino-support (0.15.3)
142170
parallel (1.23.0)
143171
parslet (2.0.0)
172+
pdf-reader (2.12.0)
173+
Ascii85 (~> 1.0)
174+
afm (~> 0.2.1)
175+
hashery (~> 2.0)
176+
ruby-rc4
177+
ttfunk
144178
public_suffix (5.0.1)
145179
racc (1.7.0)
146180
rack (2.2.7)
147181
rack-livereload (0.3.17)
148182
rack
183+
rainbow (3.1.1)
149184
rake (13.0.6)
150185
rb-fsevent (0.11.2)
151186
rb-inotify (0.10.1)
152187
ffi (~> 1.0)
153188
redcarpet (3.5.1)
154189
rexml (3.2.5)
155190
rouge (3.30.0)
191+
ruby-rc4 (0.1.5)
156192
sass (3.4.25)
157193
sassc (2.4.0)
158194
ffi (~> 1.9)
@@ -163,19 +199,27 @@ GEM
163199
temple (0.10.2)
164200
thor (1.2.2)
165201
tilt (2.0.11)
202+
timers (4.3.5)
166203
toml (0.3.0)
167204
parslet (>= 1.8.0, < 3.0.0)
205+
ttfunk (1.8.0)
206+
bigdecimal (~> 3.1)
207+
typhoeus (1.4.1)
208+
ethon (>= 0.9.0)
168209
tzinfo (2.0.6)
169210
concurrent-ruby (~> 1.0)
170211
uglifier (3.2.0)
171212
execjs (>= 0.3.0, < 3)
172213
webrick (1.8.1)
214+
yell (2.2.2)
215+
zeitwerk (2.6.13)
173216

174217
PLATFORMS
175218
ruby
176219

177220
DEPENDENCIES
178221
govuk_tech_docs
222+
html-proofer
179223
middleman-gh-pages
180224
tzinfo-data
181225
wdm (~> 0.1.0)

Rakefile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,41 @@
11
require 'middleman-gh-pages'
2+
require 'html-proofer'
23

34
ENV["COMMIT_MESSAGE_SUFFIX"] = "[skip ci]"
45
ENV["BRANCH_NAME"] = "master"
6+
7+
task :check_urls do
8+
proofer = HTMLProofer.check_directory("./build",
9+
{
10+
:check_external_hash => false,
11+
:ignore_missing_alt => true,
12+
:ignore_status_codes => [0, 401, 403],
13+
:ignore_urls => [
14+
# Ignore pulls/branches as these do not translate to raw content
15+
%r{github\.com/hmcts/(?=.*(?:pull|tree|commit))},
16+
# This is a url that's generated each time we build the html by tech-docs-gem but does not exist
17+
%r{https://github.com/hmcts/hmcts.github.io/blob/source/source/search/index.html}
18+
]
19+
})
20+
21+
token = ENV.fetch('GH_TOKEN', nil)
22+
proofer.before_request do |request|
23+
if request.base_url.include?("https://github.com/hmcts/")
24+
request.options[:headers]["Authorization"] = "Bearer #{token}"
25+
base_url_parts = request.base_url.split('/')
26+
# 5 parts is if we're just querying a repo itself - which needs a generic file added to the URl
27+
# to check the repo exists
28+
if base_url_parts.length == 5 && !request.base_url.include?('#')
29+
request.base_url = request.base_url.gsub("github.com", "raw.githubusercontent.com")
30+
# This repo builds from source branch
31+
request.base_url += request.base_url.include?("hmcts.github.io") ? "/source/README.md" : "/master/README.md"
32+
# Checking for blob is to convert URLs pointing to files
33+
elsif request.base_url.include?("/blob/")
34+
request.base_url = request.base_url.gsub("/blob", "")
35+
request.base_url = request.base_url.gsub("github.com", "raw.githubusercontent.com")
36+
end
37+
end
38+
end
39+
# Run HTML Proofer against built HTML files
40+
proofer.run
41+
end

source/cloud-native-platform/asking-for-help/index.html.md.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,5 @@ to help organise discussions and keep related conversations tied to the same con
6969

7070
## Further reading
7171

72-
- [How to Ask for Help on IRC](http://jeff.jones.be/blog/2009/03/17/how-to-ask-for-help-on-irc/)
72+
- [How to Ask for Help on IRC](https://jeff.jones.be/blog/2009/03/17/how-to-ask-for-help-on-irc/)
7373
- [How To Ask And Answer Questions The Smart Way](https://betterfm.org/smart-questions.html)

source/cloud-native-platform/common-pipeline/publishing-libraries/java.html.md.erb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,4 @@ Example: [https://jitpack.io/com/github/hmcts/idam-health-checker/2.2.5](https:/
8888

8989
You can view the different module names by selecting the 'Subproject' drop-down menu on JitPack for the package, make sure you select a version first, see an example for [java-logging 5.1.9](https://jitpack.io/#hmcts/java-logging/5.1.9).
9090

91-
![Subprojects](../images/subprojects.png)
92-
9391
Further information on JitPack can be found at [https://docs.jitpack.io/](https://docs.jitpack.io/).

source/cloud-native-platform/new-component/github-repo.html.md.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Any developer added to [hmcts org](https://github.com/hmcts) is able to create a
2020

2121
_Note: You need to remove the user level admin access you got while creating the repository after you have added your team admins with the admin role._
2222

23-
5. Find or create your Github Team in [Team Onboarding](/cloud-native-platform/onboarding/team/#github-config). Give your team members the following access to the Repo.
23+
5. Find or create your Github Team in [Team Onboarding](/cloud-native-platform/onboarding/team). Give your team members the following access to the Repo.
2424
<table>
2525
<tr>
2626
<th>Github team</th>

source/cloud-native-platform/new-component/gitops-flux.html.md.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ weight: 5
77

88
# <%= current_page.data.title %>
99

10-
One of our principles being <b>Everything as Code</b>, we practise [GitOps](https://www.weave.works/technologies/gitops/) for application deployment to Kubernetes.
10+
One of our principles being <b>Everything as Code</b>, we practice [GitOps](https://go.weave.works/rs/249-YDT-025/images/eBook_ThePracticalGuideToGitOps.pdf) for application deployment to Kubernetes.
1111

1212
- Git as single source of truth.
1313
- Declarative Infrastructure and Application deployment through pull requests.

source/cloud-native-platform/new-component/helm-chart.html.md.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,4 +182,4 @@ Ask on [#platops-help](https://hmcts-reform.slack.com/app_redirect?channel=plato
182182
## All charts
183183

184184
We follow a standard naming convention of `chart-<name>` for all Helm charts, you can find a list of all
185-
charts using [GitHub search](https://github.com/hmcts/?utf8=%25E2%259C%2593&q=chart-&type=&language=).
185+
charts using Github Search in the organisation.

0 commit comments

Comments
 (0)