Skip to content

Commit eb3584d

Browse files
committed
Add broken link check: scheduled and pr
Signed-off-by: peppi-lotta <[email protected]>
1 parent 35cfa9e commit eb3584d

File tree

6 files changed

+126
-15
lines changed

6 files changed

+126
-15
lines changed

.github/workflows/pr-link-check.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Check Links In Pull Requests
2+
3+
on:
4+
pull_request:
5+
types: [opened, edited, reopened, synchronize, ready_for_review]
6+
workflow_call:
7+
8+
permissions: {}
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
check-links-pr:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Clone repository
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
with:
22+
fetch-depth: 0
23+
ref: ${{github.event.pull_request.head.ref}}
24+
repository: ${{github.event.pull_request.head.repo.full_name}}
25+
26+
- name: Checkout base branch
27+
run: git checkout ${{ github.event.pull_request.base.ref }}
28+
29+
- name: Get list of changed Markdown files
30+
id: changed-files
31+
run: |
32+
git diff --name-only origin/${{ github.event.pull_request.base.ref }}...${{ github.head_ref }} -- '*.md' > changed-files.txt
33+
cat changed-files.txt
34+
if [ -s changed-files.txt ]; then
35+
echo "Changed md files found"
36+
echo "foundFiles=true" >> $GITHUB_ENV
37+
fi
38+
39+
- name: Switch to PR branch
40+
run: git checkout ${{ github.head_ref }}
41+
42+
- name: Check links in changed files
43+
if: env.foundFiles == 'true'
44+
uses: lycheeverse/lychee-action@f796c8b7d468feb9b8c0a46da3fac0af6874d374 # v2.2.0
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
with:
48+
failIfEmpty: false
49+
args: |
50+
--no-progress
51+
--github-token
52+
$(cat changed-files.txt | tr '\n' ' ')
53+
54+
- name: Provide helpful failure message
55+
if: failure()
56+
run: |
57+
echo "::error::Link check failed! Please review the broken links reported above."
58+
echo ""
59+
echo "If certain links are valid but fail due to:"
60+
echo "- CAPTCHA challenges"
61+
echo "- IP blocking"
62+
echo "- Authentication requirements"
63+
echo "- Rate limiting"
64+
echo ""
65+
echo "Consider adding them to .lycheeignore to bypass future checks."
66+
echo "Format: Add one URL pattern per line"
67+
exit 1
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Scheduled Check Links
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: "0 0 1 * *"
7+
repository_dispatch:
8+
# run manually
9+
types: [check-links]
10+
workflow_call:
11+
12+
permissions: {}
13+
14+
jobs:
15+
check-links:
16+
runs-on: ubuntu-latest
17+
18+
permissions:
19+
contents: read
20+
issues: write
21+
22+
steps:
23+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
25+
- name: Link Checker
26+
id: linkcheck
27+
uses: lycheeverse/lychee-action@f796c8b7d468feb9b8c0a46da3fac0af6874d374 # v2.2.0
28+
with:
29+
args: |
30+
--user-agent "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:135.0) Gecko/20100101 Firefox/135.0"
31+
--root-dir "$(pwd)/"
32+
--fallback-extensions "md"
33+
"./**/*.md"
34+
output: /tmp/lychee_output.md
35+
fail: false
36+
37+
- name: Create Issue From File
38+
if: steps.linkcheck.outputs.exit_code != 0
39+
uses: peter-evans/create-issue-from-file@e8ef132d6df98ed982188e460ebb3b5d4ef3a9cd # v5.0.1
40+
with:
41+
title: Link Checker Report
42+
content-filepath: /tmp/lychee_output.md
43+
labels: |
44+
kind/bug

.lycheeignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
https://jenkins.nordix.org/log/GHPRB/
2+
https://jenkins.nordix.org/ghprbhook/
3+
https://prow.apps.test.metal3.io/hook

