Skip to content

Commit d6c1c86

Browse files
umbrella (#87)
1 parent 09b08cf commit d6c1c86

File tree

3 files changed

+68
-15
lines changed

3 files changed

+68
-15
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22

33
https://github.com/Consensys/github-actions acts as a single source of truth (sot) for actions that we use
44

5+
# TODO
6+
- Add lint checks on this repo

docs-link-check/action.yml

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ inputs:
88
description: 'default config file.'
99
required: false
1010
default: .github-actions/docs-link-check/config/.linkspector.yml
11-
FAIL_LEVEL:
12-
description: 'exit code for reviewdog when errors are found with severity greater than or equal to this level'
13-
required: false
14-
default: 'any'
15-
FILTER_MODE:
16-
description: 'filtering mode for reviewdog command'
17-
required: false
18-
default: 'nofilter'
1911
runs:
2012
using: "composite"
2113
steps:
@@ -25,11 +17,40 @@ runs:
2517
repository: Consensys/github-actions
2618
path: .github-actions
2719

28-
# also needs reviewdog/action-setup@v1
29-
# reviewdog/action-setup@d8edfce3dd5e1ec6978745e801f9c50b5ef80252
30-
- name: Test links
31-
uses: umbrelladocs/action-linkspector@652f85bc57bb1e7d4327260decc10aa68f7694c3
20+
- name: Read .nvmrc
21+
shell: bash
22+
run: echo "NODE_VERSION=$(cat .nvmrc)" >> $GITHUB_OUTPUT
23+
id: nvm
24+
25+
- name: Use Node.js
26+
uses: actions/setup-node@v6
3227
with:
33-
config_file: ${{ inputs.CONFIG_FILE }}
34-
fail_level: ${{ inputs.FAIL_LEVEL }}
35-
filter_mode: ${{ inputs.FILTER_MODE }}
28+
registry-url: https://registry.npmjs.org/
29+
node-version-file: '.nvmrc'
30+
31+
# Fix Chrome sandbox issues on Ubuntu 24.04
32+
- name: Setup Chrome Linux Sandbox
33+
shell: bash
34+
run: |
35+
# Based on https://chromium.googlesource.com/chromium/src/+/main/docs/security/apparmor-userns-restrictions.md
36+
if [ "$(lsb_release -rs)" = "24.04" ]; then
37+
echo 0 | sudo tee /proc/sys/kernel/apparmor_restrict_unprivileged_userns
38+
echo 'Done'
39+
else
40+
echo "Not running on Ubuntu 24.04 — skipping sandbox fix"
41+
fi
42+
43+
- name: Install linkspector
44+
shell: bash
45+
run: |
46+
npm install @umbrelladocs/linkspector @umbrelladocs/rdformat-validator
47+
echo "linkspector version: $(node ${{ github.action_path }}/scripts/run-linkinspector.mjs --version)"
48+
49+
# Run linkspector and fail if there are broken links
50+
- name: Run linkspector
51+
shell: bash
52+
run: |
53+
set -eo pipefail
54+
echo "🔍 Checking for broken links..."
55+
node ${{ github.action_path }}/scripts/run-linkinspector.mjs check -c ${{ inputs.CONFIG_FILE }}
56+
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Wrapper for @umbrelladocs/linkspector that fixes CJS import of @umbrelladocs/rdformat-validator.
4+
* Compatible with Node 18–24.
5+
*/
6+
7+
import { fileURLToPath } from "url";
8+
import { dirname, resolve } from "path";
9+
10+
const __dirname = dirname(fileURLToPath(import.meta.url));
11+
12+
// Dynamically import linkspector’s CLI entry point
13+
const linkspector = await import("@umbrelladocs/linkspector/lib/cli.js");
14+
15+
// Safely import CommonJS validator
16+
import validatorPkg from "@umbrelladocs/rdformat-validator";
17+
const { validateAndFix } = validatorPkg;
18+
19+
// Patch the global context so linkspector sees the right export
20+
globalThis.validateAndFix = validateAndFix;
21+
22+
// Execute linkspector CLI
23+
if (typeof linkspector.default === "function") {
24+
await linkspector.default();
25+
} else if (typeof linkspector.run === "function") {
26+
await linkspector.run();
27+
} else {
28+
console.error("⚠️ Could not find linkspector entry point.");
29+
process.exit(1);
30+
}

0 commit comments

Comments
 (0)