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
171 changes: 171 additions & 0 deletions .github/workflows/sticker-studio-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
name: Sticker Studio Preview Deploy

on:
pull_request:
types:
- opened
- reopened
- synchronize
- closed
paths:
- "sticker-studio/**"
- ".github/workflows/sticker-studio-preview.yml"
push:
branches:
- main
paths:
- "sticker-studio/**"
- ".github/workflows/sticker-studio-preview.yml"

permissions:
contents: write
pull-requests: write

concurrency:
group: sticker-studio-preview-${{ github.event.pull_request.number || github.ref_name }}
cancel-in-progress: true

jobs:
deploy-preview:
if: github.event_name == 'pull_request' && github.event.action != 'closed' && github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
env:
PREVIEW_DIR: previews/sticker-studio/pr-${{ github.event.pull_request.number }}
PREVIEW_URL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/previews/sticker-studio/pr-${{ github.event.pull_request.number }}/
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22

- name: Verify Sticker Studio
working-directory: sticker-studio
run: npm run verify

Comment on lines +39 to +47
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Install dependencies before running verification.

Line 44 and Line 155 run npm run verify without an install step. On clean runners, this can fail due to missing node_modules, breaking both preview and stable deploys.

Suggested fix
       - name: Set up Node.js
         uses: actions/setup-node@v4
         with:
           node-version: 22
+          cache: npm
+          cache-dependency-path: sticker-studio/package-lock.json
+
+      - name: Install dependencies
+        working-directory: sticker-studio
+        run: npm ci
 
       - name: Verify Sticker Studio
         working-directory: sticker-studio
         run: npm run verify
@@
       - name: Set up Node.js
         uses: actions/setup-node@v4
         with:
           node-version: 22
+          cache: npm
+          cache-dependency-path: sticker-studio/package-lock.json
+
+      - name: Install dependencies
+        working-directory: sticker-studio
+        run: npm ci
 
       - name: Verify Sticker Studio
         working-directory: sticker-studio
         run: npm run verify

Also applies to: 150-157

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/sticker-studio-preview.yml around lines 39 - 47, The
workflow runs "Verify Sticker Studio" steps (step name "Verify Sticker Studio")
without installing dependencies first, causing failures on clean runners; add an
install step (e.g., run: npm ci with working-directory: sticker-studio)
immediately before each "run: npm run verify" invocation (including the other
occurrence around lines 150-157) so node_modules are present when the verify
script runs.

- name: Deploy preview to gh-pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./sticker-studio
destination_dir: ${{ env.PREVIEW_DIR }}
keep_files: true
enable_jekyll: false

- name: Comment preview URL on pull request
uses: actions/github-script@v7
env:
PREVIEW_DIR: ${{ env.PREVIEW_DIR }}
PREVIEW_URL: ${{ env.PREVIEW_URL }}
with:
script: |
const marker = "<!-- sticker-studio-preview -->";
const headSha = context.payload.pull_request.head.sha.slice(0, 7);
const body = `${marker}
Sticker Studio preview deployed.

URL: ${process.env.PREVIEW_URL}
Commit: ${headSha}
Path: \`${process.env.PREVIEW_DIR}/\`

If this is the first deployment, enable GitHub Pages once in repository settings and point it at the \`gh-pages\` branch.`;

const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});

const existing = comments.find(
(comment) => comment.user.type === "Bot" && comment.body.includes(marker)
);

if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});
}

cleanup-preview:
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
env:
PREVIEW_DIR: previews/sticker-studio/pr-${{ github.event.pull_request.number }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Remove preview directory from gh-pages
run: |
if ! git ls-remote --exit-code --heads origin gh-pages >/dev/null 2>&1; then
echo "gh-pages branch does not exist yet."
exit 0
fi

git fetch origin gh-pages:gh-pages
git switch gh-pages

if [ ! -d "${PREVIEW_DIR}" ]; then
echo "Preview directory already removed."
exit 0
fi

rm -rf "${PREVIEW_DIR}"

if [ -z "$(git status --short)" ]; then
echo "No cleanup changes to commit."
exit 0
fi

git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Remove Sticker Studio preview for PR #${{ github.event.pull_request.number }}"
git push origin gh-pages

deploy-stable:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
env:
STABLE_DIR: sticker-studio
STABLE_URL: https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/sticker-studio/
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22

- name: Verify Sticker Studio
working-directory: sticker-studio
run: npm run verify

- name: Deploy stable build to gh-pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./sticker-studio
destination_dir: ${{ env.STABLE_DIR }}
keep_files: true
enable_jekyll: false

- name: Print stable URL
run: echo "Stable Sticker Studio build deployed to ${STABLE_URL}"
44 changes: 44 additions & 0 deletions sticker-studio/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Sticker Studio

Standalone first-playable vertical slice for the Sticker Studio scrapbook puzzle.

## Run

Open `index.html` in a browser, or serve the directory with any static file server.

## Test

```bash
npm test
```

## Verify

```bash
npm run verify
```

## Deployment

- Pull requests that change `sticker-studio/**` or `.github/workflows/sticker-studio-preview.yml` publish a preview build to `https://<owner>.github.io/<repo>/previews/sticker-studio/pr-<number>/`.
- Pushes to `main` that change the same paths publish the stable build to `https://<owner>.github.io/<repo>/sticker-studio/`.
- Both deploy jobs verify the slice first with `npm run verify`.

## Rollback And First Checks

- Preview cleanup is automatic when the pull request closes; the workflow removes `previews/sticker-studio/pr-<number>/` from `gh-pages`.
- Stable rollback is a normal git revert on `main`; the next stable deploy republishes the reverted `sticker-studio/` contents to `gh-pages`.
- First post-deploy QA should cover a narrow-phone viewport pass, daily unlock after level `6`, persistence across reloads, and the UTC date rollover for the daily page.

## What Is Included

- Data-driven ordered sticker-sheet gameplay with tray sheets, active partial sheets, binder clips, undo, hint, restart, fail, win, and daily-page entry
- `12` handcrafted campaign pages in `2` packs of `6`, plus `1` deterministic daily generator keyed by UTC `YYYY-MM-DD`
- Solver-backed authoring validation that checks clip counts, target references, repeat-family usage, early long-chain gating, and at least one completion path
- Portrait-first scrapbook layout with visible silhouettes from the start, clip rail, sheet tray, local reject feedback, and minimal album reward wrapper

## Implementation Notes

- The current validator uses state-space search across `place` and `park` actions. That is sufficient for this slice because clip assignment is deterministic and there are no drag paths, hidden layers, or alternate slot behaviors. If production later adds manual clip-slot selection, drag-only peeling, or visual layers that affect legality, the authoring tool will need a deeper solver and better diagnostics.
- The design spec has one internal tension: levels `8` and `9` ask for `5` sheets with `9` silhouettes, while the same spec also says authored sheet lengths should stay between `2` and `4`. This slice resolves that by allowing a small number of one-sticker opener sheets in late pages and some daily seeds. If the team wants a strict two-sticker minimum, those pages should move to `10` silhouettes or back down to `4` sheets.
- Readability risk rises on dense portrait pages once repeated families arrive. The slice keeps every empty silhouette outlined, adds variant labels for repeated families, and keeps filled stickers slightly flatter so open targets stay legible. QA should still focus on level `10` onward and smaller phone widths to catch any pages where decorative layering or filled stickers hide open spots.
13 changes: 13 additions & 0 deletions sticker-studio/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Sticker Studio</title>
<link rel="stylesheet" href="./styles.css" />
</head>
<body>
<div id="app"></div>
<script type="module" src="./src/app.js"></script>
</body>
</html>
11 changes: 11 additions & 0 deletions sticker-studio/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "sticker-studio",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"test": "node --test",
"check:app": "node --check src/app.js",
"verify": "npm test && npm run check:app"
}
}
Loading
Loading