From b277e8da9f4589293de9bc3b38c4e5ffb0eda318 Mon Sep 17 00:00:00 2001 From: deflis Date: Mon, 2 Nov 2026 01:52:09 +0900 Subject: [PATCH 1/3] =?UTF-8?q?Node.js=20CI=E3=81=AE=E8=A4=87=E6=95=B0?= =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=B8=E3=83=A7=E3=83=B3=E6=A4=9C=E8=A8=BC?= =?UTF-8?q?=E3=81=A8=E5=8D=98=E4=BD=93=E3=83=BB=E5=AE=9FAPI=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=81=AE=E5=88=86=E9=9B=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/nodejs-test.yml | 61 ++++++++++++++++++++++++++++--- README.md | 10 ++++- package.json | 6 ++- 3 files changed, 68 insertions(+), 9 deletions(-) diff --git a/.github/workflows/nodejs-test.yml b/.github/workflows/nodejs-test.yml index 4953801..b03473d 100644 --- a/.github/workflows/nodejs-test.yml +++ b/.github/workflows/nodejs-test.yml @@ -7,13 +7,25 @@ on: branches: [main, master, develop] pull_request: branches: [main, master, develop] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: build: runs-on: ubuntu-latest + timeout-minutes: 15 + strategy: + fail-fast: false + matrix: + node-version: ["24", "26"] steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 name: Install pnpm @@ -23,21 +35,60 @@ jobs: - name: Install Node.js uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: - node-version: "lts/*" - cache: 'pnpm' + node-version: ${{ matrix.node-version }} + cache: "pnpm" - name: Install dependencies run: pnpm install --frozen-lockfile - - run: pnpm run build + - name: Lint + run: pnpm run check:lint + + - name: Type check + run: pnpm run check:build - name: Test with coverage + if: matrix.node-version == '26' run: pnpm run test:coverage + - name: Unit tests + if: matrix.node-version != '26' + run: pnpm run test:unit + + - name: Build + run: pnpm run build:tsc + - name: Upload coverage reports - if: always() + if: ${{ !cancelled() && matrix.node-version == '26' }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: coverage-reports + name: coverage-reports-node-${{ matrix.node-version }} path: coverage/ if-no-files-found: warn + retention-days: 7 + + integration: + name: Live API tests + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Install pnpm + uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + with: + run_install: false + + - name: Install Node.js + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: "26" + cache: "pnpm" + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Live API tests + run: pnpm run test:integration diff --git a/README.md b/README.md index 110cfde..bc54435 100644 --- a/README.md +++ b/README.md @@ -174,10 +174,16 @@ pnpm run build # テスト実行 pnpm run test -# カバレッジ計測 +# 単体テスト(外部通信なし) +pnpm run test:unit + +# 実APIテスト(外部通信あり) +pnpm run test:integration + +# 単体テストのカバレッジ計測 pnpm run test:coverage -# 型チェック +# Lint・型チェック・単体テスト pnpm run check # ドキュメント生成(TypeDoc + llms.txt) diff --git a/package.json b/package.json index bf37866..3e555f1 100644 --- a/package.json +++ b/package.json @@ -41,18 +41,20 @@ "scripts": { "build": "pnpm run check && pnpm run build:tsc", "build:tsc": "tsdown", - "check": "pnpm run check:lint && pnpm run check:build && pnpm run test", + "check": "pnpm run check:lint && pnpm run check:build && pnpm run test:unit", "check:lint": "oxlint --type-aware --deny-warnings src test", "check:build": "tsc --noEmit", "prepack": "pnpm run build", "format": "oxlint --type-aware --fix src test && oxfmt src test scripts *.ts *.json .oxlintrc.json .oxfmtrc.json tools/docs/package.json", "test": "vitest run", + "test:unit": "vitest run --exclude test/narou.test.ts", + "test:integration": "vitest run test/narou.test.ts", "docs": "pnpm run docs:clean && pnpm run docs:typedoc && pnpm run docs:json && pnpm run docs:llms", "docs:clean": "node -e \"require('node:fs').rmSync('docs', { recursive: true, force: true })\"", "docs:typedoc": "pnpm --dir tools/docs exec typedoc --tsconfig ../../tsconfig.json --out ../../docs ../../src/index.ts", "docs:json": "pnpm --dir tools/docs exec typedoc --tsconfig ../../tsconfig.json --json ../../docs/api.json ../../src/index.ts", "docs:llms": "node scripts/generate-llms-txt.js", - "test:coverage": "vitest run --coverage.enabled true" + "test:coverage": "vitest run --coverage.enabled true --exclude test/narou.test.ts" }, "devDependencies": { "@types/node": "^26.6.6", From 2cc4c9001b60bf1f58cc77ca233ea845c24f0e06 Mon Sep 17 00:00:00 2001 From: deflis Date: Mon, 2 Nov 2026 01:52:12 +0900 Subject: [PATCH 2/3] =?UTF-8?q?GitHub=20Pages=E3=81=AEPR=E3=83=93=E3=83=AB?= =?UTF-8?q?=E3=83=89=E6=A4=9C=E8=A8=BC=E8=BF=BD=E5=8A=A0=E3=81=A8=E3=83=87?= =?UTF-8?q?=E3=83=97=E3=83=AD=E3=82=A4=E6=A8=A9=E9=99=90=E3=81=AE=E5=88=86?= =?UTF-8?q?=E9=9B=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/github-pages.yml | 40 +++++++++++++++++++----------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index c702dc3..83d68f8 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -3,29 +3,28 @@ name: Deploy typedoc to Pages on: push: branches: [main, master] + pull_request: + branches: [main, master, develop] workflow_dispatch: permissions: contents: read - pages: write - id-token: write concurrency: - group: "pages" - cancel-in-progress: true + group: pages-${{ github.event.pull_request.number || 'deploy' }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - + build: runs-on: ubuntu-latest + timeout-minutes: 15 steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 name: Install pnpm @@ -35,8 +34,8 @@ jobs: - name: Install Node.js uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: - node-version: "lts/*" - cache: 'pnpm' + node-version: "26" + cache: "pnpm" - name: Install dependencies run: pnpm install --frozen-lockfile @@ -44,14 +43,27 @@ jobs: - name: Build Pages run: pnpm run docs - - name: Setup Pages - uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0 - - name: Upload artifact + if: github.event_name != 'pull_request' uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 with: path: "docs/" + deploy: + if: github.event_name != 'pull_request' + needs: build + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + pages: write + id-token: write + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Setup Pages + uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0 + - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1 From ee98d8e32484576953d05a29e7b1f23ccd25148e Mon Sep 17 00:00:00 2001 From: deflis Date: Mon, 2 Nov 2026 01:52:15 +0900 Subject: [PATCH 3/3] =?UTF-8?q?npm=E5=85=AC=E9=96=8B=E3=81=AEOIDC=E7=A7=BB?= =?UTF-8?q?=E8=A1=8C=E3=81=A8=E3=83=91=E3=83=83=E3=82=B1=E3=83=BC=E3=82=B8?= =?UTF-8?q?=E4=BD=9C=E6=88=90=E3=83=BB=E5=85=AC=E9=96=8B=E3=82=B8=E3=83=A7?= =?UTF-8?q?=E3=83=96=E3=81=AE=E5=88=86=E9=9B=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish-npm.yml | 66 +++++++++++++++++++++++++++---- 1 file changed, 59 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index ceda77b..c3daaac 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -4,11 +4,19 @@ permissions: on: release: types: [published] + +concurrency: + group: npm-publish + cancel-in-progress: false + jobs: build: runs-on: ubuntu-latest + timeout-minutes: 15 steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 name: Install pnpm @@ -18,16 +26,60 @@ jobs: - name: Install Node.js uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: - node-version: "lts/*" - cache: "pnpm" - registry-url: https://registry.npmjs.org/ + node-version: "26" + package-manager-cache: false + + - name: Verify release version + env: + RELEASE_TAG: ${{ github.event.release.tag_name }} + IS_PRERELEASE: ${{ github.event.release.prerelease }} + run: | + node --input-type=module <<'NODE' + import { readFileSync } from 'node:fs'; + const { version } = JSON.parse(readFileSync('package.json', 'utf8')); + if (![version, `v${version}`].includes(process.env.RELEASE_TAG)) { + throw new Error('Release tag must match package.json version'); + } + if (version.includes('-') !== (process.env.IS_PRERELEASE === 'true')) { + throw new Error('Release prerelease flag must match package.json version'); + } + NODE - name: Install dependencies run: pnpm install --frozen-lockfile - - name: Build - run: pnpm run build + # prepack runs lint, type checks, unit tests and the build without credentials. + - name: Pack + run: pnpm pack --out package.tgz - - uses: simenandre/publish-with-pnpm@d1c054e288970d151b70e430a316cc7d62cf08c5 # v2.0.0 + - name: Upload package + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - npm-auth-token: ${{ secrets.NPM_TOKEN }} + name: npm-package + path: package.tgz + if-no-files-found: error + retention-days: 7 + + publish: + needs: build + runs-on: ubuntu-latest + timeout-minutes: 10 + permissions: + id-token: write + steps: + - name: Download package + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: npm-package + + - name: Install Node.js + uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + node-version: "26" + package-manager-cache: false + registry-url: https://registry.npmjs.org/ + + - name: Publish to npm + run: npm publish ./package.tgz --ignore-scripts --provenance --access public --tag "$NPM_DIST_TAG" + env: + NPM_DIST_TAG: ${{ github.event.release.prerelease && 'next' || 'latest' }}