diff --git a/actions/changeset/check-coverage/action.yaml b/actions/changeset/check-coverage/action.yaml index 07f97209..d5bdd78a 100644 --- a/actions/changeset/check-coverage/action.yaml +++ b/actions/changeset/check-coverage/action.yaml @@ -7,7 +7,8 @@ description: | - editing files inside a workspace package (e.g. block code under packages//) without adding that package to the changeset; - bumping a catalog version in pnpm-workspace.yaml without a matching - bump for the workflow packages that consume it via `catalog:`. + bump for packages that consume it as a runtime dependency via + `catalog:` (devDependencies / build-only tooling are not flagged). Runs after `pnpm install`. Requires the runner to have `pnpm`, `jq`, and `yq` (mikefarah, v4+) on PATH — all pre-installed on GitHub-hosted diff --git a/actions/changeset/check-coverage/check-coverage.sh b/actions/changeset/check-coverage/check-coverage.sh index a7ad8311..aa83adae 100755 --- a/actions/changeset/check-coverage/check-coverage.sh +++ b/actions/changeset/check-coverage/check-coverage.sh @@ -10,9 +10,18 @@ # git-diff check itself. # # 2. Catalog version bumps in pnpm-workspace.yaml: for each touched -# catalog key, find workspace packages that consume it via +# catalog key, find workspace packages that consume it as a *runtime* +# dependency (`dependencies` or `peerDependencies`) via # `"": "catalog:..."` and require those packages to bump. # +# devDependencies and optionalDependencies are intentionally NOT +# considered. A bump to build-only tooling (e.g. @platforma-sdk/block-tools +# in a block's model, @platforma-sdk/tengo-builder in its workflow) does +# not change the published artifact's runtime, and `pnpm changeset` does +# not flag those packages either. Requiring a bump for them produced +# false positives on PRs that only touched an unrelated package (e.g. the +# UI) but happened to carry a catalog bump for shared build tooling. +# # Skips private (unpublished) workspace packages — they never appear in # the changeset's release set. # @@ -186,8 +195,12 @@ if git diff --name-only "origin/${BASE_BRANCH}...HEAD" | grep -qx 'pnpm-workspac [ "${pkg_is_private[${name}]:-false}" = 'true' ] && continue pj="${pkg_name_to_dir[${name}]}/package.json" [ -f "${pj}" ] || continue + # Runtime sections only. devDependencies/optionalDependencies are + # excluded on purpose — bumping build-only tooling consumed via + # `catalog:` (block-tools, tengo-builder, …) doesn't alter the + # published runtime, so requiring a release for it is a false positive. if jq -e --arg k "${key}" ' - [.dependencies?, .devDependencies?, .peerDependencies?, .optionalDependencies?] + [.dependencies?, .peerDependencies?] | map(select(. != null) | to_entries) | add // [] | map(select(.key == $k and ((.value // "") | startswith("catalog:")))) | length > 0 diff --git a/actions/changeset/check-coverage/test/coverage.bats b/actions/changeset/check-coverage/test/coverage.bats index 369a6d98..593eb3f1 100644 --- a/actions/changeset/check-coverage/test/coverage.bats +++ b/actions/changeset/check-coverage/test/coverage.bats @@ -116,6 +116,20 @@ setup() { [ "${status}" -eq 0 ] } +@test "catalog bump consumed only as a devDependency does not flag the consumer" { + # is-string is a runtime dependency of pkg-c but only a devDependency of + # pkg-dev. Bumping it must still flag pkg-c (runtime) yet leave pkg-dev + # alone — mirrors a block whose build-tool catalog dep (block-tools / + # tengo-builder, both devDependencies) bumped without the package itself + # being touched. Before the runtime-only scoping this spuriously flagged + # pkg-dev. + bump_catalog 'is-string' '^1.0.8' + run_check + [ "${status}" -eq 1 ] + [[ "${output}" == *'@check-coverage-test/pkg-c'* ]] + [[ "${output}" != *'@check-coverage-test/pkg-dev'* ]] +} + # --------------------------------------------------------------------------- # Empty-changeset corner case. # --------------------------------------------------------------------------- diff --git a/actions/changeset/check-coverage/test/fixtures/minimal-workspace/packages/pkg-dev/index.js b/actions/changeset/check-coverage/test/fixtures/minimal-workspace/packages/pkg-dev/index.js new file mode 100644 index 00000000..100aff54 --- /dev/null +++ b/actions/changeset/check-coverage/test/fixtures/minimal-workspace/packages/pkg-dev/index.js @@ -0,0 +1,3 @@ +// Consumes is-string only as a devDependency (build-tooling stand-in). +// A catalog bump for is-string must not require this package to be released. +module.exports = {}; diff --git a/actions/changeset/check-coverage/test/fixtures/minimal-workspace/packages/pkg-dev/package.json b/actions/changeset/check-coverage/test/fixtures/minimal-workspace/packages/pkg-dev/package.json new file mode 100644 index 00000000..ab988896 --- /dev/null +++ b/actions/changeset/check-coverage/test/fixtures/minimal-workspace/packages/pkg-dev/package.json @@ -0,0 +1,8 @@ +{ + "name": "@check-coverage-test/pkg-dev", + "version": "1.0.0", + "main": "index.js", + "devDependencies": { + "is-string": "catalog:" + } +}