Skip to content

fix lint

fix lint #14

Workflow file for this run

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