Skip to content

A comprehensive logo-design skill for Claude, Gemini CLI, Codex and other AI agents: principles, process, SVG craft, testing tools and a 1,400+ logo reference library.

Add smoke tests on Windows, macOS and Linux (#3)

Kaana467653b03c3
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
new file mode 100644
index 0000000..076a4dc
--- /dev/null
+++ b/.github/workflows/test.yml
@@ -0,0 +1,30 @@
+name: Tests
+
+on:
+ push:
+ branches: [main]
+ pull_request:
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+jobs:
+ smoke:
+ name: ${{ matrix.os }} · Python ${{ matrix.python }}
+ runs-on: ${{ matrix.os }}
+ timeout-minutes: 15
+ strategy:
+ fail-fast: false
+ matrix:
+ os: [ubuntu-latest, macos-latest, windows-latest]
+ python: ["3.9", "3.x"]
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+ - uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
+ with:
+ python-version: ${{ matrix.python }}
+ - name: Run the skill's scripts end to end
+ run: python tools/smoke_test.py
diff --git a/README.md b/README.md
index 41e18e7..6fed6e9 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
# Logo Design Skill for Claude & AI Agents
+[![Tests](https://github.com/kaankiziltug/logo-design-skill/actions/workflows/test.yml/badge.svg)](https://github.com/kaankiziltug/logo-design-skill/actions/workflows/test.yml)
+
![Eighteen example runs of the logo-design skill](docs/images/hero.png)
A comprehensive **logo-design skill** that turns Claude — or any agent that supports Agent Skills, such as Gemini
diff --git a/skills/logo-design/scripts/export_variants.py b/skills/logo-design/scripts/export_variants.py
index 0f81dd0..79a46cf 100644
--- a/skills/logo-design/scripts/export_variants.py
+++ b/skills/logo-design/scripts/export_variants.py
@@ -199,7 +199,7 @@ def main():
raster.append(dst)
else:
ok = False
- print("web icons skipped: no rendering backend (see: python3 scripts/render_png.py --which)")
+ print(f"web icons skipped: could not render {fname} (see: python3 scripts/render_png.py --which)")
break
if ok:
ico = os.path.join(out_dir, "favicon.ico")
diff --git a/skills/logo-design/scripts/render_png.py b/skills/logo-design/scripts/render_png.py
index fcb39ea..e0d3eb0 100644
--- a/skills/logo-design/scripts/render_png.py
+++ b/skills/logo-design/scripts/render_png.py
@@ -21,6 +21,7 @@ Usage:
"""
import argparse
import base64
+import contextlib
import os
import re
import shutil
@@ -127,13 +128,42 @@ def _inkscape(svg_file, png, w, h):
check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
+def _tempdir():
+ """Like tempfile.TemporaryDirectory, but cleanup never raises (Windows can keep Chrome's files locked)."""
+ path = tempfile.mkdtemp()
+ try:
+ yield path
+ finally:
+ for _ in range(10):
+ shutil.rmtree(path, ignore_errors=True)
+ if not os.path.exists(path):
+ break
+ time.sleep(0.3)
+
+
+def _stop(proc):
+ """Stop a browser process and its children (Chrome keeps helper processes alive on Windows)."""
+ if proc.poll() is not None:
+ return
+ if os.name == "nt":
+ subprocess.run(["taskkill", "/PID", str(proc.pid), "/T", "/F"], stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL)
+ else:
+ proc.terminate()
+ try:
+ proc.wait(timeout=5)
+ except subprocess.TimeoutExpired:
+ proc.kill()
+
+
def _chrome(svg_file, png, w, h):
with open(svg_file, "rb") as fh:
data = base64.b64encode(fh.read()).decode("ascii")
page = (f"<!doctype html><html><head><style>html,body{{margin:0;padding:0;background:transparent;width:{w}px;"
f"height:{h}px;overflow:hidden}}img{{display:block;width:{w}px;height:{h}px}}</style></head>"
f"<body><img src='data:image/svg+xml;base64,{data}'></body></html>")
- with tempfile.TemporaryDirectory() as tmp:
+ with _tempdir() as tmp:
html_path = os.path.join(tmp, "render.html")
with open(html_path, "w", encoding="utf-8") as fh:
fh.write(page)
@@ -146,7 +176,7 @@ def screenshot_html(html_path, png, w, h):
if not chrome:
raise RuntimeError("no Chromium-based browser found for HTML screenshots")
html_path = os.path.abspath(html_path)
- with tempfile.TemporaryDirectory() as tmp:
+ with _tempdir() as tmp:
shot = os.path.join(tmp, "shot.png") # never poll the destination: an older file may already exist there
cmd = [chrome, "--headless=new", "--disable-gpu", "--hide-scrollbars", "--no-first-run",
"--no-default-browser-check", "--use-mock-keychain", "--password-store=basic", "--disable-extensions",
@@ -164,12 +194,11 @@ def screenshot_html(html_path, png, w, h):
if proc.poll() is not None and os.path.exists(shot):
break
time.sleep(0.25)
- if proc.poll() is None:
- proc.terminate()
- try:
- proc.wait(timeout=5)
- except subprocess.TimeoutExpired:
- proc.kill()
+ try:
+ proc.wait(timeout=0.5) # it may exit by itself after --screenshot; otherwise stop the whole tree
+ except subprocess.TimeoutExpired:
+ pass
+ _stop(proc)
if not os.path.exists(shot):
raise RuntimeError("chrome produced no file")
shutil.move(shot, png)
@@ -237,18 +266,18 @@ def render(svg_path, png_path, width, height, padding=0.0, bg=None, backend=None
"""Render svg_path into png_path at exactly width×height. Returns the backend used, or None."""
markup = wrap_svg(svg_path, width, height, padding, bg)
order = [backend] if backend else available_backends()
- with tempfile.TemporaryDirectory() as tmp:
+ with _tempdir() as tmp:
wrapped = os.path.join(tmp, "wrapped.svg")
with open(wrapped, "w", encoding="utf-8") as fh:
fh.write(markup)
for name in order:
- try:
- BACKENDS[name](wrapped, png_path, width, height)
- if os.path.exists(png_path):
- return name
- except Exception as exc: # try the next backend
- last = exc # noqa: F841
- continue
+ for _attempt in range(2 if name == "chrome" else 1): # a browser can fail once on a busy machine
+ try:
+ BACKENDS[name](wrapped, png_path, width, height)
+ if os.path.exists(png_path):
+ return name
+ except Exception: # retry, then try the next backend
+ continue
return None
@@ -296,7 +325,7 @@ def main():
if a.ico:
pngs = []
- with tempfile.TemporaryDirectory() as tmp:
+ with _tempdir() as tmp:
for s in a.ico_sizes:
p = os.path.join(tmp, f"ico-{s}.png")
if not render(a.files[0], p, s, s, a.padding, a.bg, a.backend):
diff --git a/tools/smoke_test.py b/tools/smoke_test.py
new file mode 100644
index 0000000..50f1506
--- /dev/null
+++ b/tools/smoke_test.py
@@ -0,0 +1,146 @@
+#!/usr/bin/env python3
+"""Smoke-test every script in the skill the way an agent runs them (used by CI on Windows, macOS and Linux).
+
+ python tools/smoke_test.py # all checks; PNG checks run when a renderer is available
+
+Each script runs in a subprocess with the platform's default console encoding (cp1252 on Windows), so
+crashes such as UnicodeEncodeError on report symbols are caught. Standard library only.
+"""
+import json
+import os
+import re
+import shutil
+import subprocess
+import sys
+import tempfile
+
+ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+SKILL = os.path.join(ROOT, "skills", "logo-design")
+SCRIPTS = os.path.join(SKILL, "scripts")
+LIB = os.path.join(SKILL, "assets", "library", "svg")
+
+SYMBOL = """<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"><title>Test symbol</title>
+<circle cx="128" cy="128" r="96" fill="#0F7C80"/>
+<path d="M80 150 L176 146 L176 170 L80 174 Z" fill="#FFFFFF"/></svg>
+"""
+LOCKUP = """<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 900 256"><title>Test lockup</title>
+<circle cx="128" cy="128" r="96" fill="#0F7C80"/>
+<rect x="280" y="100" width="560" height="56" rx="8" fill="#161616"/></svg>
+"""
+
+failures = []
+
+
+def run(name, args, expect=(), cwd=None):
+ """Run a script; fail on non-zero exit, a traceback, or missing expected text/files."""
+ env = {k: v for k, v in os.environ.items() if k not in ("PYTHONIOENCODING", "PYTHONUTF8")}
+ p = subprocess.run([sys.executable] + args, cwd=cwd or SKILL, env=env, capture_output=True)
+ out = (p.stdout + p.stderr).decode("utf-8", "replace")
+ problems = []
+ if p.returncode != 0:
+ problems.append(f"exit code {p.returncode}")
+ if "Traceback (most recent call last)" in out:
+ problems.append("traceback")
+ for e in expect:
+ if os.path.isabs(e):
+ if not os.path.exists(e):
+ problems.append(f"missing file {e}")
+ elif e not in out:
+ problems.append(f"output lacks {e!r}")
+ status = "ok " if not problems else "FAIL"
+ print(f"[{status}] {name}")
+ if problems:
+ failures.append(name)
+ print(" " + "; ".join(problems))
+ print(" " + out.strip().replace("\n", "\n ")[-2500:])
+ return out
+
+
+def main():
+ tmp = tempfile.mkdtemp(prefix="logo-smoke-")
+ try:
+ sym, lock = os.path.join(tmp, "a-symbol.svg"), os.path.join(tmp, "a-lockup.svg")
+ for path, body in ((sym, SYMBOL), (lock, LOCKUP)):
+ with open(path, "w", encoding="utf-8") as fh:
+ fh.write(body)
+ lib = sorted(f for f in os.listdir(LIB) if f.endswith(".svg"))[:3]
+ S = lambda f: os.path.join(SCRIPTS, f)
+
+ # manifest / frontmatter sanity
+ text = open(os.path.join(SKILL, "SKILL.md"), encoding="utf-8").read()
+ m = re.match(r"---\nname: (.+)\ndescription: (.+?)\n", text)
+ ok = bool(m) and m.group(1).strip() == "logo-design" and len(m.group(2)) <= 1024
+ versions = set()
+ for f in ("plugin.json", "marketplace.json"):
+ data = json.load(open(os.path.join(ROOT, ".claude-plugin", f), encoding="utf-8"))
+ versions.add(data.get("version") or data["plugins"][0]["version"])
+ if "plugins" in data:
+ versions.update(p["version"] for p in data["plugins"])
+ ok = ok and len(versions) == 1
+ print(f"[{'ok ' if ok else 'FAIL'}] SKILL.md frontmatter and manifest versions ({', '.join(sorted(versions))})")
+ if not ok:
+ failures.append("frontmatter/manifests")
+
+ run("build_catalog --check", [S("build_catalog.py"), "--check"], ["0 missing"])
+ run("svg_audit (fixtures + library)", [S("svg_audit.py"), sym, lock] + [os.path.join(LIB, f) for f in lib],
+ ["production-readiness score"])
+ run("svg_audit --json", [S("svg_audit.py"), "--json", sym])
+ run("search_library near-miss filter", [S("search_library.py"), "--industry", "finance", "--limit", "3"],
+ ["using 'finance-banking'"])
+ run("search_library --summary", [S("search_library.py"), "--technique", "negative-space", "--summary"],
+ ["logos match"])
+ out = run("search_library --format json", [S("search_library.py"), "--type", "letterform", "--format", "json",
+ "--limit", "2"])
+ try:
+ json.loads(out[out.index("["):])
+ except ValueError:
+ failures.append("search_library json output")
+ print("[FAIL] search_library json output is not valid JSON")
+ run("search_library --list-values", [S("search_library.py"), "--list-values"], ["mark_type:"])
+ run("concept_sheet", [S("concept_sheet.py"), sym, sym, "--lockups", lock, lock, "--names", "A", "B",
+ "--notes", "One.", "Two.", "--recommend", "1", "-o", os.path.join(tmp, "concepts.png")],
+ [os.path.join(tmp, "concepts.svg")])
+ run("preview_sheet", [S("preview_sheet.py"), sym, lock, "--refs-industry", "finance-banking",
+ "-o", os.path.join(tmp, "preview.html")], [os.path.join(tmp, "preview.html")])
+ run("presentation_board --list-mockups", [S("presentation_board.py"), "--list-mockups"], ["payment-card"])
+ spec = {"brand": "Smoke", "tagline": "Test", "brief": "A test brief.", "adjectives": ["calm"],
+ "industry": "finance", "brand_color": "#0F7C80", "final": True, "greyscale": False,
+ "concepts": [{"name": "Test", "symbol": sym, "lockup": lock, "idea": "An idea.",
+ "rationale": ["One", "Two"]}]}
+ spec_path = os.path.join(tmp, "spec.json")
+ with open(spec_path, "w", encoding="utf-8") as fh:
+ json.dump(spec, fh)
+ run("presentation_board", [S("presentation_board.py"), spec_path, "-o", os.path.join(tmp, "board.html")],
+ [os.path.join(tmp, "board.html")])
+ run("export_variants (SVG)", [S("export_variants.py"), sym, "--out-dir", os.path.join(tmp, "export"),
+ "--mono", "#0F7C80", "--icon-bg", "#0F7C80"])
+ which = run("render_png --which", [S("render_png.py"), "--which"])
+ if "available backends: none" not in which and "available backends:" in which:
+ png = os.path.join(tmp, "a.png")
+ run("render_png (PNG)", [S("render_png.py"), sym, "-o", png, "--size", "64"], [png])
+ run("export_variants --web-icons", [S("export_variants.py"), sym, "--out-dir", os.path.join(tmp, "web"),
+ "--icon-bg", "#0F7C80", "--web-icons"],
+ [os.path.join(tmp, "web", "favicon.ico")])
+ else:
+ print("[skip] PNG checks (no renderer on this machine)")
+ run("package_skill", [os.path.join(ROOT, "tools", "package_skill.py")],
+ [os.path.join(ROOT, "dist", "logo-design.zip"), os.path.join(ROOT, "dist", "logo-design-lite.zip")],
+ cwd=ROOT)
+
+ caches = [d for d, _, _ in os.walk(SKILL) if os.path.basename(d) == "__pycache__"]
+ print(f"[{'ok ' if not caches else 'FAIL'}] no __pycache__ written into the skill folder")
+ if caches:
+ failures.append("__pycache__ in skill folder: " + ", ".join(caches))
+ finally:
+ shutil.rmtree(tmp, ignore_errors=True)
+
+ print()
+ if failures:
+ print(f"{len(failures)} check(s) failed: {', '.join(failures)}")
+ sys.exit(1)
+ print("all checks passed")
+
+
+if __name__ == "__main__":
+ sys.dont_write_bytecode = True
+ main()