jenkins/README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ easier in certain cases:
5555
commenting:
5656
* **/cherry-pick release-x.y** where `release-x.y` is any supported release
5757
branch, where the backport PR will be opened by the
58-
[cherry picker bot](https://github.com/metal3-cherrypick-bot).
58+
[metal3-io-bot](https://github.com/metal3-io-bot).
5959
1. `transfer-issue` plugin can be used for transferring issues across
6060
repositories in the same GitHub organization by commenting:
6161
* **/transfer-issue target-repo-name** on the issue. One simple example
@@ -72,7 +72,7 @@ branch to be able to open a PR against it in the future.
7272
## Cloud Resources cleanup
7373

7474
There is a Jenkins
75-
[main job](https://jenkins.nordix.org/view/Metal3%20Periodic/job/metal3_daily_main_integration_tests_cleanup/)
75+
[main job](https://jenkins.nordix.org/view/Metal3%20Periodic/job/metal3_periodic_resource_cleanup/)
7676
that cleans up all the leftover VMs from [CityCloud](https://www.citycloud.com/)
7777
every 6 hours which has failed to be deleted at the end of v1alphaX/v1betaX
7878
integration tests.
@@ -91,7 +91,7 @@ trusted.
9191
Pods, CRDs logs are collected at the end of each Jenkins job run and
9292
archived so that they can be later used for debugging purposes. You can
9393
find the archived logs under the "*Build artifacts*" section of the
94-
[job](https://jenkins.nordix.org/view/Metal3/job/metal3_bmo_main_integration_test_ubuntu/).
94+
[job](https://jenkins.nordix.org/view/Metal3%20Periodic/job/metal3-periodic-centos-e2e-integration-test-main/).
9595
Please note that the logs will be removed 30 days after creation or after 100
9696
subsequent job runs, whichever occurs first.
9797

@@ -132,15 +132,14 @@ stored in
132132
[metal3-io/project-infra](https://github.com/metal3-io/project-infra/tree/main/jenkins/jobs)
133133
repository. In a nutshell, pipelines defines sequence of steps to be executed.
134134
Each step can run a script or perform something else. For example,
135-
[integration_tests.pipeline](https://github.com/metal3-io/project-infra/blob/main/jenkins/jobs/integration_tests.pipeline)
135+
[dev_env_integration_tests.pipeline](https://github.com/metal3-io/project-infra/blob/main/jenkins/jobs/dev_env_integration_tests.pipeline)
136136
executes following scripts:
137137

138-
1. [clones](https://github.com/metal3-io/project-infra/blob/0a6cc3f9f8592914a316c27ea2411ccb48aba7c3/jenkins/jobs/integration_tests.pipeline#L65)
138+
1. [clones](https://github.com/metal3-io/project-infra/blob/1e8d2111a33dc95134b6f546d76f19be4a637e3d/jenkins/jobs/dev_env_integration_tests.pipeline#L56)
139139
git repository
140-
1. [jenkins/scripts/integration_test.sh](https://github.com/metal3-io/project-infra/blob/main/jenkins/scripts/integration_test.sh)
141-
1. [jenkins/scripts/fetch_logs.sh](https://github.com/metal3-io/project-infra/blob/main/jenkins/scripts/fetch_logs.sh)
142-
1. [jenkins/scripts/integration_test_clean.sh](https://github.com/metal3-io/project-infra/blob/main/jenkins/scripts/integration_test_clean.sh)
143-
1. [jenkins/scripts/integration_delete.sh](https://github.com/metal3-io/project-infra/blob/main/jenkins/scripts/integration_delete.sh)
140+
1. [jenkins/scripts/dynamic_worker_workflow/dev_env_integration_tests.sh](https://github.com/metal3-io/project-infra/blob/main/jenkins/scripts/dynamic_worker_workflow/dev_env_integration_tests.sh)
141+
1. [jenkins/scripts/dynamic_worker_workflow/fetch_logs.sh](https://github.com/metal3-io/project-infra/blob/main/jenkins/scripts/dynamic_worker_workflow/fetch_logs.sh)
142+
1. [jenkins/scripts/dynamic_worker_workflow/run_clean.sh](https://github.com/metal3-io/project-infra/blob/main/jenkins/scripts/dynamic_worker_workflow/run_clean.sh)
144143

145144
### GitHub Pull Request Builder, a.k.a. ghprb
146145

jenkins/scripts/bare_metal_lab/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ the same host and interfere with each other. This means that if there is already
3333
one build job running in the BML, a new one will not start before the first has
3434
finished. Github won't show the usual *Details* link for this specific run but
3535
build status can be checked from the
36-
[Jenkins dashboard](https://jenkins.nordix.org/job/metal3_metal3io_project_infra_bml_integration_tests_centos/)
36+
[Jenkins dashboard](https://jenkins.nordix.org/job/metal3-bml-integration-test-centos/)
3737
where the build will be scheduled and stay in pending at this time.
3838
Once the build starts, the status will be updated with a link.

prow/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@ instance:
4949
Prow.
5050

5151
In addition to this, we rely on a GitHub bot account
52-
([metal3-io-bot](https://github.com/metal3-io-bot), owner of the GitHub token)
53-
and a separate GitHub bot
54-
[metal3-cherrypick-bot](https://github.com/metal3-cherrypick-bot), for cherry
55-
picking pull requests. A webhook must be configured in GitHub to send events to
56-
Prow and a DNS record must be configured so that
52+
([metal3-io-bot](https://github.com/metal3-io-bot), owner of the GitHub token).
53+
A webhook must be configured in GitHub to
54+
send events to Prow and a DNS record must be configured so that
5755
<https://prow.apps.test.metal3.io> points to the IP where Prow can be accessed.
5856

5957
The DNS records are managed by CNCF for us. Any changes to them can be done

0 commit comments

Comments
 (0)