diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 17cdde7699..1041a366c9 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -5,7 +5,31 @@ - - +## ๐Ÿงช QA Metadata + +```json +{ + "scope": "app-runtime", + "precondition": "", + "action": "", + "expected": "", + "risk": "", + "evidence": [ + { + "kind": "issue", + "ref": "#", + "assertion": "" + } + ] +} +``` + ## ๐Ÿ“ท๐˜š๐˜ค๐˜ณ๐˜ฆ๐˜ฆ๐˜ฏ๐˜ด๐˜ฉ๐˜ฐ๐˜ต -## ๐Ÿ’ฌ๐˜›๐˜ฐ ๐˜™๐˜ฆ๐˜ท๐˜ช๐˜ฆ๐˜ธ๐˜ฆ๐˜ณ๐˜ด \ No newline at end of file +## ๐Ÿ’ฌ๐˜›๐˜ฐ ๐˜™๐˜ฆ๐˜ท๐˜ช๐˜ฆ๐˜ธ๐˜ฆ๐˜ณ๐˜ด diff --git a/.github/scripts/qa-metadata.mjs b/.github/scripts/qa-metadata.mjs new file mode 100644 index 0000000000..8ed4888e30 --- /dev/null +++ b/.github/scripts/qa-metadata.mjs @@ -0,0 +1,230 @@ +// PR ๋ณธ๋ฌธ์˜ `QA Metadata` ์„น์…˜์„ ํŒŒ์‹ฑยท๊ฒ€์ฆํ•œ๋‹ค. validate-pr-qa-metadata.mjs ๊ฐ€ Unit Test ์—์„œ +// ์ด ํ•จ์ˆ˜๋“ค๋กœ ๊ฒŒ์ดํŠธ๋ฅผ ๊ฑด๋‹ค (#809). +// +// ์›๋ž˜ qa-semantic-audit.mjs ์˜ ์•ž๋ถ€๋ถ„์ด์—ˆ๋‹ค. ๊ทธ ์Šคํฌ๋ฆฝํŠธ๋Š” deployment-decision.yml ์˜ ํŒ์ • ์œ„์— +// Copilot ์˜๋ฏธ ๊ฐ์‚ฌ๋ฅผ ์–น์—ˆ๋Š”๋ฐ, develop ์ด ํŒ์ • ์›Œํฌํ”Œ๋กœ ์ž์ฒด๋ฅผ ๊ฑท์–ด๋‚ด(d657a0492) ํ† ๋Œ€๊ฐ€ ์‚ฌ๋ผ์กŒ๋‹ค. +// ๋ฐฐํฌ ์‹œ์ ์€ ๋ฆด๋ฆฌ์Šค PR ์„ ์—ฌ๋Š” ์‚ฌ๋žŒ์ด ์ •ํ•˜๊ณ  QA ํฌ์ธํŠธ๋„ ์‚ฌ๋žŒ์ด ์“ฐ๋ฏ€๋กœ, ๋‚จ๋Š” ๊ฒƒ์€ PR ๋‹จ์œ„๋กœ +// ๊ตฌ์กฐํ™” QA ์›์ฒœ์„ ๊ฐ•์ œํ•˜๋Š” ์ด ๊ฒŒ์ดํŠธ๋ฟ์ด๋‹ค. + +export const QA_METADATA_SCOPES = [ + "app-runtime", + "release-only", + "ci-only", + "covered-by-ci", +]; + +const RUNNABLE_SCOPES = new Set(["app-runtime", "release-only"]); +const EXCLUDED_SCOPES = new Set(["ci-only", "covered-by-ci"]); +const EVIDENCE_KINDS = new Set([ + "issue", + "test", + "ci", + "screenshot", + "measurement", + "diff", +]); +const MAX_METADATA_TEXT_LENGTH = 1_000; +const MAX_EVIDENCE_ITEMS = 20; +const GENERIC_QA_PATTERNS = [ + /#\d+\s*๊ด€๋ จ ๋™์ž‘์„ ์žฌํ˜„ํ•˜๊ณ  ์ˆ˜์ • ํ›„ ๊ธฐ๋Œ€ ๊ฒฐ๊ณผ๊ฐ€ ์ถฉ์กฑ๋˜๋Š”์ง€ ํ™•์ธ/i, + /PR\s*#\d+์˜ ๋ณ€๊ฒฝ ํ๋ฆ„์„ ์‹คํ–‰ํ•˜๊ณ  ๊ธฐ์กด ๋™์ž‘์ด ํšŒ๊ท€ํ•˜์ง€ ์•Š๋Š”์ง€ ํ™•์ธ/i, + /^(?:๊ด€๋ จ|๊ธฐ์กด|์ •์ƒ)\s*(?:๋™์ž‘|๊ธฐ๋Šฅ|ํ๋ฆ„)(?:์„|์ด|๊ฐ€)?\s*(?:ํ™•์ธ|ํ…Œ์ŠคํŠธ)(?:ํ•œ๋‹ค|ํ•˜๊ธฐ|ํ•ด๋ณด๊ธฐ)?[.!]?$/i, +]; +const PLACEHOLDER_VALUES = new Set([ + "", + "-", + "#", + "...", + "n/a", + "na", + "none", + "no response", + "todo", + "tbd", + "์—†์Œ", + "ํ•ด๋‹น ์—†์Œ", +]); + +function normalizedText(value) { + return typeof value === "string" ? value.trim() : ""; +} + +export function isGenericQaText(value) { + const text = normalizedText(value); + return ( + PLACEHOLDER_VALUES.has(text.toLowerCase()) || + GENERIC_QA_PATTERNS.some((pattern) => pattern.test(text)) + ); +} + +function qaMetadataSection(body) { + const lines = String(body ?? "").split(/\r?\n/); + let capturing = false; + const section = []; + + for (const line of lines) { + const heading = /^(#{1,6})\s+(.+?)\s*$/.exec(line); + if (heading) { + if (capturing) { + break; + } + capturing = /qa\s*(?:๋ฉ”ํƒ€๋ฐ์ดํ„ฐ|metadata)/i.test(heading[2]); + continue; + } + if (capturing) { + section.push(line); + } + } + + return section.join("\n").replace(//g, ""); +} + +export function hasQaMetadataSection(body) { + return Boolean(qaMetadataSection(body).trim()); +} + +export function extractQaMetadata(body) { + const section = qaMetadataSection(body); + if (!section.trim()) { + throw new Error("`QA ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ` ์„น์…˜์ด ์—†์Šต๋‹ˆ๋‹ค."); + } + + const blocks = [...section.matchAll(/```(?:json)?\s*\r?\n([\s\S]*?)```/gi)]; + if (blocks.length !== 1) { + throw new Error("`QA ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ`์—๋Š” JSON ์ฝ”๋“œ ๋ธ”๋ก์ด ์ •ํ™•ํžˆ ํ•˜๋‚˜ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค."); + } + + let metadata; + try { + metadata = JSON.parse(blocks[0][1]); + } catch { + throw new Error("`QA ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ` JSON์„ ํ•ด์„ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค."); + } + if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) { + throw new Error("`QA ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ` ์ตœ์ƒ์œ„ ๊ฐ’์€ JSON ๊ฐ์ฒด์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค."); + } + return metadata; +} + +function validateTextField(metadata, key, errors) { + const value = normalizedText(metadata[key]); + if (!value) { + errors.push(`\`${key}\` ๋ฌธ์ž์—ด์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.`); + return ""; + } + if (isGenericQaText(value)) { + errors.push(`\`${key}\`์— placeholder ๋˜๋Š” generic QA ๋ฌธ๊ตฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.`); + } + if (value.length > MAX_METADATA_TEXT_LENGTH) { + errors.push(`\`${key}\`๋Š” ${MAX_METADATA_TEXT_LENGTH}์ž ์ดํ•˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.`); + } + return value; +} + +function validateEvidence(metadata, errors) { + if (!Array.isArray(metadata.evidence) || metadata.evidence.length === 0) { + errors.push("`evidence`์—๋Š” ๊ทผ๊ฑฐ ๊ฐ์ฒด๊ฐ€ ํ•˜๋‚˜ ์ด์ƒ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค."); + return []; + } + if (metadata.evidence.length > MAX_EVIDENCE_ITEMS) { + errors.push(`\`evidence\`๋Š” ${MAX_EVIDENCE_ITEMS}๊ฐœ ์ดํ•˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.`); + } + + return metadata.evidence.flatMap((item, index) => { + if (!item || typeof item !== "object" || Array.isArray(item)) { + errors.push(`\`evidence[${index}]\`๋Š” ๊ฐ์ฒด์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.`); + return []; + } + const kind = normalizedText(item.kind).toLowerCase(); + const ref = normalizedText(item.ref); + const assertion = normalizedText(item.assertion); + if (!EVIDENCE_KINDS.has(kind)) { + errors.push( + `\`evidence[${index}].kind\`๋Š” ${[...EVIDENCE_KINDS].join(", ")} ์ค‘ ํ•˜๋‚˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.`, + ); + } + if (!ref || isGenericQaText(ref)) { + errors.push(`\`evidence[${index}].ref\`์— ๊ตฌ์ฒด์ ์ธ ์ด์Šˆยทํ…Œ์ŠคํŠธยทjob ์ฐธ์กฐ๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.`); + } + if (!assertion || isGenericQaText(assertion)) { + errors.push(`\`evidence[${index}].assertion\`์— ํ•ด๋‹น ๊ทผ๊ฑฐ๊ฐ€ ์ฆ๋ช…ํ•˜๋Š” ๋‚ด์šฉ์„ ์ ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.`); + } + if (ref.length > MAX_METADATA_TEXT_LENGTH || assertion.length > MAX_METADATA_TEXT_LENGTH) { + errors.push(`\`evidence[${index}]\`์˜ ๋ฌธ์ž์—ด์€ ${MAX_METADATA_TEXT_LENGTH}์ž ์ดํ•˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.`); + } + + const normalized = { kind, ref, assertion }; + for (const key of ["input", "boundary", "observation"]) { + const value = normalizedText(item[key]); + if (value) { + normalized[key] = value; + if (isGenericQaText(value)) { + errors.push(`\`evidence[${index}].${key}\`์— generic ๋ฌธ๊ตฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.`); + } + if (value.length > MAX_METADATA_TEXT_LENGTH) { + errors.push( + `\`evidence[${index}].${key}\`๋Š” ${MAX_METADATA_TEXT_LENGTH}์ž ์ดํ•˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.`, + ); + } + } + } + return [normalized]; + }); +} + +export function inspectQaMetadata(body, options = {}) { + const pullRequestNumber = options.pullRequestNumber ?? "?"; + const errors = []; + let raw; + try { + raw = extractQaMetadata(body); + } catch (error) { + return { + valid: false, + metadata: null, + errors: [`PR #${pullRequestNumber}: ${error.message}`], + }; + } + + const scope = normalizedText(raw.scope).toLowerCase(); + if (!QA_METADATA_SCOPES.includes(scope)) { + errors.push(`\`scope\`๋Š” ${QA_METADATA_SCOPES.join(", ")} ์ค‘ ํ•˜๋‚˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค.`); + } + const evidence = validateEvidence(raw, errors); + const metadata = { scope, evidence }; + + if (RUNNABLE_SCOPES.has(scope)) { + for (const key of ["precondition", "action", "expected", "risk"]) { + metadata[key] = validateTextField(raw, key, errors); + } + if (normalizedText(raw.exclusionReason)) { + errors.push(`\`${scope}\`์—๋Š” \`exclusionReason\`์„ ํ•จ๊ป˜ ๋‘˜ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.`); + } + } else if (EXCLUDED_SCOPES.has(scope)) { + metadata.exclusionReason = validateTextField(raw, "exclusionReason", errors); + for (const key of ["precondition", "action", "expected", "risk"]) { + if (normalizedText(raw[key])) { + errors.push(`\`${scope}\`์—์„œ๋Š” \`${key}\` ๋Œ€์‹  \`exclusionReason\`์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.`); + } + } + const matchingBoundaryEvidence = evidence.some( + (item) => + (item.kind === "ci" || item.kind === "test") && + normalizedText(item.input) && + normalizedText(item.boundary) && + normalizedText(item.observation), + ); + if (!matchingBoundaryEvidence) { + errors.push( + `\`${scope}\` ์ œ์™ธ์—๋Š” ๋™์ผ ์ž…๋ ฅยท๊ฒฝ๊ณ„ยท๊ด€์ฐฐ ๊ฒฐ๊ณผ๋ฅผ ์ ์€ ci/test evidence๊ฐ€ ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.`, + ); + } + } + + return { + valid: errors.length === 0, + metadata: errors.length === 0 ? metadata : null, + errors: errors.map((error) => `PR #${pullRequestNumber}: ${error}`), + }; +} + diff --git a/.github/scripts/qa-metadata.test.mjs b/.github/scripts/qa-metadata.test.mjs new file mode 100644 index 0000000000..2d32d51077 --- /dev/null +++ b/.github/scripts/qa-metadata.test.mjs @@ -0,0 +1,135 @@ +import assert from "node:assert/strict"; +import test from "node:test"; + +import { inspectQaMetadata, isGenericQaText } from "./qa-metadata.mjs"; +import { + QA_METADATA_GATE_CUTOFF, + validatePullRequestEvent, +} from "./validate-pr-qa-metadata.mjs"; + +function qaBody(metadata) { + return `## QA ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ +\`\`\`json +${JSON.stringify(metadata, null, 2)} +\`\`\``; +} + +function issueEvidence(issueNumber) { + return { + kind: "issue", + ref: `#${issueNumber}`, + assertion: "์žฌํ˜„ ์กฐ๊ฑด๊ณผ ๊ด€์ฐฐ ๊ฐ€๋Šฅํ•œ ๊ธฐ๋Œ€ ๊ฒฐ๊ณผ๋ฅผ ์ •์˜ํ•œ๋‹ค", + }; +} + +function runtimeMetadata(issueNumber, overrides = {}) { + return { + scope: "app-runtime", + precondition: `์ด์Šˆ #${issueNumber}์˜ ์žฌํ˜„ ๋ฐ์ดํ„ฐ๊ฐ€ ์ค€๋น„๋œ ๋กœ๊ทธ์ธ ์ƒํƒœ`, + action: `์ด์Šˆ #${issueNumber}์˜ ์‚ฌ์šฉ์ž ํ๋ฆ„์„ ๋ช…์‹œ๋œ ์ˆœ์„œ๋กœ ์ˆ˜ํ–‰ํ•œ๋‹ค`, + expected: `์ด์Šˆ #${issueNumber}์— ์ •์˜๋œ ํ™”๋ฉด ์ƒํƒœ์™€ ์ €์žฅ ๊ฒฐ๊ณผ๊ฐ€ ํ‘œ์‹œ๋œ๋‹ค`, + risk: `์‚ฌ์šฉ์ž๊ฐ€ ์ด์Šˆ #${issueNumber}์˜ ๊ธฐ๋Šฅ์„ ์™„๋ฃŒํ•  ์ˆ˜ ์—†๋‹ค`, + evidence: [issueEvidence(issueNumber)], + ...overrides, + }; +} + +function exclusionMetadata(issueNumber) { + return { + scope: "ci-only", + exclusionReason: "GitHub Actions ์ œ์–ด ๋ณ€๊ฒฝ์œผ๋กœ APK ์‚ฌ์šฉ์ž ํ๋ฆ„์ด ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค", + evidence: [ + { + kind: "ci", + ref: "Unit Test / Run deployment script tests", + assertion: "๊ฐ™์€ ์Šคํฌ๋ฆฝํŠธ ์ž…๋ ฅ๊ณผ ์ข…๋ฃŒ ์ƒํƒœ๋ฅผ CI์—์„œ ๊ฒ€์ฆํ•œ๋‹ค", + input: `์ด์Šˆ #${issueNumber}์— ํ•ด๋‹นํ•˜๋Š” workflow fixture`, + boundary: "GitHub Actions ์Šคํฌ๋ฆฝํŠธ์˜ ํŒŒ์‹ฑ๊ณผ ๊ฒฐ๊ณผ ๊ฒ€์ฆ ๊ฒฝ๊ณ„", + observation: "node test๊ฐ€ ๊ธฐ๋Œ€ JSON๊ณผ ์ข…๋ฃŒ ์ฝ”๋“œ๋ฅผ ๋‹จ์–ธํ•œ๋‹ค", + }, + ], + }; +} + +test("accepts runnable metadata with canonical fields", () => { + const inspection = inspectQaMetadata(qaBody(runtimeMetadata(550)), { + pullRequestNumber: 550, + }); + + assert.equal(inspection.valid, true); + assert.equal(inspection.metadata.scope, "app-runtime"); + assert.match(inspection.metadata.action, /#550/); +}); + +test("rejects the former generic fallback even when JSON is present", () => { + const metadata = runtimeMetadata(550, { + action: "#550 ๊ด€๋ จ ๋™์ž‘์„ ์žฌํ˜„ํ•˜๊ณ  ์ˆ˜์ • ํ›„ ๊ธฐ๋Œ€ ๊ฒฐ๊ณผ๊ฐ€ ์ถฉ์กฑ๋˜๋Š”์ง€ ํ™•์ธ", + }); + const inspection = inspectQaMetadata(qaBody(metadata), { pullRequestNumber: 550 }); + + assert.equal(inspection.valid, false); + assert.match(inspection.errors.join("\n"), /generic QA/); + assert.equal(isGenericQaText(metadata.action), true); +}); + +test("requires matching input, boundary, and observation evidence for exclusions", () => { + const metadata = exclusionMetadata(796); + delete metadata.evidence[0].observation; + const inspection = inspectQaMetadata(qaBody(metadata), { pullRequestNumber: 796 }); + + assert.equal(inspection.valid, false); + assert.match(inspection.errors.join("\n"), /๋™์ผ ์ž…๋ ฅยท๊ฒฝ๊ณ„ยท๊ด€์ฐฐ ๊ฒฐ๊ณผ/); +}); + +test("validates pull request events with the same parser used by the gate", () => { + const result = validatePullRequestEvent({ + number: 809, + pull_request: { number: 809, body: qaBody(exclusionMetadata(809)) }, + }); + + assert.equal(result.valid, true); + assert.equal(result.metadata.scope, "ci-only"); +}); + +const beforeCutoff = new Date(Date.parse(QA_METADATA_GATE_CUTOFF) - 1_000).toISOString(); +const afterCutoff = new Date(Date.parse(QA_METADATA_GATE_CUTOFF) + 1_000).toISOString(); + +test("grandfathers pull requests created before the gate cutoff when the section is absent", () => { + const result = validatePullRequestEvent({ + pull_request: { number: 741, created_at: beforeCutoff, body: "## ์ž‘์—… ๋‚ด์šฉ\n์„ค๋ช…๋งŒ ์žˆ๋‹ค." }, + }); + + assert.equal(result.grandfathered, true); + assert.equal(result.valid, true); + assert.deepEqual(result.errors, []); +}); + +test("still validates grandfathered pull requests once they add the section", () => { + const metadata = exclusionMetadata(809); + metadata.scope = "invalid-scope"; + const result = validatePullRequestEvent({ + pull_request: { number: 741, created_at: beforeCutoff, body: qaBody(metadata) }, + }); + + assert.equal(result.grandfathered, false); + assert.equal(result.valid, false); +}); + +test("enforces the section for pull requests created after the cutoff", () => { + const result = validatePullRequestEvent({ + pull_request: { number: 999, created_at: afterCutoff, body: "## ์ž‘์—… ๋‚ด์šฉ\n์„น์…˜ ์—†์Œ." }, + }); + + assert.equal(result.grandfathered, false); + assert.equal(result.valid, false); + assert.match(result.errors.join("\n"), /์„น์…˜์ด ์—†์Šต๋‹ˆ๋‹ค/); +}); + +test("enforces the section when created_at is missing", () => { + const result = validatePullRequestEvent({ + pull_request: { number: 999, body: "## ์ž‘์—… ๋‚ด์šฉ\n์„น์…˜ ์—†์Œ." }, + }); + + assert.equal(result.grandfathered, false); + assert.equal(result.valid, false); +}); diff --git a/.github/scripts/render-distribution-release-notes.sh b/.github/scripts/render-distribution-release-notes.sh index c9760dbe7b..9430af72a8 100644 --- a/.github/scripts/render-distribution-release-notes.sh +++ b/.github/scripts/render-distribution-release-notes.sh @@ -127,6 +127,11 @@ if [[ -z "$normalized_qa_points" ]]; then exit 1 fi +if printf '%s\n' "$normalized_qa_points" | grep -Eiq '#[0-9]+[[:space:]]*๊ด€๋ จ ๋™์ž‘์„ ์žฌํ˜„ํ•˜๊ณ  ์ˆ˜์ • ํ›„ ๊ธฐ๋Œ€ ๊ฒฐ๊ณผ๊ฐ€ ์ถฉ์กฑ๋˜๋Š”์ง€ ํ™•์ธ|PR[[:space:]]*#[0-9]+์˜ ๋ณ€๊ฒฝ ํ๋ฆ„์„ ์‹คํ–‰ํ•˜๊ณ  ๊ธฐ์กด ๋™์ž‘์ด ํšŒ๊ท€ํ•˜์ง€ ์•Š๋Š”์ง€ ํ™•์ธ'; then + printf '::error::QA ํฌ์ธํŠธ์— ์‚ฌ์ „์กฐ๊ฑดยทํ–‰๋™ยท๊ธฐ๋Œ€ ๊ฒฐ๊ณผ๊ฐ€ ์—†๋Š” generic fallback ๋ฌธ๊ตฌ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.\n' >&2 + exit 1 +fi + source_ref="${SOURCE_REF:-unknown}" source_ref="${source_ref#refs/heads/}" source_sha="${SOURCE_SHA:-unknown}" diff --git a/.github/scripts/render-distribution-release-notes.test.mjs b/.github/scripts/render-distribution-release-notes.test.mjs new file mode 100644 index 0000000000..0ddf536d29 --- /dev/null +++ b/.github/scripts/render-distribution-release-notes.test.mjs @@ -0,0 +1,47 @@ +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import fs from "node:fs/promises"; +import os from "node:os"; +import path from "node:path"; +import test from "node:test"; +import { fileURLToPath } from "node:url"; + +const scriptPath = fileURLToPath( + new URL("./render-distribution-release-notes.sh", import.meta.url), +); + +async function runRenderer(t, qaPoints) { + const directory = await fs.mkdtemp(path.join(os.tmpdir(), "afternote-release-notes-")); + t.after(() => fs.rm(directory, { recursive: true, force: true })); + const outputPath = path.join(directory, "notes.txt"); + const result = spawnSync("bash", [scriptPath, outputPath], { + encoding: "utf8", + env: { + ...process.env, + EVENT_NAME: "workflow_dispatch", + ISSUE_NUMBERS: "#550", + QA_POINTS: qaPoints, + SOURCE_REF: "develop", + SOURCE_SHA: "1234567890abcdef", + }, + }); + return { result, outputPath }; +} + +test("release notes reject the former generic fallback", async (t) => { + const { result } = await runRenderer( + t, + "#550 ๊ด€๋ จ ๋™์ž‘์„ ์žฌํ˜„ํ•˜๊ณ  ์ˆ˜์ • ํ›„ ๊ธฐ๋Œ€ ๊ฒฐ๊ณผ๊ฐ€ ์ถฉ์กฑ๋˜๋Š”์ง€ ํ™•์ธ", + ); + + assert.equal(result.status, 1); + assert.match(result.stderr, /generic fallback/); +}); + +test("release notes retain an actionable QA scenario", async (t) => { + const point = "์‚ญ์ œ ํ™•์ธ์„ ๋ˆ„๋ฅด๋ฉด ์„ฑ๊ณต ์‹œ ๋ชฉ๋ก์—์„œ ์ œ๊ฑฐ๋˜๊ณ  ์‹คํŒจ ์‹œ ๊ธฐ์กด ํ•ญ๋ชฉ๊ณผ ์˜ค๋ฅ˜ ์•ˆ๋‚ด๊ฐ€ ์œ ์ง€๋œ๋‹ค"; + const { result, outputPath } = await runRenderer(t, point); + + assert.equal(result.status, 0, result.stderr); + assert.match(await fs.readFile(outputPath, "utf8"), new RegExp(point)); +}); diff --git a/.github/scripts/validate-pr-qa-metadata.mjs b/.github/scripts/validate-pr-qa-metadata.mjs new file mode 100644 index 0000000000..e3307f0663 --- /dev/null +++ b/.github/scripts/validate-pr-qa-metadata.mjs @@ -0,0 +1,87 @@ +#!/usr/bin/env node + +import fs from "node:fs/promises"; +import path from "node:path"; +import { pathToFileURL } from "node:url"; + +import { hasQaMetadataSection, inspectQaMetadata } from "./qa-metadata.mjs"; + +// ๊ฒŒ์ดํŠธ ๋„์ž… ์ „์— ์ƒ์„ฑ๋œ PR์€ ๋ฆฌ๋ฒ ์ด์Šค๋กœ ์ด ์›Œํฌํ”Œ๋กœ๋ฅผ ๋ฐ›์•„๋„ ์†Œ๊ธ‰ ์ฐจ๋‹จํ•˜์ง€ ์•Š๋Š”๋‹ค. +// ์„น์…˜์„ ์ฑ„์›Œ ๋„ฃ์€ ์ˆœ๊ฐ„๋ถ€ํ„ฐ๋Š” ์ƒ์„ฑ ์‹œ๊ฐ๊ณผ ๋ฌด๊ด€ํ•˜๊ฒŒ ๊ฒ€์ฆํ•œ๋‹ค. +// +// ์ด ๊ฐ’์€ ๊ฒŒ์ดํŠธ๊ฐ€ develop ์— ๋“ค์–ด๊ฐ€๋Š” ๋‚ ๋ณด๋‹ค ๋’ค์—ฌ์•ผ ํ•œ๋‹ค. ์•ž์„œ๋ฉด ๊ทธ ์‚ฌ์ด์— ์—ด๋ฆฐ PR ๋“ค์ด +// ๋ณธ๋ฌธ์„ ๊ณ ์น˜๊ธฐ ์ „๊นŒ์ง€ ๋ฆฌ๋ฒ ์ด์Šคํ•˜๋Š” ์ˆœ๊ฐ„ ๋ง‰ํžŒ๋‹ค โ€” 8/24 ๋กœ ๋‘๋Š” ๋™์•ˆ ์—ด๋ฆฐ PR 22๊ฑด์ด, +// 8/26 00:00Z ๋กœ ๋‘๋Š” ๋™์•ˆ #1194 ๊ฐ€ ๊ทธ ์ƒํƒœ์˜€๋‹ค. ๋จธ์ง€๊ฐ€ ์ด ๋‚ ์งœ๋ฅผ ๋„˜๊ธฐ๋ฉด ๋„˜๊ธด ๋งŒํผ ๋‹ค์‹œ ๋ฏผ๋‹ค. +export const QA_METADATA_GATE_CUTOFF = "2026-08-27T00:00:00Z"; + +function isGrandfathered(pullRequest) { + const createdAt = Date.parse(pullRequest?.created_at ?? ""); + return Number.isFinite(createdAt) && createdAt < Date.parse(QA_METADATA_GATE_CUTOFF); +} + +function escapeWorkflowCommand(value) { + return String(value) + .replaceAll("%", "%25") + .replaceAll("\r", "%0D") + .replaceAll("\n", "%0A"); +} + +export function validatePullRequestEvent(event) { + if (!event?.pull_request) { + return { skipped: true, valid: true, errors: [] }; + } + if (isGrandfathered(event.pull_request) && !hasQaMetadataSection(event.pull_request.body)) { + return { skipped: false, grandfathered: true, valid: true, errors: [] }; + } + const number = event.pull_request.number ?? event.number ?? "?"; + const inspection = inspectQaMetadata(event.pull_request.body, { + pullRequestNumber: number, + }); + return { + skipped: false, + grandfathered: false, + valid: inspection.valid, + errors: inspection.errors, + metadata: inspection.metadata, + }; +} + +async function main() { + const eventPath = process.argv[2] || process.env.GITHUB_EVENT_PATH; + if (!eventPath) { + throw new Error("GitHub pull_request event path is required"); + } + const event = JSON.parse(await fs.readFile(eventPath, "utf8")); + const validation = validatePullRequestEvent(event); + if (validation.skipped) { + console.log("pull_request event๊ฐ€ ์•„๋‹ˆ๋ฏ€๋กœ QA ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ๊ฒ€์ฆ์„ ๊ฑด๋„ˆ๋œ๋‹ˆ๋‹ค."); + return; + } + if (validation.grandfathered) { + console.log( + `::notice title=๊ตฌ์กฐํ™” QA ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ::${escapeWorkflowCommand( + `๊ฒŒ์ดํŠธ ๋„์ž…(${QA_METADATA_GATE_CUTOFF}) ์ „์— ์ƒ์„ฑ๋œ PR์ด๋ฏ€๋กœ ๊ฒ€์ฆ์„ ๊ฑด๋„ˆ๋œ๋‹ˆ๋‹ค. ` + + "`QA ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ` ์„น์…˜์„ ์ฑ„์šฐ๋ฉด ๋‹ค์Œ push๋ถ€ํ„ฐ ๊ฒ€์ฆ๋ฉ๋‹ˆ๋‹ค.", + )}`, + ); + return; + } + if (!validation.valid) { + for (const error of validation.errors) { + console.error( + `::error title=๊ตฌ์กฐํ™” QA ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ์˜ค๋ฅ˜::${escapeWorkflowCommand(error)}`, + ); + } + process.exitCode = 1; + return; + } + console.log(`QA ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ๊ฒ€์ฆ ์™„๋ฃŒ: ${validation.metadata.scope}`); +} + +const invokedPath = process.argv[1] ? pathToFileURL(path.resolve(process.argv[1])).href : ""; +if (import.meta.url === invokedPath) { + main().catch((error) => { + console.error(error instanceof Error ? error.stack : error); + process.exitCode = 1; + }); +} diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 51c11f5cb6..9e51f6ebd9 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -1,6 +1,8 @@ name: Unit Test # ๋ชจ๋“  PR ์—์„œ unit test ์‹คํ–‰: +# - validate-pr-qa-metadata.mjs : PR ๊ตฌ์กฐํ™” QA ์›์ฒœ ๋ˆ„๋ฝยทgeneric ๋ฌธ๊ตฌ ์ฐจ๋‹จ. +# ๊ฒŒ์ดํŠธ ๋„์ž… ์ „ ์ƒ์„ฑ PR ์€ ์„น์…˜์ด ์—†์œผ๋ฉด ๊ฑด๋„ˆ๋›ด๋‹ค(์Šคํฌ๋ฆฝํŠธ์˜ QA_METADATA_GATE_CUTOFF) โ€” ๋ฆฌ๋ฒ ์ด์Šค ์†Œ๊ธ‰ ์ฐจ๋‹จ ๋ฐฉ์ง€. # - node --test .github/scripts/*.test.mjs : ๋ฐฐํฌ ํŒ๋‹จ ์Šคํฌ๋ฆฝํŠธ ํšŒ๊ท€ ๊ฐ€๋“œ. # - :koverXmlReportCi / :koverHtmlReportCi : Android debug + ์ˆœ์ˆ˜ JVM ํ…Œ์ŠคํŠธ์™€ aggregate coverage # - :konsist:test : ์ˆœ์ˆ˜ JVM ๋ชจ๋“ˆ(testDebugUnitTest ๋ฏธ๋ณด์œ )์ด๋ผ ๋ณ„๋„ ๋ช…์‹œ. ๋ ˆ์ด์–ด ์˜์กด ์•„ํ‚คํ…์ฒ˜ ๊ฐ€๋“œ. @@ -38,6 +40,9 @@ jobs: "+refs/heads/${BASE_REF}:refs/remotes/origin/kover-base" \ "+refs/pull/${PR_NUMBER}/head:refs/remotes/origin/kover-head" + - name: Validate structured QA metadata + run: node .github/scripts/validate-pr-qa-metadata.mjs "$GITHUB_EVENT_PATH" + - name: Run deployment script tests run: node --test .github/scripts/*.test.mjs diff --git a/README.md b/README.md index 4de6993e06..0edbfdf832 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,46 @@ keytool -exportcert -alias afternote-debug-shared -keystore ~/afternote-debug-sh ๋ณ„๋„ API๋‚˜ ์œ ๋ฃŒ AI๋ฅผ ํ˜ธ์ถœํ•˜์ง€ ์•Š์œผ๋ฉฐ ๊ธฐ์กด GitHub Actions ์‹คํ–‰๋Ÿ‰๋งŒ ์‚ฌ์šฉํ•œ๋‹ค. Actions์˜ **Collect Release Scope**์—์„œ ๋ฆด๋ฆฌ์Šค PR ๋ฒˆํ˜ธ๋ฅผ ์ž…๋ ฅํ•ด ๋‹ค์‹œ ์‚ฐ์ถœํ•  ์ˆ˜๋„ ์žˆ๋‹ค. +### PR๋ณ„ ๊ตฌ์กฐํ™” QA ์›์ฒœ + +๋ชจ๋“  PR์€ `QA Metadata` ์„น์…˜์˜ JSON ๊ฐ์ฒด๋ฅผ ์ฑ„์šด๋‹ค. `app-runtime`ยท`release-only`๋Š” `precondition`ยท`action`ยท`expected`ยท`risk`ยท`evidence`๊ฐ€ ํ•„์š”ํ•˜๋‹ค. `ci-only`ยท`covered-by-ci`๋Š” ๋นˆ QA ๋ฌธ๊ตฌ ๋Œ€์‹  `exclusionReason`๊ณผ ๋™์ผ ์ž…๋ ฅยท๊ฒฝ๊ณ„ยท๊ด€์ฐฐ ๊ฒฐ๊ณผ๋ฅผ ์ ์€ `ci` ๋˜๋Š” `test` evidence๊ฐ€ ํ•„์š”ํ•˜๋‹ค. ๋ˆ„๋ฝ๊ณผ `#123 ๊ด€๋ จ ๋™์ž‘์„ ์žฌํ˜„...` ํ˜•ํƒœ์˜ generic ๋ฌธ๊ตฌ๋Š” Unit Test workflow์—์„œ ์‹คํŒจํ•œ๋‹ค. ๊ฒŒ์ดํŠธ ๋„์ž…(`QA_METADATA_GATE_CUTOFF`) ์ „์— ์ƒ์„ฑ๋œ PR์€ ์„น์…˜์ด ์—†์œผ๋ฉด ๊ฒ€์ฆ์„ ๊ฑด๋„ˆ๋›ฐ๋ฏ€๋กœ, ๋ฆฌ๋ฒ ์ด์Šค๋กœ ์ด workflow๋ฅผ ๋ฐ›์•„๋„ ์†Œ๊ธ‰ ์ฐจ๋‹จ๋˜์ง€ ์•Š๋Š”๋‹ค. ์„น์…˜์„ ์ฑ„์šฐ๋ฉด ์ƒ์„ฑ ์‹œ๊ฐ๊ณผ ๋ฌด๊ด€ํ•˜๊ฒŒ ๊ฒ€์ฆํ•œ๋‹ค. + +```json +{ + "scope": "app-runtime", + "precondition": "์‚ญ์ œํ•  ์• ํ”„ํ„ฐ๋…ธํŠธ๊ฐ€ ๋ชฉ๋ก์— ์žˆ๋Š” ๋กœ๊ทธ์ธ ์ƒํƒœ", + "action": "์‚ญ์ œ ํ™•์ธ์—์„œ ํ™•์ธ์„ ๋ˆŒ๋Ÿฌ DELETE ์š”์ฒญ์„ ๋ณด๋‚ธ๋‹ค", + "expected": "์„ฑ๊ณต ์‹œ ๋ชฉ๋ก์—์„œ ์ œ๊ฑฐ๋˜๊ณ  ์‹คํŒจ ์‹œ ๊ธฐ์กด ํ•ญ๋ชฉ๊ณผ ์˜ค๋ฅ˜ ์•ˆ๋‚ด๊ฐ€ ์œ ์ง€๋œ๋‹ค", + "risk": "์‹คํŒจํ•œ ์‚ญ์ œ๊ฐ€ ์„ฑ๊ณต์ฒ˜๋Ÿผ ๋ณด์ด๊ฑฐ๋‚˜ ๊ธฐ์กด ํ•ญ๋ชฉ์ด ์œ ์‹ค๋  ์ˆ˜ ์žˆ๋‹ค", + "evidence": [ + { + "kind": "issue", + "ref": "#550", + "assertion": "์‚ญ์ œ ์„ฑ๊ณตยท์‹คํŒจ์˜ ๊ด€์ฐฐ ๊ฒฐ๊ณผ๋ฅผ ์ •์˜ํ•œ๋‹ค" + } + ] +} +``` + +์•ฑ QA ์ œ์™ธ ์›์ฒœ์€ ๋‹ค์Œ์ฒ˜๋Ÿผ ๊ฐ™์€ ๊ฒฝ๊ณ„๋ฅผ ๊ฒ€์ฆํ•˜๋Š” CI ๊ทผ๊ฑฐ๋ฅผ ๊ตฌ์กฐํ™”ํ•œ๋‹ค. + +```json +{ + "scope": "ci-only", + "exclusionReason": "GitHub Actions ์ œ์–ด ๋ณ€๊ฒฝ์œผ๋กœ APK ์‚ฌ์šฉ์ž ํ๋ฆ„์ด ์กด์žฌํ•˜์ง€ ์•Š๋Š”๋‹ค", + "evidence": [ + { + "kind": "ci", + "ref": "Unit Test / Run deployment script tests", + "assertion": "๊ฐ™์€ ์Šคํฌ๋ฆฝํŠธ ์ž…๋ ฅ๊ณผ ์ข…๋ฃŒ ์ƒํƒœ๋ฅผ CI์—์„œ ๊ฒ€์ฆํ•œ๋‹ค", + "input": "๋ฐฐํฌ ํŒ๋‹จ context fixture", + "boundary": "๊ตฌ์กฐํ™” ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ํŒŒ์‹ฑ๋ถ€ํ„ฐ ์ตœ์ข… JSON ๊ฒ€์ฆ๊นŒ์ง€", + "observation": "node test๊ฐ€ ์ œ์™ธยท๋ณ‘ํ•ฉยทgeneric 0๊ฑด์„ ๋‹จ์–ธํ•œ๋‹ค" + } + ] +} +``` + ### ๋ฐฐํฌ โ€” `main` โ†’ Firebase App Distribution (์ž๋™, ์œ ์ผํ•œ ๊ฒฝ๋กœ) ์—ฌ๊ธฐ์„œ ๋ฐฐํฌ๋Š” ๊ฒ€์ฆํ•  `main` ๋นŒ๋“œ๋ฅผ Firebase ํ…Œ์Šคํ„ฐ์—๊ฒŒ ์ „๋‹ฌํ•˜๋Š” ๋‹จ๊ณ„์ด๋ฉฐ, Play Store ํ”„๋กœ๋•์…˜ ๋ฆด๋ฆฌ์Šค๋ฅผ ๋œปํ•˜์ง€ ์•Š๋Š”๋‹ค. @@ -168,7 +208,7 @@ keytool -exportcert -alias afternote-debug-shared -keystore ~/afternote-debug-sh - ์ฃผ์ฐจ๋ฅผ ๋ณ€๊ฒฝํ•œ ๋’ค ์ตœ์‹  ๋ฆฌํฌํŠธ๊ฐ€ ํ‘œ์‹œ๋˜๋Š”์ง€ ํ™•์ธ ``` -PR์ด `main`์— ๋จธ์ง€๋˜๋ฉด ์›Œํฌํ”Œ๋กœ๊ฐ€ ๋‘ ์„น์…˜์„ ๋ฆด๋ฆฌ์Šค ๋…ธํŠธ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. ์—ฐ๊ฒฐ๋œ PR์ด๋‚˜ ํ•„์ˆ˜ ์„น์…˜์„ ์ฐพ์ง€ ๋ชปํ•˜๋ฉด ๋ฐฐํฌํ•˜์ง€ ์•Š๋Š”๋‹ค. +PR์ด `main`์— ๋จธ์ง€๋˜๋ฉด ์›Œํฌํ”Œ๋กœ๊ฐ€ ๋‘ ์„น์…˜์„ ๋ฆด๋ฆฌ์Šค ๋…ธํŠธ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. ์—ฐ๊ฒฐ๋œ PR์ด๋‚˜ ํ•„์ˆ˜ ์„น์…˜์„ ์ฐพ์ง€ ๋ชปํ•˜๋ฉด ๋ฐฐํฌํ•˜์ง€ ์•Š๋Š”๋‹ค. `## QA ํฌ์ธํŠธ`์— ์‚ฌ์ „์กฐ๊ฑดยทํ–‰๋™ยท๊ธฐ๋Œ€ ๊ฒฐ๊ณผ๊ฐ€ ์—†๋Š” generic fallback ๋ฌธ๊ตฌ๊ฐ€ ์žˆ์œผ๋ฉด ๋ฆด๋ฆฌ์Šค ๋…ธํŠธ ๋ Œ๋” ๋‹จ๊ณ„์—์„œ ์‹คํŒจํ•œ๋‹ค. CI ๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” GitHub Secrets (Settings โ†’ Secrets and variables โ†’ Actions):