Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2cd0a57

Browse files
Clean up tasks and actions (#2494)
1 parent cc57076 commit 2cd0a57

9 files changed

Lines changed: 167 additions & 9 deletions

File tree

.github/workflows/better_link_checker.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class PageIndexer {
1212
private excludedPaths: string[];
1313
private excludedExtensions: string[];
1414
private excludedProtocolPrefixes: string[];
15+
private tutorialExamplePatterns: RegExp[];
1516

1617
public anyErrors = false;
1718
private log = false;
@@ -23,7 +24,13 @@ class PageIndexer {
2324
this.failedPages = new Set<string>();
2425
this.parser = new DOMParser();
2526
this.rootUrl = rootUrl;
26-
this.excludedPaths = ["/api"];
27+
this.excludedPaths = [
28+
"/api", // API reference docs handled separately
29+
];
30+
this.tutorialExamplePatterns = [
31+
/^\/ry$/, // Redis tutorial: /ry
32+
/^\/api\/dinosaurs(\/.*)?$/, // Tutorial APIs: /api/dinosaurs, /api/dinosaurs/aardonyx, etc.
33+
];
2734
this.excludedExtensions = [
2835
".ts",
2936
".js",
@@ -133,6 +140,9 @@ class PageIndexer {
133140
) &&
134141
!this.excludedPaths.some((path) => url.pathname.startsWith(path)) &&
135142
!this.excludedExtensions.some((ext) => url.pathname.endsWith(ext)) &&
143+
!this.tutorialExamplePatterns.some((pattern) =>
144+
pattern.test(url.pathname)
145+
) &&
136146
url.href.startsWith(this.rootUrl.href);
137147
}
138148

.github/workflows/deploy-orama-search.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,24 @@ jobs:
3737
fetch-depth: 2
3838

3939
- name: Setup Deno
40-
uses: denoland/setup-deno@v1
40+
uses: denoland/setup-deno@v2
4141
with:
42-
deno-version: v1.x
42+
cache: true
43+
44+
- name: "Reference: install"
45+
if: steps.changes.outputs.content_changed == 'true'
46+
working-directory: "reference_gen"
47+
run: deno install
48+
49+
- name: "Reference: generate types"
50+
if: steps.changes.outputs.content_changed == 'true'
51+
working-directory: "reference_gen"
52+
run: deno task types
53+
54+
- name: "Reference: generate docs"
55+
if: steps.changes.outputs.content_changed == 'true'
56+
working-directory: "reference_gen"
57+
run: deno task doc
4358

4459
- name: Check for content changes
4560
id: changes
@@ -64,15 +79,16 @@ jobs:
6479
if: steps.changes.outputs.content_changed == 'true'
6580
run: |
6681
echo "Generating comprehensive Orama search index..."
67-
deno task generate:orama:full
82+
deno task generate:search
6883
6984
- name: Upload and deploy to Orama Cloud
7085
if: steps.changes.outputs.content_changed == 'true'
7186
run: |
7287
echo "Uploading search index to Orama Cloud..."
73-
deno task upload:orama static/orama-index-full.json --deploy
88+
deno task search:upload
7489
env:
75-
ORAMA_INDEX_ID: ${{ secrets.ORAMA_INDEX_ID }}
90+
ORAMA_PROJECT_ID: ${{ vars.ORAMA_PROJECT_ID }}
91+
ORAMA_DATASOURCE_ID: ${{ vars.ORAMA_DATASOURCE_ID }}
7692
ORAMA_PRIVATE_API_KEY: ${{ secrets.ORAMA_PRIVATE_API_KEY }}
7793

7894
- name: Report deployment success

.github/workflows/deploy.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,22 @@ jobs:
3636

3737
- name: Build
3838
env:
39-
ORAMA_CLOUD_INDEX_ID: ${{ vars.ORAMA_CLOUD_INDEX_ID }}
40-
ORAMA_CLOUD_API_KEY: ${{ secrets.ORAMA_CLOUD_API_KEY }}
39+
ORAMA_PROJECT_ID: ${{ vars.ORAMA_PROJECT_ID }}
40+
ORAMA_DATASOURCE_ID: ${{ vars.ORAMA_DATASOURCE_ID }}
41+
ORAMA_PRIVATE_API_KEY: ${{ secrets.ORAMA_PRIVATE_API_KEY }}
4142
run: deno task build
4243

44+
- name: Generate and upload search index
45+
env:
46+
ORAMA_PROJECT_ID: ${{ vars.ORAMA_PROJECT_ID }}
47+
ORAMA_DATASOURCE_ID: ${{ vars.ORAMA_DATASOURCE_ID }}
48+
ORAMA_PRIVATE_API_KEY: ${{ secrets.ORAMA_PRIVATE_API_KEY }}
49+
run: |
50+
echo "Generating search index..."
51+
deno task generate:search
52+
echo "Uploading search index to Orama Cloud..."
53+
deno task search:upload
54+
4355
- name: Run server
4456
run: deno run --allow-read=. --allow-net --allow-env --lock=deno.lock server.ts &
4557

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,53 @@ deno task serve:style
6565

6666
Then browse to the styleguide section of the site at `/styleguide/`
6767

68+
## Link checking
69+
70+
To ensure all links in the documentation work correctly, you can run the link
71+
checker locally before committing changes. This helps catch broken links early
72+
in the development process.
73+
74+
### Running link checker locally
75+
76+
The link checker needs to run against a live server. Here's the workflow:
77+
78+
1. **Start the dev server** (in one terminal):
79+
80+
```console
81+
deno task dev
82+
```
83+
84+
Wait for it to fully start (may take 30-60 seconds on first run).
85+
86+
2. **Run the link checker** (in another terminal):
87+
88+
```console
89+
deno task check:links:local
90+
```
91+
92+
This will check all links on your local site and report any issues.
93+
94+
### Pre-commit hook (optional)
95+
96+
For automatic link checking before commits, you can install a pre-commit hook:
97+
98+
```console
99+
deno task install:hooks
100+
```
101+
102+
This will check links automatically whenever you commit markdown files. You can
103+
bypass it temporarily with:
104+
105+
```console
106+
git commit --no-verify
107+
```
108+
109+
**Note for Windows users**: If you're using Git Bash or WSL, the pre-commit hook
110+
should work normally. If you encounter issues, you can manually run
111+
`deno task check:links:local` before committing.
112+
113+
The link checker also runs automatically in CI for all deployments.
114+
68115
## Editing content
69116

70117
The actual content of the docs site is found mostly in these folders:

deno.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
"build:light": "deno run --env-file -A lume.ts",
2828
"prod": "deno run --allow-read --allow-env --allow-net server.ts",
2929
"test": "deno test -A",
30+
"check:links": "deno run --no-lock --allow-net --allow-env .github/workflows/better_link_checker.ts",
31+
"check:links:local": "deno run --allow-net --allow-env check_links_local.ts",
32+
"install:hooks": "bash scripts/install-pre-commit-hook.sh",
3033
"lint:update": "deno run -A update_lint_rules.ts",
3134
"generate:search": "deno run -A orama/generate_orama_index_full.ts",
3235
"generate:search:docs-only": "deno run -A orama/generate.ts",

deno.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

orama/upload_orama_index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ async function main() {
261261

262262
// Load the index file
263263
const indexData = await loadIndexFile(indexFilePath);
264-
const documents = indexData.documents || [];
264+
const documents = indexData.documents || indexData.data || [];
265265

266266
if (documents.length === 0) {
267267
console.error("❌ No documents found in index file");

scripts/install-pre-commit-hook.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
# Install pre-commit hook for link checking
4+
# This script copies the pre-commit hook and makes it executable
5+
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
8+
HOOK_SOURCE="$SCRIPT_DIR/pre-commit"
9+
HOOK_DEST="$REPO_ROOT/.git/hooks/pre-commit"
10+
11+
echo "🚀 Installing pre-commit hook for link checking..."
12+
13+
if [ ! -f "$HOOK_SOURCE" ]; then
14+
echo "❌ Pre-commit hook source not found at $HOOK_SOURCE"
15+
exit 1
16+
fi
17+
18+
if [ ! -d "$REPO_ROOT/.git/hooks" ]; then
19+
echo "❌ Git hooks directory not found. Are you in a git repository?"
20+
exit 1
21+
fi
22+
23+
# Backup existing pre-commit hook if it exists
24+
if [ -f "$HOOK_DEST" ]; then
25+
echo "📁 Backing up existing pre-commit hook..."
26+
cp "$HOOK_DEST" "$HOOK_DEST.backup.$(date +%s)"
27+
fi
28+
29+
# Copy and make executable
30+
cp "$HOOK_SOURCE" "$HOOK_DEST"
31+
chmod +x "$HOOK_DEST"
32+
33+
echo "✅ Pre-commit hook installed successfully!"
34+
echo " The hook will check links whenever you commit markdown files."
35+
echo " To disable temporarily, use: git commit --no-verify"
36+
echo " To uninstall, delete: $HOOK_DEST"

scripts/pre-commit

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
# Pre-commit hook to check for broken links
4+
# To install: cp scripts/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit
5+
6+
echo "🔍 Running link checker before commit..."
7+
8+
# Check if any markdown files were changed
9+
CHANGED_MD_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(md|mdx)$' || true)
10+
11+
if [ -n "$CHANGED_MD_FILES" ]; then
12+
echo "📝 Markdown files changed, running link checker..."
13+
echo "Changed files:"
14+
echo "$CHANGED_MD_FILES" | sed 's/^/ - /'
15+
echo
16+
17+
# Run the local link checker
18+
if ! deno task check:links:local; then
19+
echo
20+
echo "❌ Link checker failed! Please fix broken links before committing."
21+
echo " You can run 'deno task check:links:local' to check links locally."
22+
echo " Or run 'deno task dev' and manually verify the problematic links."
23+
echo
24+
echo " To skip this check, use: git commit --no-verify"
25+
exit 1
26+
fi
27+
28+
echo "✅ All links are working correctly!"
29+
else
30+
echo "ℹ️ No markdown files changed, skipping link check."
31+
fi
32+
33+
echo "✅ Pre-commit checks passed!"

0 commit comments

Comments
 (0)