Skip to content
Merged
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
29 changes: 29 additions & 0 deletions .blog-config.sh.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Blog Image Workflow Configuration
# Copy this file to .blog-config.sh and fill in your API keys

# OpenAI API key for DALL-E image generation
# Get your key from: https://platform.openai.com/api-keys
OPENAI_API_KEY="sk-your-api-key-here"

# TinyPNG API key for image optimization (optional)
# Get your key from: https://tinypng.com/developers
# If not provided, will use ImageMagick for local optimization
TINYPNG_API_KEY=""

# Path to your images repository
# This should point to the local clone of github.com/haacked/images
IMAGES_REPO_PATH="$HOME/dev/haacked/images"

# Base URL for published images
IMAGE_BASE_URL="https://i.haacked.com"

# Optional: Editor command to open new posts
# Examples: "code", "vim", "subl", etc.
# Leave empty to skip auto-opening
EDITOR=""

# DALL-E image generation settings
DALLE_MODEL="dall-e-3"
DALLE_SIZE="1024x1024" # Options: 1024x1024, 1792x1024, 1024x1792
DALLE_QUALITY="standard" # Options: standard, hd
DALLE_STYLE="vivid" # Options: vivid, natural
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test Blog Scripts

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install BATS
run: |
sudo apt-get update
sudo apt-get install -y bats
Copy link

Copilot AI Nov 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package name bats installed via apt-get may not be the correct BATS package. On Ubuntu/Debian, the correct package for BATS (Bash Automated Testing System) is typically bats (older versions) or bats-core (newer versions). The bin/test script references bats-core in its installation instructions (line 21), but the workflow installs bats. These should be consistent. Consider using bats for Ubuntu's default package, or document which version is expected.

Suggested change
sudo apt-get install -y bats
sudo apt-get install -y bats-core

Copilot uses AI. Check for mistakes.

- name: Run tests
run: bin/test
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ $RECYCLE.BIN/

.sass-cache/
.jekyll-metadata

# Draft images (published separately to images repo)
.draft-images/

# Local blog configuration (contains API keys)
.blog-config.sh
47 changes: 47 additions & 0 deletions bin/test
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
# Run all tests for blog workflow scripts

set -euo pipefail

# Get script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"

# Colors
GREEN='\033[0;32m'
RED='\033[0;31m'
YELLOW='\033[1;33m'
NC='\033[0m'

echo -e "${GREEN}Running blog workflow tests...${NC}\n"

# Check if bats is installed
if ! command -v bats > /dev/null 2>&1; then
echo -e "${RED}Error: bats is not installed${NC}"
echo "Install with: brew install bats-core"
exit 1
fi

# Run unit tests
echo -e "${YELLOW}=== Unit Tests ===${NC}"
if bats "$ROOT_DIR/tests/unit/"*.bats; then
echo -e "\n${GREEN}✓ All unit tests passed!${NC}\n"
else
echo -e "\n${RED}✗ Some unit tests failed${NC}\n"
exit 1
fi

# Run integration tests if they exist
if [ -d "$ROOT_DIR/tests/integration" ] && [ -n "$(ls -A "$ROOT_DIR/tests/integration"/*.bats 2> /dev/null)" ]; then
echo -e "${YELLOW}=== Integration Tests ===${NC}"
if bats "$ROOT_DIR/tests/integration/"*.bats; then
echo -e "\n${GREEN}✓ All integration tests passed!${NC}\n"
else
echo -e "\n${RED}✗ Some integration tests failed${NC}\n"
exit 1
fi
fi

echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN}All tests passed! ✓${NC}"
echo -e "${GREEN}========================================${NC}"
Loading