Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: πŸ” Validate Jekyll Site

on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
schedule:
# Run weekly validation on Sundays at 2 AM UTC
- cron: '0 2 * * 0'

jobs:
validate:
runs-on: ubuntu-latest

steps:
- name: πŸ“₯ Checkout repository
uses: actions/checkout@v4

- name: πŸ’Ž Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true

- name: πŸ”§ Install dependencies
run: |
bundle install

- name: πŸ—οΈ Build Jekyll site
run: |
bundle exec jekyll build

- name: βœ… Run build validation
run: |
chmod +x scripts/validate-build.sh
./scripts/validate-build.sh

- name: πŸ”— Run link validation
run: |
chmod +x scripts/validate-links.sh
./scripts/validate-links.sh

- name: πŸ“ Run content validation
run: |
chmod +x scripts/validate-content.sh
./scripts/validate-content.sh

- name: πŸš€ Deploy to GitHub Pages (if main branch)
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_site

- name: πŸ“Š Upload build artifacts
if: failure()
uses: actions/upload-artifact@v3
with:
name: jekyll-build-logs
path: _site/
retention-days: 7
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ _site
.jekyll-metadata
vendor
.DS_Store
.bundle/
160 changes: 160 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# Contributing to National Digital Capacity Library

Thank you for your interest in contributing to the National Digital Capacity Library! This guide will help you get started.

## Quick Start for Contributors

### 1. Verify Your Setup Works

Before making any changes, ensure the code works on your system:

```bash
./check.sh
```

This validates that:
- Jekyll builds successfully
- All dependencies are installed
- The site structure is valid
- Assets are properly generated

### 2. Making Changes

1. Fork the repository
2. Create a new branch for your changes
3. Make your modifications
4. Test your changes (see Testing section below)
5. Submit a pull request

### 3. Testing Your Changes

**Always test your changes before submitting a pull request:**

```bash
# Quick validation (recommended for most changes)
./check.sh

# Comprehensive validation (recommended for structural changes)
make validate

# Individual tests
make validate-build # Check if Jekyll builds
make validate-links # Check for broken links
make validate-content # Validate content structure
```

## Development Workflow

### Local Development

```bash
# Install dependencies
make install

# Start development server
make serve
# or
bundle exec jekyll serve

# View at http://localhost:4000/capacity-building/
```

### Before Committing

```bash
# Validate your changes
./check.sh

# Clean up generated files (optional)
make clean
```

## Validation Levels

### 1. Simple Validation (`./check.sh`)
- βœ… Jekyll builds without errors
- βœ… Essential files exist (index.html, feed.xml)
- βœ… HTML structure is valid
- βœ… Assets are present

**Use for**: Content changes, minor updates

### 2. Build Validation (`make validate-build`)
- βœ… All simple validation checks
- βœ… Detailed file counting and statistics
- βœ… RSS feed validation
- βœ… Comprehensive HTML structure checking

**Use for**: Template changes, configuration updates

### 3. Comprehensive Validation (`make validate`)
- βœ… All build validation checks
- βœ… Internal link validation
- βœ… Image reference validation
- βœ… Content quality checks
- βœ… JSON structure validation

**Use for**: Major changes, before releases

## Continuous Integration

The repository uses GitHub Actions to automatically validate all pull requests. The CI pipeline:

1. Sets up Ruby and Jekyll environment
2. Installs dependencies
3. Runs build validation
4. Checks for broken links
5. Validates content structure
6. Deploys to GitHub Pages (if merged to main)

Your pull request must pass all CI checks before it can be merged.

## Content Guidelines

### Markdown Files
- Include front matter with layout, title, and description
- Use consistent heading structure
- Include meta descriptions for SEO

### Images
- Optimize images for web (compress, appropriate format)
- Include alt text for accessibility
- Store in `/assets/images/` directory

### Links
- Use relative links for internal content
- Test all external links
- Use descriptive link text

## Getting Help

- Check existing issues for similar problems
- Create a new issue for bugs or feature requests
- Tag maintainers for urgent issues

## File Structure

