Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
47 changes: 47 additions & 0 deletions .env.1password
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 1Password Environment Template
# This file contains secret references to 1Password vault items
# Use with: op run --env-file=.env.1password -- command
# Or: op inject -i .env.1password -o .env

# ⚠️ DO NOT COMMIT THIS FILE - IT CONTAINS SECRET REFERENCES
# This file should be in .gitignore

# Required Cloudflare Secrets
# Create these items in your 1Password vault: "MD-Book-Deployment"
CLOUDFLARE_API_TOKEN="op://MD-Book-Deployment/Cloudflare/api_token"
CLOUDFLARE_ACCOUNT_ID="op://MD-Book-Deployment/Cloudflare/account_id"

# Optional Custom Domains
# Uncomment and set these if you have custom domains
# PRODUCTION_DOMAIN="op://MD-Book-Deployment/Domains/production"
# STAGING_DOMAIN="op://MD-Book-Deployment/Domains/staging"

# Build Configuration (these can remain as regular values)
INPUT_DIR=test_input
OUTPUT_DIR=dist
SKIP_TESTS=false
DEPLOY_WORKER=true

# Development Configuration
DEV_PORT=3000
WATCH_FILES=true

# Optional Analytics and Monitoring Secrets
# Uncomment and set these in 1Password if needed
# ANALYTICS_TOKEN="op://MD-Book-Deployment/Analytics/token"
# ERROR_REPORTING_DSN="op://MD-Book-Deployment/ErrorReporting/dsn"

# Optional Email Configuration for Feedback
# Uncomment and set these in 1Password if needed
# FEEDBACK_EMAIL="op://MD-Book-Deployment/Email/feedback_address"
# SMTP_HOST="op://MD-Book-Deployment/SMTP/host"
# SMTP_PORT="op://MD-Book-Deployment/SMTP/port"
# SMTP_USER="op://MD-Book-Deployment/SMTP/username"
# SMTP_PASS="op://MD-Book-Deployment/SMTP/password"

# GitHub Integration (for scripts that sync secrets)
# GITHUB_TOKEN="op://MD-Book-Deployment/GitHub/personal_access_token"

# 1Password Service Account for CI/CD
# This should be set as a GitHub repository secret, not here
# OP_SERVICE_ACCOUNT_TOKEN="ops_..."
48 changes: 48 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Cloudflare Configuration
# Get these from your Cloudflare dashboard

# Required: Your Cloudflare API Token
# Create at: https://dash.cloudflare.com/profile/api-tokens
# Permissions needed: Zone:Zone:Read, Zone:Page Rules:Edit, Account:Cloudflare Pages:Edit
CLOUDFLARE_API_TOKEN=your_api_token_here

# Required: Your Cloudflare Account ID
# Find at: https://dash.cloudflare.com/ (right sidebar)
CLOUDFLARE_ACCOUNT_ID=your_account_id_here

# Optional: Custom domain for production
# PRODUCTION_DOMAIN=docs.yourdomain.com

# Optional: Custom domain for staging
# STAGING_DOMAIN=staging-docs.yourdomain.com

# Build Configuration
# Input directory containing your Markdown files
INPUT_DIR=test_input

# Output directory for generated HTML files
OUTPUT_DIR=dist

# Skip tests during deployment (for faster deployments)
SKIP_TESTS=false

# Deploy Cloudflare Worker along with Pages
DEPLOY_WORKER=true

# Development Configuration
# Port for local development server
DEV_PORT=3000

# Enable file watching in development
WATCH_FILES=true

# Analytics and Monitoring (Optional)
# ANALYTICS_TOKEN=your_analytics_token
# ERROR_REPORTING_DSN=your_error_reporting_dsn

# Email notifications for feedback (Optional)
# FEEDBACK_EMAIL=feedback@yourdomain.com
# SMTP_HOST=smtp.yourdomain.com
# SMTP_PORT=587
# SMTP_USER=your_smtp_user
# SMTP_PASS=your_smtp_password
121 changes: 87 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:

permissions:
contents: read
issues: write
pull-requests: write

env:
CARGO_TERM_COLOR: always
Expand All @@ -22,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04, ubuntu-latest, macos-latest, windows-latest]
rust: [stable, beta]
include:
# Test on nightly but allow failures
Expand Down Expand Up @@ -56,15 +58,13 @@ jobs:
${{ runner.os }}-cargo-${{ matrix.rust }}-
${{ runner.os }}-cargo-

- name: Install Node.js for frontend tests
uses: actions/setup-node@v4
- name: Install Bun for frontend tests
uses: oven-sh/setup-bun@v1
with:
node-version: '18'
cache: 'npm'
cache-dependency-path: package.json
bun-version: latest

