From abe282eb23d39b8721d44c40257f74b92573259c Mon Sep 17 00:00:00 2001 From: Julien Ripouteau Date: Wed, 11 Nov 2026 22:19:25 +0000 Subject: [PATCH 1/3] ci: release packages with changesets and npm trusted publishing Add a release workflow on main. While changesets are pending, it opens or updates a "chore: release" pull request. Once that pull request is merged, it packs the packages whose version is not on npm yet and publishes them with npm trusted publishing (OIDC), then creates git tags and GitHub releases. Only the publish job gets id-token: write. Amp-Thread-ID: https://ampcode.com/threads/T-01a1cc89-88ff-735a-b0e6-546b99965804 --- .github/workflows/release.yml | 124 ++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..c8a6262 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,124 @@ +name: Release + +on: + push: + branches: + - main + +# Each job declares the permissions it needs +permissions: {} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + +jobs: + select-mode: + runs-on: ubuntu-latest + outputs: + mode: ${{ steps.select-mode.outputs.mode }} + publish-plan-artifact-id: ${{ steps.select-mode.outputs.publish-plan-artifact-id }} + permissions: + contents: read + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + + - uses: pnpm/action-setup@v6 + + - uses: actions/setup-node@v7 + with: + node-version: 24 + package-manager-cache: false + + - run: pnpm install --frozen-lockfile + + - name: Select Changesets mode + id: select-mode + uses: changesets/action/select-mode@v2 + + # Opens or updates the "chore: release" pull request while changesets are pending + version: + if: needs.select-mode.outputs.mode == 'version' + needs: select-mode + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + + - uses: pnpm/action-setup@v6 + + - uses: actions/setup-node@v7 + with: + node-version: 24 + package-manager-cache: false + + - run: pnpm install --frozen-lockfile + + - name: Version packages + uses: changesets/action/version@v2 + with: + commit-message: 'chore: release' + pr-title: 'chore: release' + + # Builds and packs the packages whose version is not on npm yet + pack: + if: needs.select-mode.outputs.mode == 'publish' + needs: select-mode + runs-on: ubuntu-latest + outputs: + pack-dir-artifact-id: ${{ steps.pack.outputs.pack-dir-artifact-id }} + permissions: + contents: read + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + + - uses: pnpm/action-setup@v6 + + - uses: actions/setup-node@v7 + with: + node-version: 24 + package-manager-cache: false + + - run: pnpm install --frozen-lockfile + + - run: pnpm build + + - name: Pack packages + id: pack + uses: changesets/action/pack@v2 + with: + publish-plan-artifact-id: ${{ needs.select-mode.outputs.publish-plan-artifact-id }} + + # Publishes with npm trusted publishing (OIDC), then creates git tags and GitHub releases + publish: + needs: pack + runs-on: ubuntu-latest + permissions: + contents: write + id-token: write + steps: + - uses: actions/checkout@v7 + with: + persist-credentials: false + + - uses: pnpm/action-setup@v6 + + - uses: actions/setup-node@v7 + with: + node-version: 24 + package-manager-cache: false + + - run: pnpm install --frozen-lockfile + + - name: Publish packages + uses: changesets/action/publish@v2 + with: + pack-dir-artifact-id: ${{ needs.pack.outputs.pack-dir-artifact-id }} + create-github-releases: true From 28ae30396418d6edc3a82d9f0b4048ff2bf62217 Mon Sep 17 00:00:00 2001 From: Julien Ripouteau Date: Wed, 11 Nov 2026 22:26:29 +0000 Subject: [PATCH 2/3] test: fix flaky deleteByTag bus test A tag invalidation counts entries created in the same millisecond as invalidated. When cache3 recomputed baz in the same millisecond as the invalidation of tag x, the next read invalidated it again and returned 3333 instead of 333. Wait after the invalidation, as the neighbouring test does. Amp-Thread-ID: https://ampcode.com/threads/T-01a1cc89-88ff-735a-b0e6-546b99965804 --- packages/bentocache/tests/tagging.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/bentocache/tests/tagging.spec.ts b/packages/bentocache/tests/tagging.spec.ts index 5d50672..a047d9d 100644 --- a/packages/bentocache/tests/tagging.spec.ts +++ b/packages/bentocache/tests/tagging.spec.ts @@ -145,6 +145,8 @@ test.group('Tagging | deleteByTag', () => { assert.deepEqual(baz1, 3) await cache1.deleteByTag({ tags: ['x'] }) + // An entry created in the same millisecond as the invalidation counts as invalidated + await sleep(10) const foo2 = await cache1.get({ key: 'foo' }) const bar2 = await cache2.getOrSet({ key: 'bar', factory: () => 222, tags: ['y', 'z'] }) From a7268d82b0d945ac0b27a590a8ffd58755a2ff31 Mon Sep 17 00:00:00 2001 From: Julien Ripouteau Date: Wed, 11 Nov 2026 22:29:44 +0000 Subject: [PATCH 3/3] test: fix the same flaky race in 'can remove by tag' Amp-Thread-ID: https://ampcode.com/threads/T-01a1cc89-88ff-735a-b0e6-546b99965804 --- packages/bentocache/tests/tagging.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/bentocache/tests/tagging.spec.ts b/packages/bentocache/tests/tagging.spec.ts index a047d9d..d7c0a7e 100644 --- a/packages/bentocache/tests/tagging.spec.ts +++ b/packages/bentocache/tests/tagging.spec.ts @@ -61,6 +61,8 @@ test.group('Tagging | deleteByTag', () => { assert.deepEqual(r3, 3) await cache.deleteByTag({ tags: ['x'] }) + // An entry created in the same millisecond as the invalidation counts as invalidated + await sleep(10) const r4 = await cache.get({ key: 'foo' }) const r5 = await cache.getOrSet({ key: 'bar', factory: () => 222, tags: ['y', 'z'] })