fix lint #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |