Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8297002dc5 | |||
| 90e410f49e | |||
| 14a3d32480 | |||
| 19b8becc30 |
@@ -0,0 +1,38 @@
|
|||||||
|
name: Auto PR
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'feat/**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
open-pr:
|
||||||
|
runs-on: [macos, host]
|
||||||
|
steps:
|
||||||
|
- name: Create Pull Request via Gitea API
|
||||||
|
env:
|
||||||
|
CI_TOKEN: ${{ secrets.CI_TOKEN }}
|
||||||
|
GITEA_BASE_URL: https://gitea.jaybe.dev
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
|
HEAD_BRANCH: ${{ github.ref_name }}
|
||||||
|
BASE_BRANCH: main
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
if [ -z "${CI_TOKEN:-}" ]; then
|
||||||
|
echo "GITEA_TOKEN not set; skipping auto-pr"; exit 0; fi
|
||||||
|
OWNER=$(echo "$REPO" | cut -d'/' -f1)
|
||||||
|
NAME=$(echo "$REPO" | cut -d'/' -f2)
|
||||||
|
TITLE="auto: PR for $HEAD_BRANCH"
|
||||||
|
BODY="Automated PR created on push to $HEAD_BRANCH"
|
||||||
|
echo "Creating PR $HEAD_BRANCH -> $BASE_BRANCH for $OWNER/$NAME"
|
||||||
|
HTTP_CODE=$(curl -sS -o /tmp/pr_resp.json -w "%{http_code}" -X POST \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: token ${CI_TOKEN}" \
|
||||||
|
"${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/pulls" \
|
||||||
|
-d "{\"head\":\"${HEAD_BRANCH}\",\"base\":\"${BASE_BRANCH}\",\"title\":\"${TITLE}\",\"body\":\"${BODY}\"}") || true
|
||||||
|
echo "API status: $HTTP_CODE"
|
||||||
|
if [ "$HTTP_CODE" = "201" ]; then
|
||||||
|
echo "PR created"; cat /tmp/pr_resp.json
|
||||||
|
else
|
||||||
|
echo "PR not created (possibly exists). Response:"; cat /tmp/pr_resp.json || true
|
||||||
|
fi
|
||||||
@@ -42,3 +42,24 @@ jobs:
|
|||||||
path: playwright-report
|
path: playwright-report
|
||||||
if-no-files-found: ignore
|
if-no-files-found: ignore
|
||||||
retention-days: 3
|
retention-days: 3
|
||||||
|
|
||||||
|
- name: Auto-merge PR on green
|
||||||
|
if: ${{ github.event_name == 'pull_request' }}
|
||||||
|
env:
|
||||||
|
CI_TOKEN: ${{ secrets.CI_TOKEN }}
|
||||||
|
GITEA_BASE_URL: https://gitea.jaybe.dev
|
||||||
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
if [ -z "${CI_TOKEN:-}" ]; then
|
||||||
|
echo "CI_TOKEN not set; skipping auto-merge"; exit 0; fi
|
||||||
|
OWNER=$(echo "$REPO" | cut -d'/' -f1)
|
||||||
|
NAME=$(echo "$REPO" | cut -d'/' -f2)
|
||||||
|
echo "Merging PR #$PR_NUMBER for $OWNER/$NAME"
|
||||||
|
RESP=$(curl -sS -X POST \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: token ${CI_TOKEN}" \
|
||||||
|
"${GITEA_BASE_URL}/api/v1/repos/${OWNER}/${NAME}/pulls/${PR_NUMBER}/merge" \
|
||||||
|
-d '{"Do":"merge","MergeMessage":"auto-merge: CI green"}' || true)
|
||||||
|
echo "API response: $RESP"
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ describe('Exporter a11y/responsive enhancements', () => {
|
|||||||
test('hero image alt derives from heading', () => {
|
test('hero image alt derives from heading', () => {
|
||||||
const out = exportPage(makePage())
|
const out = exportPage(makePage())
|
||||||
expect(out.html).toContain('<h1 id="hero-heading">Welcome</h1>')
|
expect(out.html).toContain('<h1 id="hero-heading">Welcome</h1>')
|
||||||
expect(out.html).toContain('<img src="https://example.com/img.png" alt="Welcome" />')
|
expect(out.html).toMatch(/<img[^>]*src="https:\/\/example\.com\/img\.png"[^>]*alt="Welcome"[^>]*\/>/)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('responsive and a11y CSS tokens exist', () => {
|
test('responsive and a11y CSS tokens exist', () => {
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ function renderHero(section: { props: { heading: string; subheading?: string; im
|
|||||||
${subheading ? `<p>${escapeHtml(subheading)}</p>` : ''}
|
${subheading ? `<p>${escapeHtml(subheading)}</p>` : ''}
|
||||||
</div>
|
</div>
|
||||||
<div class="media">
|
<div class="media">
|
||||||
<img src="${escapeHtml(imageUrl)}" alt="${escapeHtml(heading)}" />
|
<img src="${escapeHtml(imageUrl)}" alt="${escapeHtml(heading)}" loading="lazy" decoding="async" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
@@ -237,6 +237,7 @@ function buildHead(page: Page) {
|
|||||||
return `
|
return `
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
|
<link rel="canonical" href="/" />
|
||||||
<title>${escapeHtml(page.seo.title)}</title>
|
<title>${escapeHtml(page.seo.title)}</title>
|
||||||
<meta name="description" content="${escapeHtml(page.seo.description)}" />
|
<meta name="description" content="${escapeHtml(page.seo.description)}" />
|
||||||
<meta property="og:title" content="${escapeHtml(page.seo.title)}" />
|
<meta property="og:title" content="${escapeHtml(page.seo.title)}" />
|
||||||
@@ -272,6 +273,7 @@ function buildCss(page: Page) {
|
|||||||
.testimonial blockquote{ margin:0; font-style:italic; color:#1f2937 }
|
.testimonial blockquote{ margin:0; font-style:italic; color:#1f2937 }
|
||||||
.testimonial figcaption{ color:#475569; margin-top:.25rem }
|
.testimonial figcaption{ color:#475569; margin-top:.25rem }
|
||||||
@media (max-width: 640px){ .container{ padding: 1rem } h1{ font-size: 1.5rem } }
|
@media (max-width: 640px){ .container{ padding: 1rem } h1{ font-size: 1.5rem } }
|
||||||
|
@media (prefers-color-scheme: dark){ body{ color:#e5e7eb; background:#0b1020 } .feature-item{ background:#0f172a; border-color:#1f2937 } }
|
||||||
@media (prefers-reduced-motion: reduce){ *{ transition: none !important; animation: none !important } }
|
@media (prefers-reduced-motion: reduce){ *{ transition: none !important; animation: none !important } }
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,34 @@
|
|||||||
|
import { describe, it, expect } from 'vitest'
|
||||||
|
import { exportPage } from '@/lib/exporter/html'
|
||||||
|
import { pageSchema, type Page } from '@/lib/schema/page'
|
||||||
|
|
||||||
|
function makePage(): Page {
|
||||||
|
return pageSchema.parse({
|
||||||
|
title: 'SEO/Perf',
|
||||||
|
locale: 'en',
|
||||||
|
theme: { primaryColor: '#0ea5e9', fontFamily: 'Inter' },
|
||||||
|
sections: [
|
||||||
|
{ type: 'hero', props: { heading: 'Welcome', subheading: 'Sub', imageUrl: 'https://img.example/hero.png' } },
|
||||||
|
],
|
||||||
|
form: { actionUrl: '', fields: [], spamProtection: { honeypotFieldName: '_hp', minSubmitSeconds: 2 } },
|
||||||
|
seo: { title: 'SEO', description: 'Desc' },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('Exporter - small SEO/Perf improvements', () => {
|
||||||
|
it('includes canonical link and dark mode tokens; hero image lazy/async', () => {
|
||||||
|
const out = exportPage(makePage())
|
||||||
|
const html = out.html
|
||||||
|
const css = out.css
|
||||||
|
|
||||||
|
// canonical link present in head
|
||||||
|
expect(html).toMatch(/<link[^>]+rel="canonical"/)
|
||||||
|
|
||||||
|
// hero image has loading/decoding attributes
|
||||||
|
expect(html).toMatch(/<img[^>]*loading="lazy"/)
|
||||||
|
expect(html).toMatch(/<img[^>]*decoding="async"/)
|
||||||
|
|
||||||
|
// dark mode media query token exists
|
||||||
|
expect(css).toMatch(/@media \(prefers-color-scheme: dark\)/)
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user