Skip to content

Commit 89a9db1

Browse files
authored
ci: add periodic link check lychee (#733)
# Summary This updates the pre-commit hooks and adds a periodic link check against a set of urls. It deprecates the use of markdownlinkchecker in favour of lychee. - [x] First, we add the a job be run daily which uses lychee to check the links present in a series of pages under a given root. - [x] Next, we remove the existing link checker periodic actions. Subsequent PRs can enable opening issues with results of broken links. Other changes: - remove check-spelling action: conflcits with cspell, not available in megalinter via pre-commit, is a source of unnecessary toil. - Remove links to community.egi.eu to show that lychee is actually doing its job - Remove unnused packages in `package.json` which seemed to be included for potential testing activities which were never done. This addresses several critical vulnerabilities identified by github (but which we are not actually exposed by). --- **Related issue :** Closed #157 --------- Signed-off-by: Bruce Becker <bruce.becker@egi.eu>
1 parent cab16eb commit 89a9db1

23 files changed

Lines changed: 1120 additions & 4546 deletions

.cspell.json

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

.cspell.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
language: "en-gb"
3+
dictionaries:
4+
- custom-words
5+
ignorePaths:
6+
- ".github/actions/**"
7+
- ".cspell.json"
8+
dictionaryDefinitions:
9+
- name: custom-words
10+
path: ./.github/actions/spelling/expect.txt
11+
addWords: true

.github/CODE_OF_CONDUCT.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ and orientation.
3232

3333
## Our Standards
3434

35-
Examples of behavior that contributes to creating a positive environment
35+
Examples of behaviour that contributes to creating a positive environment
3636
include:
3737

3838
- Using welcoming and inclusive language
@@ -41,7 +41,7 @@ include:
4141
- Focusing on what is best for the community
4242
- Showing empathy towards other community members
4343

44-
Examples of unacceptable behavior by participants include:
44+
Examples of unacceptable behaviour by participants include:
4545

4646
- The use of sexualized language or imagery and unwelcome sexual attention or
4747
advances
@@ -55,13 +55,13 @@ Examples of unacceptable behavior by participants include:
5555
## Our Responsibilities
5656

5757
Project maintainers are responsible for clarifying the standards of acceptable
58-
behavior and are expected to take appropriate and fair corrective action in
59-
response to any instances of unacceptable behavior.
58+
behaviour and are expected to take appropriate and fair corrective action in
59+
response to any instances of unacceptable behaviour.
6060

6161
Project maintainers have the right and responsibility to remove, edit, or reject
6262
comments, commits, code, wiki edits, issues, and other contributions that are
6363
not aligned to this Code of Conduct, or to ban temporarily or permanently any
64-
contributor for other behaviors that they deem inappropriate, threatening,
64+
contributor for other behaviours that they deem inappropriate, threatening,
6565
offensive, or harmful.
6666

6767
## Scope
@@ -75,8 +75,8 @@ further defined and clarified by project maintainers.
7575

7676
## Enforcement
7777

78-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
79-
reported by contacting the EGI Foundation team at contact@egi.eu. The team will
78+
Instances of abusive, harassing, or otherwise unacceptable behaviour may be
79+
reported by contacting the EGI Foundation team at <contact@egi.eu>. The team will
8080
review and investigate all complaints, and will respond in a way that it deems
8181
appropriate to the circumstances. The team is obligated to maintain
8282
confidentiality with regard to the reporter of an incident. Further details of

.github/actions/spelling/excludes.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# See https://github.com/check-spelling/check-spelling/wiki/Configuration-Examples:-excludes
2-
# Ignore some docsy-realted folders
2+
# Ignore some docsy-related folders
33
^archetypes/
44
^assets/
55
^themes/
66
^layouts/
77
^public/
88
^static/
99
^resources/
10-
^\.github/
10+
^\.github/workflows
1111
^\.gitmodules
1212
CODEOWNERS
1313
AUTHORS

.github/actions/spelling/expect.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
ADFS
22
allowfullscreen
33
autoplay
4+
autoprefixer
45
checkin
56
creds
67
csr
78
CVMFS
9+
CYFRONET
10+
DataHub
811
dearmor
912
delims
1013
dependant
1114
diracsgm
15+
docsy
1216
findstr
17+
flox
1318
galdyn
1419
gecos
1520
geodata
@@ -22,12 +27,22 @@ Initialising
2227
jscpd
2328
jwt
2429
ligo
30+
linter
31+
linters
2532
lsb
2633
markdownlint
2734
mega
35+
megalinter
2836
mytoken
2937
mytokens
3038
newkey
39+
Oneclient
40+
Oneclients
41+
Onedata
42+
Oneprovider
43+
Oneproviders
44+
Onezone
45+
Onezones
3146
pem
3247
pheno
3348
pravda

.github/workflows/check-links.yml

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

.github/workflows/deploy_pr_preview.yml

Lines changed: 172 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
name: Deploy pull request preview
33
# Setup and build files with hugo
4+
# cspell:disable-next-line
45
# https://github.com/peaceiris/actions-hugo
56
# Deploy to GitHub pages
67
# https://github.com/peaceiris/actions-gh-pages
@@ -56,7 +57,7 @@ jobs:
5657
echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
5758
5859
- name: Deploy Pull Request preview
59-
uses: peaceiris/actions-gh-pages@v4
60+
uses: peaceiris/actions-gh-pages@v4 # # cspell:disable-line
6061
with:
6162
# Use GITHUB_TOKEN allowing to write to local repository
6263
github_token: ${{ secrets.GITHUB_TOKEN }}
@@ -66,7 +67,7 @@ jobs:
6667
publish_branch: pr_previews
6768
# Source directory
6869
publish_dir: ./${{ steps.extract.outputs.pr_number }}/
69-
# Destitnation directory
70+
# Destination directory
7071
destination_dir: ${{ steps.extract.outputs.pr_number }}
7172
# Reuse PR commit message
7273
commit_message: ${{ github.event.head_commit.message }}
@@ -86,3 +87,172 @@ jobs:
8687
repo: context.repo.repo,
8788
body: output
8889
})
90+
check_preview_links_users:
91+
env:
92+
BASE_URL: https://docs.egi.eu/documentation/users
93+
runs-on: ubuntu-latest
94+
needs:
95+
- deploy_pr_preview
96+
if: >
97+
github.event.workflow_run.event == 'pull_request' &&
98+
github.event.workflow_run.conclusion == 'success'
99+
strategy:
100+
matrix:
101+
# This matrix is built from the directories in content/en/users
102+
url:
103+
- "aai"
104+
- "compute"
105+
- "data"
106+
- "dev-env"
107+
- "getting-started"
108+
# - "machine-learning" # currently in draft
109+
- "security"
110+
- "training"
111+
- "tutorials"
112+
# cspell:disable
113+
name: Check links of preview
114+
steps:
115+
- name: Checkout configuration
116+
uses: actions/checkout@v4
117+
- name: Get tools
118+
# We will run hakrawler to crawl a page and sub-pages
119+
# Then use lychee to check whether the urls in that page are ok.
120+
run: |
121+
curl -fSL https://github.com/lycheeverse/lychee/releases/download/lychee-v0.19.1/lychee-x86_64-unknown-linux-musl.tar.gz | tar xvfz -> lychee
122+
go install github.com/hakluke/hakrawler@latest
123+
- name: Extract links and check them.
124+
# This passes a given endpoint to hakrawler, which gets all of the links
125+
# in it up to a depth of 10 (-d) and without crawling back up the tree (-i)
126+
# and returning only unique (-u) urls.
127+
# The urls are then parsed via jq to get only hrefs, no scripts
128+
# and the resulting list is sent to lyuchee via stdin (-)
129+
# to see if there are any bad links in those pages
130+
run: >-
131+
echo "https://docs.egi.eu/documentation/${{
132+
job.deploy_pr_preview.outputs.pr_number }}/users/${{ matrix.url }}" |
133+
hakrawler -u -i -d 10 -json |
134+
jq -r '. |
135+
select(.Source == "href") | .URL' |
136+
lychee -
137+
check_preview_links_internal:
138+
env:
139+
BASE_URL: https://docs.egi.eu/documentation/internal
140+
runs-on: ubuntu-latest
141+
needs:
142+
- deploy_pr_preview
143+
if: >
144+
github.event.workflow_run.event == 'pull_request' &&
145+
github.event.workflow_run.conclusion == 'success'
146+
strategy:
147+
matrix:
148+
# This matrix is built from the directories in content/en/users
149+
url:
150+
- "accounting"
151+
- "collaboration-tools"
152+
- "configuration-database"
153+
- "getting-started"
154+
- "guidelines-software-development"
155+
- "helpdesk" # cspell:disable-line
156+
- "messaging"
157+
- "monitoring"
158+
- "operations-portal"
159+
- "security-coordination"
160+
# cspell:disable
161+
name: Check links of preview
162+
steps:
163+
- name: Checkout configuration
164+
uses: actions/checkout@v4
165+
- name: Get tools
166+
# We will run hakrawler to crawl a page and sub-pages
167+
# Then use lychee to check whether the urls in that page are ok.
168+
run: |
169+
curl -fSL https://github.com/lycheeverse/lychee/releases/download/lychee-v0.19.1/lychee-x86_64-unknown-linux-musl.tar.gz | tar xvfz -> lychee
170+
go install github.com/hakluke/hakrawler@latest
171+
- name: Extract links and check them.
172+
# This passes a given endpoint to hakrawler, which gets all of the links
173+
# in it up to a depth of 10 (-d) and without crawling back up the tree (-i)
174+
# and returning only unique (-u) urls.
175+
# The urls are then parsed via jq to get only hrefs, no scripts
176+
# and the resulting list is sent to lyuchee via stdin (-)
177+
# to see if there are any bad links in those pages
178+
run: >-
179+
echo "https://docs.egi.eu/documentation/${{
180+
job.deploy_pr_preview.outputs.pr_number }}/internal/${{ matrix.url }}"
181+
|
182+
hakrawler -u -i -d 10 -json |
183+
jq -r '. |
184+
select(.Source == "href") | .URL' |
185+
lychee -
186+
check_preview_links_providers:
187+
env:
188+
BASE_URL: https://docs.egi.eu/documentation/providers
189+
runs-on: ubuntu-latest
190+
needs:
191+
- deploy_pr_preview
192+
if: >
193+
github.event.workflow_run.event == 'pull_request' &&
194+
github.event.workflow_run.conclusion == 'success'
195+
strategy:
196+
matrix:
197+
# This matrix is built from the directories in content/en/users
198+
url:
199+
- "check-in"
200+
- "cloud-compute"
201+
- "datahub" # cspell:disable-line
202+
- "high-throughput-compute"
203+
- "joining"
204+
- "notebooks"
205+
- "online-storage"
206+
- "operations-manuals"
207+
- "rod"
208+
# cspell:disable
209+
name: Check links of preview
210+
steps:
211+
- name: Checkout configuration
212+
uses: actions/checkout@v4
213+
- name: Get tools
214+
# We will run hakrawler to crawl a page and sub-pages
215+
# Then use lychee to check whether the urls in that page are ok.
216+
run: |
217+
curl -fSL https://github.com/lycheeverse/lychee/releases/download/lychee-v0.19.1/lychee-x86_64-unknown-linux-musl.tar.gz | tar xvfz -> lychee
218+
go install github.com/hakluke/hakrawler@latest
219+
- name: Extract links and check them.
220+
# This passes a given endpoint to hakrawler, which gets all of the links
221+
# in it up to a depth of 10 (-d) and without crawling back up the tree (-i)
222+
# and returning only unique (-u) urls.
223+
# The urls are then parsed via jq to get only hrefs, no scripts
224+
# and the resulting list is sent to lyuchee via stdin (-)
225+
# to see if there are any bad links in those pages
226+
run: >-
227+
echo "https://docs.egi.eu/documentation/${{
228+
job.deploy_pr_preview.outputs.pr_number }}/providers/${{ matrix.url
229+
}}" |
230+
hakrawler -u -i -d 10 -json |
231+
jq -r '. |
232+
select(.Source == "href") | .URL' |
233+
lychee -
234+
lychee-otherdocs: # cspell:disable-line
235+
env:
236+
BASE_URL: https://docs.egi.eu/
237+
name: Check links at base of the about pages
238+
strategy:
239+
matrix:
240+
url:
241+
- ""
242+
- about
243+
- support
244+
runs-on: ubuntu-latest
245+
steps:
246+
- name: Checkout code
247+
uses: actions/checkout@v4
248+
249+
- name: Get tools
250+
# On the "other" page, we do not want to crawl down, so we only use
251+
# lyuchee to check the page itself.
252+
run: |
253+
curl -fSL https://github.com/lycheeverse/lychee/releases/download/lychee-v0.19.1/lychee-x86_64-unknown-linux-musl.tar.gz | tar xvfz -> lychee
254+
- name: Check Links.
255+
run:
256+
lychee https://docs.egi.eu/documentation/${{
257+
job.deploy_pr_preview.outputs.pr_number }}/${{ matrix.url }}
258+
# cspell:enable

0 commit comments

Comments
 (0)