- name: Install frontend dependencies
run: npm ci
run: bun install

- name: Check formatting
if: matrix.rust == 'stable'
Expand All @@ -88,11 +88,18 @@ jobs:
continue-on-error: true # Some E2E tests might need actual server

- name: Run frontend tests
run: npm test
run: bun test

- name: Run benchmarks (stable only)
- name: Install benchmark dependencies
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest'
run: cargo bench --no-run # Don't actually run benchmarks in CI, just compile
run: sudo apt-get update && sudo apt-get install -y bc jq

- name: Run performance benchmarks
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest'
run: |
chmod +x ./scripts/bench.sh
./scripts/bench.sh
continue-on-error: false # Fail CI if significant regressions detected

- name: Test documentation build
if: matrix.rust == 'stable'
Expand Down Expand Up @@ -129,17 +136,12 @@ jobs:
target/
key: ${{ runner.os }}-cargo-wasm-${{ hashFiles('**/Cargo.lock') }}

- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh

- name: Install wasm-bindgen-cli
run: cargo install wasm-bindgen-cli

- name: Build for WebAssembly
run: cargo build --target wasm32-unknown-unknown --lib
run: cargo build --target wasm32-unknown-unknown --lib --no-default-features

- name: Run WASM tests
run: wasm-pack test --headless --chrome --firefox
run: cargo test --target wasm32-unknown-unknown --no-default-features
continue-on-error: true # WASM tests might not work in CI environment

msrv:
Expand Down Expand Up @@ -192,17 +194,10 @@ jobs:
key: ${{ runner.os }}-cargo-audit-${{ hashFiles('**/Cargo.lock') }}

- name: Install cargo-audit
run: cargo install cargo-audit
run: cargo install --locked cargo-audit

- name: Run security audit
run: cargo audit

- name: Install cargo-deny
run: cargo install cargo-deny

- name: Check licenses and security
run: cargo deny check
continue-on-error: true # Allow to continue if deny.toml doesn't exist yet

coverage:
name: Code Coverage
Expand All @@ -219,7 +214,7 @@ jobs:
components: llvm-tools-preview

- name: Install cargo-tarpaulin
run: cargo install cargo-tarpaulin
run: cargo install --locked cargo-tarpaulin

- name: Generate coverage report
run: |
Expand All @@ -235,7 +230,7 @@ jobs:
performance:
name: Performance Regression
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
if: github.event_name == 'pull_request' || (github.event_name == 'push' && github.ref == 'refs/heads/main')

steps:
- name: Checkout repository
Expand All @@ -248,22 +243,80 @@ jobs:
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }}

- name: Run benchmarks
run: cargo bench -- --output-format json | tee benchmark-results.json
continue-on-error: true
- name: Install benchmark dependencies
run: sudo apt-get update && sudo apt-get install -y bc jq

- name: Store benchmark results
- name: Cache benchmark results
uses: actions/cache@v4
with:
path: benchmark-results/
key: ${{ runner.os }}-benchmarks-${{ github.base_ref || github.ref_name }}
restore-keys: |
${{ runner.os }}-benchmarks-main
${{ runner.os }}-benchmarks-

- name: Run performance benchmarks
run: |
chmod +x ./scripts/bench.sh
./scripts/bench.sh

- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: benchmark-results.json
name: benchmark-results-${{ github.sha }}
path: benchmark-results/
retention-days: 30

- name: Comment benchmark results on PR
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const path = 'benchmark-results/current.json';

try {
let body;

if (fs.existsSync(path)) {
const results = fs.readFileSync(path, 'utf8');
const truncatedResults = results.slice(0, 2000);
const wasTruncated = results.length > 2000;

body = `## 📊 Performance Benchmark Results\n\nBenchmark completed successfully. Check the uploaded artifacts for detailed results.\n\n<details>\n<summary>Raw Results ${wasTruncated ? '(truncated)' : ''}</summary>\n\n\`\`\`json\n${truncatedResults}${wasTruncated ? '\n...\n[Results truncated - see artifacts for full output]' : ''}\n\`\`\`\n\n</details>`;
} else {
body = '## ⚠️ Performance Benchmark Results\n\nBenchmark completed but no results file was generated. Please check the workflow logs and uploaded artifacts.';
}

await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: body
});

} catch (error) {
console.error('Failed to post benchmark comment:', error);

// Try to post a simple error message
try {
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '## ❌ Performance Benchmark Failed\n\nFailed to post benchmark results. Check workflow logs for details.'
});
} catch (commentError) {
console.error('Failed to post error comment:', commentError);
// Don't fail the workflow if we can't post comments
}
}

docs:
name: Documentation
Expand Down
Loading
Loading