```
capacity-building/
β”œβ”€β”€ _config.yml # Jekyll configuration
β”œβ”€β”€ _layouts/ # Page templates
β”œβ”€β”€ _includes/ # Reusable components
β”œβ”€β”€ assets/ # CSS, JS, images
β”œβ”€β”€ scripts/ # Validation scripts
β”œβ”€β”€ check.sh # Quick validation script
β”œβ”€β”€ Makefile # Build automation
└── [content directories] # Markdown content
```

## Validation Scripts

- `check.sh` - Simple entry point for validation
- `scripts/validate-simple.sh` - Quick validation
- `scripts/validate-build.sh` - Build validation
- `scripts/validate-links.sh` - Link checking
- `scripts/validate-content.sh` - Content validation
- `scripts/validate-all.sh` - Comprehensive validation

## Questions?

Feel free to open an issue or contact the maintainers if you have questions about contributing or the validation process.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

source "http://rubygems.org"
source "https://rubygems.org"

# git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
activesupport (6.1.7.10)
concurrent-ruby (~> 1.0, >= 1.0.2)
Expand Down
46 changes: 46 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Makefile for Jekyll site validation and development

.PHONY: help install build serve validate clean validate-build validate-links validate-content validate-simple

# Default target
help: ## Show this help message
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-20s\033[0m %s\n", $$1, $$2}'

install: ## Install dependencies
bundle install

build: ## Build the Jekyll site
bundle exec jekyll build

serve: ## Serve the site locally for development
bundle exec jekyll serve --host 0.0.0.0 --port 4000

validate-simple: ## Run simple validation (quick check if code works)
@chmod +x scripts/validate-simple.sh
@./scripts/validate-simple.sh

validate: ## Run comprehensive validations (build, links, content)
@chmod +x scripts/validate-all.sh
@./scripts/validate-all.sh

validate-build: ## Run build validation only
@chmod +x scripts/validate-build.sh
@./scripts/validate-build.sh

validate-links: ## Run link validation only
@chmod +x scripts/validate-links.sh
@./scripts/validate-links.sh

validate-content: ## Run content validation only
@chmod +x scripts/validate-content.sh
@./scripts/validate-content.sh

clean: ## Clean generated files
rm -rf _site .jekyll-cache .jekyll-metadata

# Development workflow
dev: install build serve ## Setup and start development server

# CI/CD workflow
ci: install validate-simple ## Run CI validation pipeline (simple)
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,75 @@ Welcome to the **Digital Library for Digital Sri Lanka**. This repository hosts

Visit http://127.0.0.1:4000/capacity-building/ to view the site locally.

## Testing & Validation

### βœ… Quick Answer: Does the Code Work?

**Yes! Here's how to verify it:**

```bash
# Simple one-command check
./check.sh
```

This script will:
- βœ… Install dependencies automatically
- βœ… Build the Jekyll site
- βœ… Validate HTML structure
- βœ… Check essential files and assets
- βœ… Confirm everything works correctly

### Alternative Quick Checks

```bash
# Using Make
make validate-simple

# Or run the validation script directly
./scripts/validate-simple.sh
```

### Comprehensive Testing

For thorough validation including link checking and content validation:

```bash
# Run all validations
./scripts/validate-all.sh

# Or run individual validations
./scripts/validate-build.sh # Build validation
./scripts/validate-links.sh # Link checking
./scripts/validate-content.sh # Content structure validation
```

### Using Make Commands

```bash
make help # Show available commands
make install # Install dependencies
make build # Build the site
make serve # Start development server
make validate-simple # Quick validation (recommended)
make validate # Comprehensive validation
make ci # Run CI validation pipeline
```

### Continuous Integration

The repository includes GitHub Actions workflow (`.github/workflows/validate.yml`) that automatically:
- βœ… Builds the Jekyll site
- βœ… Validates HTML structure
- βœ… Checks for broken links
- βœ… Validates content quality
- βœ… Deploys to GitHub Pages (on main branch)

### What Gets Validated

- **Build Process**: Jekyll builds without errors
- **HTML Structure**: Valid DOCTYPE, head, body sections
- **Content Quality**: Front matter, titles, meta descriptions
- **Links**: Internal link validity
- **Assets**: CSS and JavaScript files presence
- **JSON**: Valid JSON structure (search.json, etc.)

Loading