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
9 changes: 0 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,6 @@ jobs:
- name: Test with coverage
run: npm test

- name: Upload coverage to Codecov
if: ${{ !env.ACT }}
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/lcov.info
fail_ci_if_error: false
verbose: true

build:
name: Build
needs: gate
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Codecov — upload coverage on merge to main only.
# PR CI (ci.yml) runs tests but does not upload. See docs/ci-cd.md.
name: Codecov

on:
push:
branches:
- main

concurrency:
group: codecov-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

permissions:
contents: read

jobs:
coverage:
name: Upload coverage
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 24
cache: npm

- name: Install dependencies
run: npm ci

- name: Test with coverage
run: npm test

- name: Upload coverage to Codecov
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/lcov.info
fail_ci_if_error: false
verbose: true
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ const cache = createCache({
| `@b4moss/cachian/methods/set` | `set` |
| `@b4moss/cachian/methods/update` | `update` |
| `@b4moss/cachian/methods/upsert` | `upsert` |
| `@b4moss/cachian/methods/remove` | `remove` |
| `@b4moss/cachian/methods/remove` | `remove` (single key only) |
| `@b4moss/cachian/methods/has` | `has` |
| `@b4moss/cachian/methods/clear` | `clear` |
| `@b4moss/cachian/methods/purge` | `purge` |

Entry shape in storage: `{ expiresAt: number, data: unknown, createdAt?: number }` (localStorage stores JSON strings; IndexedDB stores objects). New `set` writes always include `createdAt`.
Expand Down Expand Up @@ -106,6 +105,11 @@ await cache.purge({ expired: true });

Legacy entries without `createdAt` are left alone by `olderThan` and absolute-time modes, but **are removed** by `{ expired: true }` when `expiresAt` is past. Mixing `olderThan` with `createdBefore` / `createdAfter`, or mixing `{ expired: true }` with any other mode, throws `TypeError`.

## Breaking changes (v0.6)

- Public `clear()` MethodDef / `@b4moss/cachian/methods/clear` removed — use `purge({ all: true })`.
- `remove(key)` deletes a **single** key only; multi-key deletion is `purge({ keys })`.

## Breaking changes (v0.4)

- `createCache()` no longer returns a fixed full API; pass `driver` + `methods`.
Expand Down
8 changes: 6 additions & 2 deletions README_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ const cache = createCache({
| `@b4moss/cachian/methods/set` | `set` |
| `@b4moss/cachian/methods/update` | `update` |
| `@b4moss/cachian/methods/upsert` | `upsert` |
| `@b4moss/cachian/methods/remove` | `remove` |
| `@b4moss/cachian/methods/remove` | `remove`(単一キーのみ) |
| `@b4moss/cachian/methods/has` | `has` |
| `@b4moss/cachian/methods/clear` | `clear` |
| `@b4moss/cachian/methods/purge` | `purge` |

保存形式は `{ expiresAt: number, data: unknown, createdAt?: number }`(localStorage は JSON 文字列、IndexedDB はオブジェクト)。新規 `set` では必ず `createdAt` を付与します。
Expand Down Expand Up @@ -106,6 +105,11 @@ await cache.purge({ expired: true });

`createdAt` の無い旧エントリは `olderThan` および絶対時刻モードでは残りますが、`{ expired: true }` では `expiresAt` が過去なら **削除されます**。`olderThan` と `createdBefore` / `createdAfter` の混在、および `{ expired: true }` と他モードの混在は `TypeError` になります。

## 破壊的変更(v0.6)

- 公開 `clear()` MethodDef / `@b4moss/cachian/methods/clear` を廃止 — 全削除は `purge({ all: true })`
- `remove(key)` は **単一キーのみ**削除。複数キー削除は `purge({ keys })`

## 破壊的変更(v0.4)

- `createCache()` は固定フル API を返さず、`driver` + `methods` の指定が必須
Expand Down
21 changes: 17 additions & 4 deletions docs/ci-cd.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ feature/* / cursor/*
PR → develop / dev-* ← CI(Gate → Test ‖ Build → "Test & Build")
│
▼
main ← Scorecard・既定ブランチ・v* タグはここからのみ
main ← Codecov アップロード・Scorecard・既定ブランチ・v* タグはここからのみ
```

- 日常の統合先: `develop`(必要時は版付き `dev-*`)
- リリース: `main` に取り込み、`main` 上で `vX.Y.Z`(または `vX.Y.Z-rc.N`)をタグ付け
- `main` 向け PR では CI に依存しない(安定ブランチ向けの参考リポジトリと同じ扱い)
- Codecov は **`main` への push(= `main` へのマージ後)のみ**。PR CI ではアップロードしない

## ローカルゲート(PR 前必須)

Expand All @@ -45,7 +46,7 @@ npm run ci:local
act pull_request -W .github/workflows/ci.yml
```

既定は [`.actrc`](../.actrc)。`act` 実行時はゲートが Test/Build を必ず実行します(`ACT=true`)。Codecov は `ACT` 時にスキップします。
既定は [`.actrc`](../.actrc)。`act` 実行時はゲートが Test/Build を必ず実行します(`ACT=true`)。Codecov は `main` 専用の別ワークフローであり、ローカル `act` の対象外です。

Docker が無い環境(一部の Cloud Agent など):

Expand All @@ -65,7 +66,8 @@ npm run ci:local:fallback # npm ci && npm test && npm run build

| ファイル | 役割 | 状態 |
|----------|------|------|
| `.github/workflows/ci.yml` | PR CI: Gate → Test ‖ Build → 集約 **Test & Build** | 実装済み |
| `.github/workflows/ci.yml` | PR CI: Gate → Test ‖ Build → 集約 **Test & Build**(Codecov アップロードなし) | 実装済み |
| `.github/workflows/codecov.yml` | `main` への push → test + `coverage/lcov.info` を Codecov へアップロード | 実装済み |
| `.github/workflows/codeql.yml` | CodeQL(`develop`/`dev-*` PR、`main` push、週次) | 予定 |
| `.github/workflows/scorecard.yml` | OpenSSF Scorecard(`main` + schedule) | 実装済み |
| `.github/workflows/release-on-tag.yml` | `v*` push → GitHub Release 作成 | 実装済み |
Expand All @@ -87,7 +89,17 @@ npm run ci:local:fallback # npm ci && npm test && npm run build
| required check 名 | 集約ジョブ **`Test & Build`** |
| Node | `24`(engines `>=24`)、`npm ci`、Actions は SHA ピン |

Codecov のカバレッジパス: `coverage/lcov.info`(単一パッケージルート)。
### Codecov(main のみ)

| 項目 | ルール |
|------|--------|
| トリガ | `main` への `push`(`main` へのマージ) |
| 発火しない例 | PR CI(`ci.yml`)、他ブランチへの push |
| 手順 | `npm ci` → `npm test` → `coverage/lcov.info` をアップロード |
| 認証 | 任意の `CODECOV_TOKEN`、`id-token: write` による OIDC |
| ステータス | informational(`codecov.yml`)、`fail_ci_if_error: false` |

カバレッジパス: `coverage/lcov.info`(単一パッケージルート)。README の Coverage バッジは既定ブランチ(`main`)を参照する。

### CD — npm publish

Expand Down Expand Up @@ -130,5 +142,6 @@ Codecov のカバレッジパス: `coverage/lcov.info`(単一パッケージ
ローカル変更 → npm run ci:local(必須)
→ develop / dev-* へ PR
→ CI Gate → Test ‖ Build → "Test & Build"
merge → main → Codecov アップロード(バッジ用カバレッジ)
main 上のタグ v* → Release → Publish(CI 再利用 or 再検証)→ npm
```
21 changes: 17 additions & 4 deletions docs/ci-cd.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ feature/* / cursor/*
PR → develop / dev-* ← CI (Gate → Test ‖ Build → "Test & Build")
│
▼
main ← Scorecard; stable default; tags v* only from here
main ← Codecov upload; Scorecard; stable default; tags v* only from here
```

- Day-to-day integration: `develop` (and versioned `dev-*` when needed).
- Release cut: merge into `main`, then tag `vX.Y.Z` (or prerelease `vX.Y.Z-rc.N`) on `main`.
- Do **not** rely on CI for PRs into `main` (same rule as the reference for stable branches).
- Codecov runs **only** on push to `main` (i.e. after merge into `main`), not on PR CI.

## Local gate (required before PR)

Expand All @@ -45,7 +46,7 @@ npm run ci:local
act pull_request -W .github/workflows/ci.yml
```

Defaults live in [`.actrc`](../.actrc). Under `act`, the CI gate always runs Test/Build (`ACT=true`). Codecov is skipped when `ACT` is set.
Defaults live in [`.actrc`](../.actrc). Under `act`, the CI gate always runs Test/Build (`ACT=true`). Codecov is a separate `main`-only workflow and is not part of local `act`.

Without Docker (some Cloud Agent environments):

Expand All @@ -65,7 +66,8 @@ Do not open or update a PR while this gate is failing.

| File | Role | Status |
|------|------|--------|
| `.github/workflows/ci.yml` | PR CI: Gate → Test ‖ Build → aggregate **Test & Build** | Implemented |
| `.github/workflows/ci.yml` | PR CI: Gate → Test ‖ Build → aggregate **Test & Build** (no Codecov upload) | Implemented |
| `.github/workflows/codecov.yml` | Push to `main` → test + upload `coverage/lcov.info` to Codecov | Implemented |
| `.github/workflows/codeql.yml` | CodeQL on PR to `develop`/`dev-*`, push to `main`, weekly | Planned |
| `.github/workflows/scorecard.yml` | OpenSSF Scorecard on `main` + schedule | Implemented |
| `.github/workflows/release-on-tag.yml` | Push `v*` → create GitHub Release | Implemented |
Expand All @@ -87,7 +89,17 @@ Do not open or update a PR while this gate is failing.
| Required check name | Aggregate job **`Test & Build`** |
| Node | `24` (engines `>=24`), `npm ci`, pin Actions by SHA |

Coverage path for Codecov: `coverage/lcov.info` (single package root; not a workspace path).
### Codecov (main only)

| Item | Rule |
|------|------|
| Trigger | `push` to `main` (merge into `main`) |
| Not triggered | PR CI (`ci.yml`); push to other branches |
| Steps | `npm ci` → `npm test` → upload `coverage/lcov.info` |
| Auth | Optional `CODECOV_TOKEN`; OIDC via `id-token: write` |
| Status | Informational (`codecov.yml`); `fail_ci_if_error: false` |

Coverage path: `coverage/lcov.info` (single package root; not a workspace path). README Coverage badge reads the default branch (`main`).

### CD — npm publish

Expand Down Expand Up @@ -130,5 +142,6 @@ Until workflows run and the package is published, some badges may show unknown/e
local change → npm run ci:local (must pass)
→ open PR to develop / dev-*
→ CI Gate → Test ‖ Build → "Test & Build"
merge → main → Codecov upload (coverage for badge)
tag v* on main → Release → Publish (reuse CI or re-verify) → npm
```
Loading
Loading