-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (127 loc) Β· 4.24 KB
/
ci.yml
File metadata and controls
146 lines (127 loc) Β· 4.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
name: CI
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Install Emacs
run: |
sudo apt update
sudo apt-get install -y emacs
- name: Check Org files syntax
run: |
echo "π Checking Org files syntax..."
for file in posts/*.org; do
if [ -f "$file" ]; then
echo "Checking: $file"
emacs --batch --eval "(progn (find-file \"$file\") (org-lint))" 2>&1 | grep -E "(Warning|Error)" || true
fi
done
- name: Validate metadata
run: |
echo "π Validating post metadata..."
for file in posts/*.org; do
if [ -f "$file" ] && [[ "$file" != "posts/index.org" ]] && [[ "$file" != "posts/about.org" ]] && [[ "$file" != "posts/404.org" ]]; then
echo "Checking: $file"
# Check for required metadata
if ! grep -q "^#+TITLE:" "$file"; then
echo "β Missing TITLE in $file"
exit 1
fi
if ! grep -q "^#+AUTHOR:" "$file"; then
echo "β Missing AUTHOR in $file"
exit 1
fi
if ! grep -q "^#+DATE:" "$file"; then
echo "β Missing DATE in $file"
exit 1
fi
fi
done
echo "β
All metadata valid"
shellcheck:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:
scandir: '.'
format: gcc
severity: warning
build-test:
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Emacs
run: |
sudo apt update
sudo apt-get install -y emacs
- name: Test build
run: |
chmod +x build.sh
./build.sh
env:
CI: true
GITHUB_WORKSPACE: ${{ github.workspace }}
- name: Validate HTML output
run: |
echo "π Validating HTML files..."
# Check that index.html exists
if [ ! -f "public/index.html" ]; then
echo "β public/index.html not found"
exit 1
fi
# Check that all expected HTML files exist
for org_file in posts/*.org; do
if [ -f "$org_file" ] && [[ "$org_file" != "posts/404.org" ]]; then
base_name=$(basename "$org_file" .org)
html_file="public/${base_name}.html"
if [ ! -f "$html_file" ]; then
echo "β Expected $html_file not found"
exit 1
fi
fi
done
echo "β
All HTML files generated successfully"
- name: Check for broken internal links
run: |
echo "π Checking for broken internal links..."
cd public
# Use a temporary file to track broken links
broken_file=$(mktemp)
for html_file in *.html; do
if [ -f "$html_file" ]; then
# Extract internal links
grep -oE 'href="[^"]*\.html"' "$html_file" 2>/dev/null | sed 's/href="//;s/"//' | sort -u | while read -r link; do
if [ -n "$link" ] && [[ ! "$link" =~ ^https?:// ]]; then
# Handle both relative and absolute paths
check_file="${link#/}"
if [ ! -f "$check_file" ] && [ ! -f "../$check_file" ]; then
echo "β Broken link in $html_file: $link" | tee -a "$broken_file"
fi
fi
done
fi
done
# Count broken links
broken_count=$(wc -l < "$broken_file" 2>/dev/null || echo "0")
rm -f "$broken_file"
if [ "$broken_count" -gt 0 ]; then
echo "β Found $broken_count broken links"
exit 1
else
echo "β
No broken internal links found"
fi