From 81e298ce649898deeab4b4911a64c21ff2af7fa2 Mon Sep 17 00:00:00 2001 From: t1nyb0x Date: Fri, 9 Oct 2026 23:54:02 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E4=B8=80=E8=A6=A7=E3=81=AE?= =?UTF-8?q?=E3=82=AB=E3=83=BC=E3=83=89=E7=94=A8=E3=81=AB=E6=A8=AA=E5=B9=85?= =?UTF-8?q?=E3=81=A7=E6=8F=83=E3=81=88=E3=81=9F=E6=B4=BE=E7=94=9F=E7=94=BB?= =?UTF-8?q?=E5=83=8F=E3=82=92=E4=BD=9C=E3=82=8C=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SharpImageProcessor に cardWidth を渡したときだけ card を作る。一覧は横幅で並べるので、 長辺ではなく横幅で揃え、縦に長い画像でも display の長辺は超えない。指定しなければ 今までと同じ結果になり、ImageVariants の card は省略できるので、既存の実装や fake は そのまま動く。 cardWidth を使う前に作った画像のために、保存済みの display から card を作る createCardVariant も出す。 Co-Authored-By: Claude Opus 5.5 --- packages/media/src/sharp.test.ts | 60 +++++++++++++++++++++++++++++++- packages/media/src/sharp.ts | 44 ++++++++++++++++++++++- packages/media/src/types.ts | 2 ++ 3 files changed, 104 insertions(+), 2 deletions(-) diff --git a/packages/media/src/sharp.test.ts b/packages/media/src/sharp.test.ts index 7531ebb..835bb86 100644 --- a/packages/media/src/sharp.test.ts +++ b/packages/media/src/sharp.test.ts @@ -1,6 +1,6 @@ import sharp from "sharp"; import { describe, expect, it } from "vitest"; -import { SharpImageProcessor, sniffImage } from "./sharp.ts"; +import { createCardVariant, SharpImageProcessor, sniffImage } from "./sharp.ts"; import { DISPLAY_MAX_EDGE, MAX_INPUT_EDGE, THUMB_MAX_EDGE } from "./types.ts"; // テストの画像は全部ここで作る。リポジトリに画像を置かない (docs/adr/0002) @@ -136,3 +136,61 @@ describe("SharpImageProcessor", () => { expect([thumb.width, thumb.height]).toEqual([400, 200]); }); }); + +describe("SharpImageProcessor card variant", () => { + const withCard = new SharpImageProcessor({ cardWidth: 960 }); + + it("does not make a card unless the service asks for one", async () => { + const out = await new SharpImageProcessor().process(await png(1200, 800), "image/png"); + expect(out.card).toBeUndefined(); + }); + + it("makes a WebP card at the requested width, keeping the aspect ratio", async () => { + const out = await withCard.process(await png(1500, 2000), "image/png"); + const card = await sharp(out.card).metadata(); + expect([card.format, card.width, card.height]).toEqual(["webp", 960, 1280]); + }); + + it("does not enlarge an image narrower than the card width", async () => { + const out = await withCard.process(await png(300, 200), "image/png"); + const card = await sharp(out.card).metadata(); + expect([card.width, card.height]).toEqual([300, 200]); + }); + + it("keeps a very tall card within the display edge", async () => { + const out = await withCard.process(await png(1000, 8000), "image/png"); + const card = await sharp(out.card).metadata(); + expect([card.width, card.height]).toEqual([DISPLAY_MAX_EDGE / 8, DISPLAY_MAX_EDGE]); + }); + + it("drops EXIF from the card", async () => { + const withExif = new Uint8Array( + await solid(1200, 600) + .jpeg() + .withExif({ IFD0: { Artist: "someone" } }) + .toBuffer(), + ); + const out = await withCard.process(withExif, "image/jpeg"); + expect((await sharp(out.card).metadata()).exif).toBeUndefined(); + }); +}); + +describe("createCardVariant", () => { + it("shrinks an existing display image to the card width", async () => { + const card = await createCardVariant(await webp(2048, 1536), 960); + const meta = await sharp(card).metadata(); + expect([meta.format, meta.width, meta.height]).toEqual(["webp", 960, 720]); + }); + + it("does not enlarge a display image narrower than the card width", async () => { + const card = await createCardVariant(await webp(400, 600), 960); + const meta = await sharp(card).metadata(); + expect([meta.width, meta.height]).toEqual([400, 600]); + }); + + it("rejects bytes that do not decode", async () => { + await expect( + createCardVariant(new TextEncoder().encode("not an image"), 960), + ).rejects.toMatchObject({ reason: "decode_failed" }); + }); +}); diff --git a/packages/media/src/sharp.ts b/packages/media/src/sharp.ts index 4b6f2b3..4ddfef5 100644 --- a/packages/media/src/sharp.ts +++ b/packages/media/src/sharp.ts @@ -49,8 +49,33 @@ export type SharpImageProcessorOptions = { displayMaxEdge?: number; /** サムネイルの長辺 (px)。既定 THUMB_MAX_EDGE */ thumbMaxEdge?: number; + /** + * カード用の横幅 (px)。指定したときだけ card を作る。一覧は横幅で並べるので長辺ではなく横幅で揃え、 + * 縦に長い画像でも display の長辺は超えない + */ + cardWidth?: number; }; +const cardResize = (width: number, maxEdge: number) => + ({ width, height: maxEdge, fit: "inside", withoutEnlargement: true }) as const; + +/** + * 保存済みの display からカード用の画像を作る (cardWidth を使う前に作った画像の作り直し用)。 + * display はメタデータを落とし終えているので、ここでは縮めて WebP にするだけ + */ +export async function createCardVariant(bytes: Uint8Array, width: number): Promise { + try { + return new Uint8Array( + await sharp(bytes, { limitInputPixels: MAX_INPUT_PIXELS, failOn: "error" }) + .resize(cardResize(width, DISPLAY_MAX_EDGE)) + .webp({ quality: 80 }) + .toBuffer(), + ); + } catch { + throw new ImageRejectedError("decode_failed"); + } +} + /** * Sharp による実装。EXIF の向きを焼き込み、メタデータは ICC 以外を落とし、sRGB に統一する。 * 再エンコードするので、WebP の知らないチャンク (再編集用の同梱データなど) も残らない。 @@ -59,10 +84,12 @@ export type SharpImageProcessorOptions = { export class SharpImageProcessor implements ImageProcessor { private readonly displayMaxEdge: number; private readonly thumbMaxEdge: number; + private readonly cardWidth: number | undefined; constructor(options: SharpImageProcessorOptions = {}) { this.displayMaxEdge = options.displayMaxEdge ?? DISPLAY_MAX_EDGE; this.thumbMaxEdge = options.thumbMaxEdge ?? THUMB_MAX_EDGE; + this.cardWidth = options.cardWidth; } sniff(bytes: Uint8Array): ImageFormat | null { @@ -114,6 +141,14 @@ export class SharpImageProcessor implements ImageProcessor { .webp({ quality: 80 }) .toBuffer(); + const card = + this.cardWidth === undefined + ? undefined + : await base() + .resize(cardResize(this.cardWidth, this.displayMaxEdge)) + .webp({ quality: 80 }) + .toBuffer(); + const { data: raw, info: rawInfo } = await sharp(thumb) .ensureAlpha() .raw() @@ -126,7 +161,14 @@ export class SharpImageProcessor implements ImageProcessor { 3, ); - return { width: info.width, height: info.height, display, thumb, blurhash }; + return { + width: info.width, + height: info.height, + display, + thumb, + ...(card ? { card } : {}), + blurhash, + }; } catch (e) { if (e instanceof ImageRejectedError) throw e; throw new ImageRejectedError("decode_failed"); diff --git a/packages/media/src/types.ts b/packages/media/src/types.ts index 27de217..c587eac 100644 --- a/packages/media/src/types.ts +++ b/packages/media/src/types.ts @@ -4,6 +4,8 @@ export type ImageVariants = { height: number; display: Uint8Array; thumb: Uint8Array; + /** 一覧のカード用。横幅で揃える。SharpImageProcessor に cardWidth を渡したときだけ作る */ + card?: Uint8Array; blurhash: string; }; From 8054b5600d0c047a1bdf3aefcb633ae6f7ad6f22 Mon Sep 17 00:00:00 2001 From: t1nyb0x Date: Fri, 9 Oct 2026 23:59:00 +0900 Subject: [PATCH 2/4] =?UTF-8?q?ci:=20gitleaks=20=E3=81=A8=20audit=E3=80=81?= =?UTF-8?q?release-please=20=E3=81=A8=E5=85=AC=E9=96=8B=E3=82=92=E5=86=8D?= =?UTF-8?q?=E5=88=A9=E7=94=A8=E3=83=AF=E3=83=BC=E3=82=AF=E3=83=95=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=81=AB=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit security.yml (gitleaks で履歴全体、高リスクの脆弱性は警告、追加の検査、GitHub Packages の認証は入力で) と release.yml (release-please と、版が上がったパッケージの公開) を workflow_call で置き、 このリポジトリの ci.yml もそれを呼ぶ。ほかのリポジトリが同じものを使う (ADR-0009)。 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yml | 73 ++++----------------------------- .github/workflows/release.yml | 63 ++++++++++++++++++++++++++++ .github/workflows/security.yml | 75 ++++++++++++++++++++++++++++++++++ 3 files changed, 146 insertions(+), 65 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/security.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c03b7dd..56610d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,77 +46,20 @@ jobs: - run: pnpm test:coverage - run: pnpm build:packages - # シークレットの混入と高リスクの脆弱性。audit は警告に留める + # シークレットの混入と高リスクの脆弱性 (ほかのリポジトリと同じ再利用ワークフロー、ADR-0009) security: if: github.event_name == 'pull_request' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - fetch-depth: 0 - # gitleaks の本体 (CLI、MIT) を直接動かす。gitleaks-action は organization のリポジトリではライセンスキーが要る。 - # 版とチェックサムは公式の gitleaks_<版>_checksums.txt から。lumorphia/editor と同じ版 - - name: gitleaks (履歴全体) - env: - GITLEAKS_VERSION: 8.30.1 - GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb - run: | - set -euo pipefail - curl -fsSLo /tmp/gitleaks.tar.gz \ - "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" - echo "${GITLEAKS_SHA256} /tmp/gitleaks.tar.gz" | sha256sum -c - - tar -xzf /tmp/gitleaks.tar.gz -C /tmp gitleaks - /tmp/gitleaks git --redact --no-banner --verbose . - - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 - - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 - with: - node-version: 24.21.0 - cache: pnpm - - run: pnpm install --frozen-lockfile - # 失敗にすると、上流の修正を待つあいだ全ての PR が止まる。結果は Actions の注釈で見て、Renovate で上げる - - name: pnpm audit (high 以上。警告) - run: pnpm audit --audit-level=high --prod - continue-on-error: true + permissions: + contents: read + packages: read + uses: ./.github/workflows/security.yml - # main に積まれた Conventional Commits から release-please がパッケージごとのリリース PR (版と CHANGELOG.md) を - # 開き直す。そのリリース PR をマージした push で、版が上がったパッケージだけを GitHub Packages に公開する + # main への push で release-please と、版が上がったパッケージの公開 (再利用ワークフロー、ADR-0009) release: if: github.event_name == 'push' && github.ref == 'refs/heads/main' - runs-on: ubuntu-latest permissions: contents: write pull-requests: write packages: write - steps: - # GITHUB_TOKEN が開いた PR では ci が走らない (Actions の再帰防止)。リリース PR は版と CHANGELOG だけなので - # 検査は要らないが、required check にするなら RELEASE_PLEASE_TOKEN (PAT) を secrets に入れる - - uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0 - id: release - with: - token: ${{ secrets.RELEASE_PLEASE_TOKEN || secrets.GITHUB_TOKEN }} - - if: steps.release.outputs.releases_created == 'true' - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - - if: steps.release.outputs.releases_created == 'true' - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 - - if: steps.release.outputs.releases_created == 'true' - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 - with: - node-version: 24.21.0 - cache: pnpm - registry-url: https://npm.pkg.github.com - scope: "@lumorphia" - - if: steps.release.outputs.releases_created == 'true' - run: pnpm install --frozen-lockfile - - if: steps.release.outputs.releases_created == 'true' - run: pnpm build:packages - # paths_released は今回リリースしたパッケージのパスの JSON 配列 (例: ["packages/media"])。 - # release-please-action の src/index.ts (outputReleases) が出す - - if: steps.release.outputs.releases_created == 'true' - env: - NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - PATHS_RELEASED: ${{ steps.release.outputs.paths_released }} - run: | - set -euo pipefail - for path in $(jq -r '.[]' <<<"$PATHS_RELEASED"); do - pnpm --filter "./${path}" publish --no-git-checks - done + uses: ./.github/workflows/release.yml + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..e7e11d4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,63 @@ +name: release + +# パッケージごとに版を付けて GitHub Packages に公開するリポジトリ (platform、umbra) が、main への push で呼ぶ (ADR-0009)。 +# main に積まれた Conventional Commits から release-please がパッケージごとのリリース PR (版と CHANGELOG.md) を +# 開き直す。そのリリース PR をマージした push で、版が上がったパッケージだけを公開する。 +# 呼び出し側の例: +# release: +# if: github.event_name == 'push' && github.ref == 'refs/heads/main' +# permissions: { contents: write, pull-requests: write, packages: write } +# uses: lumorphia/platform/.github/workflows/release.yml@
# main +# secrets: inherit +on: + workflow_call: + secrets: + RELEASE_PLEASE_TOKEN: + description: "リリース PR で CI を回したいときの PAT。無ければ GITHUB_TOKEN" + required: false + +permissions: + contents: read + +jobs: + release: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + packages: write + steps: + # GITHUB_TOKEN が開いた PR では ci が走らない (Actions の再帰防止)。リリース PR は版と CHANGELOG だけなので + # 検査は要らないが、required check にするなら RELEASE_PLEASE_TOKEN (PAT) を secrets に入れる + - uses: googleapis/release-please-action@45996ed1f6d02564a971a2fa1b5860e934307cf7 # v5.0.0 + id: release + with: + token: ${{ secrets.RELEASE_PLEASE_TOKEN || secrets.GITHUB_TOKEN }} + - if: steps.release.outputs.releases_created == 'true' + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - if: steps.release.outputs.releases_created == 'true' + uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + - if: steps.release.outputs.releases_created == 'true' + uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version: 24.21.0 + cache: pnpm + registry-url: https://npm.pkg.github.com + scope: "@lumorphia" + - if: steps.release.outputs.releases_created == 'true' + run: pnpm install --frozen-lockfile + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - if: steps.release.outputs.releases_created == 'true' + run: pnpm build:packages + # paths_released は今回リリースしたパッケージのパスの JSON 配列 (例: ["packages/media"])。 + # release-please-action の src/index.ts (outputReleases) が出す + - if: steps.release.outputs.releases_created == 'true' + env: + NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PATHS_RELEASED: ${{ steps.release.outputs.paths_released }} + run: | + set -euo pipefail + for path in $(jq -r '.[]' <<<"$PATHS_RELEASED"); do + pnpm --filter "./${path}" publish --no-git-checks + done diff --git a/.github/workflows/security.yml b/.github/workflows/security.yml new file mode 100644 index 0000000..c400ea0 --- /dev/null +++ b/.github/workflows/security.yml @@ -0,0 +1,75 @@ +name: security + +# Lumorphia の各リポジトリが PR で呼ぶ、シークレットの混入と高リスクの脆弱性の検査 (ADR-0009)。 +# アクションの版・gitleaks の版とチェックサム・Node の版は、ここで上げれば全部のリポジトリに効く。 +# 呼び出し側の例: +# security: +# if: github.event_name == 'pull_request' +# permissions: { contents: read, packages: read } +# uses: lumorphia/platform/.github/workflows/security.yml@
# main +# with: { github-packages: true } +on: + workflow_call: + inputs: + github-packages: + description: "private の @lumorphia/* を GitHub Packages から読むか (install に認証を付ける)" + type: boolean + default: false + audit-command: + description: "高リスクの脆弱性の検査。失敗にはせず、結果は Actions の注釈で見る" + type: string + default: pnpm audit --audit-level=high --prod + extra-command: + description: "追加の検査 (例: pnpm licenses:check)。空なら回さない。失敗はジョブの失敗にする" + type: string + default: "" + +permissions: + contents: read + +jobs: + security: + runs-on: ubuntu-latest + permissions: + contents: read + packages: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + fetch-depth: 0 + # gitleaks の本体 (CLI、MIT) を直接動かす。gitleaks-action は organization のリポジトリではライセンスキーが要る。 + # 版とチェックサムは公式の gitleaks_<版>_checksums.txt から + - name: gitleaks (履歴全体) + env: + GITLEAKS_VERSION: 8.30.1 + GITLEAKS_SHA256: 551f6fc83ea457d62a0d98237cbad105af8d557003051f41f3e7ca7b3f2470eb + run: | + set -euo pipefail + curl -fsSLo /tmp/gitleaks.tar.gz \ + "https://github.com/gitleaks/gitleaks/releases/download/v${GITLEAKS_VERSION}/gitleaks_${GITLEAKS_VERSION}_linux_x64.tar.gz" + echo "${GITLEAKS_SHA256} /tmp/gitleaks.tar.gz" | sha256sum -c - + tar -xzf /tmp/gitleaks.tar.gz -C /tmp gitleaks + /tmp/gitleaks git --redact --no-banner --verbose . + - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + - if: ${{ !inputs.github-packages }} + uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version: 24.21.0 + cache: pnpm + - if: ${{ inputs.github-packages }} + uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version: 24.21.0 + cache: pnpm + registry-url: https://npm.pkg.github.com + scope: "@lumorphia" + - run: pnpm install --frozen-lockfile + env: + NODE_AUTH_TOKEN: ${{ inputs.github-packages && secrets.GITHUB_TOKEN || '' }} + # 失敗にすると、上流の修正を待つあいだ全ての PR が止まる。結果は Actions の注釈で見て、Renovate で上げる + - name: 高リスクの脆弱性 (警告) + run: ${{ inputs.audit-command }} + continue-on-error: true + - if: ${{ inputs.extra-command != '' }} + name: 追加の検査 + run: ${{ inputs.extra-command }} From 62a0cf651743e381f58a7489ad1b2c03b87d60f3 Mon Sep 17 00:00:00 2001 From: t1nyb0x Date: Fri, 9 Oct 2026 23:59:00 +0900 Subject: [PATCH 3/4] =?UTF-8?q?build:=20Renovate=20=E3=81=AE=E5=85=B1?= =?UTF-8?q?=E9=80=9A=E3=81=AE=E8=A8=AD=E5=AE=9A=E3=82=92=20renovate/defaul?= =?UTF-8?q?t.json=20=E3=81=AB=E7=BD=AE=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 各リポジトリは local>lumorphia/platform//renovate/default を extends で読む。自分たちのパッケージ (@lumorphia/*) は公開してすぐに上げる決まりを足した。このリポジトリもそれを読む (ADR-0009)。 Co-Authored-By: Claude Opus 5.5 --- renovate.json | 36 +---------------------------------- renovate/default.json | 44 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 35 deletions(-) create mode 100644 renovate/default.json diff --git a/renovate.json b/renovate.json index bc84fbd..cb12330 100644 --- a/renovate.json +++ b/renovate.json @@ -1,38 +1,4 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["config:recommended", ":timezone(Asia/Tokyo)", "schedule:weekly"], - "baseBranchPatterns": ["develop"], - "labels": ["dependencies"], - "rangeStrategy": "bump", - "minimumReleaseAge": "1 day", - "updateNotScheduled": false, - "postUpdateOptions": ["pnpmDedupe"], - "packageRules": [ - { - "description": "開発依存と本番依存の minor / patch は 1 本の PR にまとめる", - "matchDepTypes": ["dependencies", "devDependencies"], - "groupName": "dependencies (minor, patch)", - "matchUpdateTypes": ["minor", "patch"] - }, - { - "description": "メジャーは個別に。破壊的変更を 1 つずつ見る", - "matchUpdateTypes": ["major"], - "dependencyDashboardApproval": true - }, - { - "description": "Node の版は ci.yml と engines を 1 本の PR でそろえて上げる", - "matchDepNames": ["node"], - "groupName": "node" - }, - { - "description": "GitHub Actions もまとめる", - "matchManagers": ["github-actions"], - "groupName": "github actions" - } - ], - "vulnerabilityAlerts": { - "enabled": true, - "labels": ["security"] - }, - "prConcurrentLimit": 3 + "extends": ["local>lumorphia/platform//renovate/default"] } diff --git a/renovate/default.json b/renovate/default.json new file mode 100644 index 0000000..2670a76 --- /dev/null +++ b/renovate/default.json @@ -0,0 +1,44 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:recommended", ":timezone(Asia/Tokyo)", "schedule:weekly"], + "baseBranchPatterns": ["develop"], + "labels": ["dependencies"], + "rangeStrategy": "bump", + "minimumReleaseAge": "1 day", + "updateNotScheduled": false, + "postUpdateOptions": ["pnpmDedupe"], + "packageRules": [ + { + "description": "開発依存と本番依存の minor / patch は 1 本の PR にまとめる", + "matchDepTypes": ["dependencies", "devDependencies"], + "groupName": "dependencies (minor, patch)", + "matchUpdateTypes": ["minor", "patch"] + }, + { + "description": "メジャーは個別に。破壊的変更を 1 つずつ見る", + "matchUpdateTypes": ["major"], + "dependencyDashboardApproval": true + }, + { + "description": "Node の版は ci.yml と engines を 1 本の PR でそろえて上げる", + "matchDepNames": ["node"], + "groupName": "node" + }, + { + "description": "GitHub Actions もまとめる", + "matchManagers": ["github-actions"], + "groupName": "github actions" + }, + { + "description": "自分たちのパッケージ (lumorphia/platform・umbra・editor、GitHub Packages) は公開してすぐに上げる。読むには各リポジトリの hostRules (npm.pkg.github.com のトークン) が要る", + "matchPackageNames": ["@lumorphia/*"], + "minimumReleaseAge": "0 days" + } + ], + "vulnerabilityAlerts": { + "enabled": true, + "labels": ["security"] + }, + "prConcurrentLimit": 3, + "description": "Lumorphia の各リポジトリが extends で読む Renovate の共通の設定 (ADR-0009)。リポジトリだけの決まりは各 renovate.json に足す" +} From 8a519b02ff6752a71d736b3c71bc755a973df051 Mon Sep 17 00:00:00 2001 From: t1nyb0x Date: Fri, 9 Oct 2026 23:59:00 +0900 Subject: [PATCH 4/4] =?UTF-8?q?docs:=20=E9=96=8B=E7=99=BA=E3=81=AE?= =?UTF-8?q?=E9=81=93=E5=85=B7=E3=81=AE=E5=85=B1=E9=80=9A=E5=8C=96=E3=81=AE?= =?UTF-8?q?=E7=AF=84=E5=9B=B2=E3=82=92=20ADR-0009=20=E3=81=AB=E6=9B=B8?= =?UTF-8?q?=E3=81=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 6 ++++++ docs/adr/0009-shared-dev-tooling.md | 28 ++++++++++++++++++++++++++++ docs/adr/README.md | 2 ++ 3 files changed, 36 insertions(+) create mode 100644 docs/adr/0009-shared-dev-tooling.md diff --git a/AGENTS.md b/AGENTS.md index fa6e971..a1b0e8c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -29,6 +29,12 @@ docs/adr/ 設計判断 - `legal` は画面でも本文を表示するので Node API を使わない。ファイルの読み込みと同意の記録の形はサービスが決める - キーの付け方 (`tmp/`、`posts/` など) はサービスが決める。`storage` は知らない +## ほかのリポジトリと共通の開発の道具 (ADR-0009) + +- `renovate/default.json`: Renovate の共通の設定。各リポジトリは `"extends": ["local>lumorphia/platform//renovate/default"]` で読む。Renovate は main の版を読むので、変えたら develop → main まで入れる +- `.github/workflows/security.yml`・`release.yml`: 再利用ワークフロー (`on: workflow_call`)。このリポジトリの `ci.yml` は `./.github/workflows/...` で呼び、ほかは `lumorphia/platform/.github/workflows/<名前>.yml@
# main` で呼ぶ。入力を変えたり消したりすると呼び出し側が壊れるので、足すだけにする +- **手本** (パッケージにしない。新しいリポジトリはここから写す): `.prettierrc`、`.prettierignore`、`tsconfig.base.json`、`eslint.config.js` の共通の rules (`consistent-type-imports`、`no-unused-vars`)、`.gitleaks.toml`、`.husky/`、`package.json` の `lint-staged`、`release-please-config.json` + ## 入れてよいデータ (public リポジトリ) - クレデンシャル (トークン、鍵、パスワード、`.env`) は入れない。husky の pre-commit と CI が gitleaks で検査する。テストの擬似の値は `test-` などで始める (`.gitleaks.toml`) diff --git a/docs/adr/0009-shared-dev-tooling.md b/docs/adr/0009-shared-dev-tooling.md new file mode 100644 index 0000000..56a9b3b --- /dev/null +++ b/docs/adr/0009-shared-dev-tooling.md @@ -0,0 +1,28 @@ +# ADR-0009: 開発の道具は Renovate の共通の設定と CI の再利用ワークフローだけを共通にする + +| 項目 | 内容 | +| -------- | ---------- | +| Status | Accepted | +| Date | 2026-10-09 | +| Deciders | t1nyb0x | + +## Context + +lumorphia/scenote の ADR-0006 で、開発の道具 (ESLint・TypeScript・Prettier の設定、CI の再利用ワークフロー、Renovate と release-please の設定、E2E の土台) を共通にすると決めた (順番の 6 番目)。5 つのリポジトリ (prismtone、accounts、platform、umbra、editor) を見比べると、Prettier・TypeScript の設定はほぼ同じで数行しかなく、めったに変わらない。CI のアクション・gitleaks・Node の版は揃っているが、上げるたびに 5 か所を直している。Renovate の設定は 4 つが同じで、prismtone だけ独自の決まりが多い。E2E の偽物 (OAuth・Misskey・Mastodon・Lodestone) と開発用の証明書は prismtone から accounts に写され、少しずつずれ始めている。 + +## Decision + +- **Renovate の共通の設定**を `renovate/default.json` に置く。各リポジトリは `"extends": ["local>lumorphia/platform//renovate/default"]` で読み、リポジトリだけの決まり (prismtone の postgres や transformers の上限など) と hostRules を自分の `renovate.json` に足す。Renovate は main の版を読む +- **CI の再利用ワークフロー**を置く。`security.yml` (gitleaks で履歴全体、高リスクの脆弱性は警告、追加の検査) と `release.yml` (release-please と、版が上がったパッケージだけを GitHub Packages に公開。platform と umbra の形)。呼び出し側は `lumorphia/platform/.github/workflows/<名前>.yml@
# main` で固定し、Renovate が上げる。lint・テスト・E2E・Docker はリポジトリごとの違いが大きいので共通にしない +- **Prettier・TypeScript・ESLint の基本の設定はパッケージにしない**。数行で、版を上げる手間のほうが大きい。新しいリポジトリは AGENTS.md の「手本」の一覧から写す +- **E2E の土台は、Scenote の骨組みと一緒に切り出す**。3 つ目の使い手が出たときのほうが、共通の形を決めやすい + +## Consequences + +アクション・gitleaks・Node の版と Renovate の決まりは、platform で 1 回直せば各リポジトリに届く (再利用ワークフローは呼び出し側の固定を Renovate が上げたとき)。platform の main に入るまで、ほかのリポジトリは新しいワークフローと設定を使えない。 + +再利用ワークフローは public の platform にあり、private のリポジトリ (prismtone、umbra) からも呼べる。中身はシークレットを持たず、呼び出し側の `GITHUB_TOKEN` で動く。 + +## References + +- lumorphia/scenote ADR-0006 diff --git a/docs/adr/README.md b/docs/adr/README.md index 9a8d3a4..3a07735 100644 --- a/docs/adr/README.md +++ b/docs/adr/README.md @@ -15,4 +15,6 @@ | [0008](0008-legal-package.md) | 規約の本文と同意の版の比較を @lumorphia/legal にまとめる | +| [0009](0009-shared-dev-tooling.md) | 開発の道具は Renovate の共通の設定と CI の再利用ワークフローだけを共通にする | + 本文中の「prismtone ADR-NNNN」は lumorphia/prismtone の ADR を指す。