Skip to content

fix: restore yarn test and yarn package on Yarn 4 - #8

Merged
MaikoTan merged 2 commits into
masterfrom
maikotan-upgraded-succotash
Oct 5, 2026
Merged

MaikoTan merged 2 commits into
masterfrom
maikotan-upgraded-succotash

Conversation

@MaikoTan

@MaikoTan MaikoTan commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Why

The previous toolchain upgrade moved the repo to Yarn 4, which silently broke both yarn test and yarn package. Neither command was covered by CI, so the breakage went unnoticed.

The root cause of the packaging failure is that Yarn 4 removed yarn list --prod --json, which @vscode/vsce shells out to whenever it detects a yarn.lock. This also meant the publish workflow was broken: both registry steps packaged independently and both would have failed the same way.

What was broken

yarn package failed with Command failed: yarn list --prod --json.

yarn test failed with two independent problems, the first masking the second:

  1. tsconfig.json excluded src/test/** from compilation, so out/test/runTest.js was never emitted and the entry point simply did not exist.
  2. Once the exclude was removed, glob v13 no longer exposes a callable default export, so import * as glob followed by glob(...) threw TypeError: glob is not a function. Rewritten to use globSync, which also lets the nested Promise collapse into a flat async function.

CI updates

  • build.yml: enable corepack and use yarn install --immutable, since bare yarn install does not verify the lockfile. Added xvfb-run -a yarn test; CI was not running tests at all, which is how this regressed unnoticed.
  • publish.yml: package once with yarn package and pass that same .vsix to both registries via extensionFile. Previously each registry step packaged on its own, so the two uploads could not be guaranteed byte-identical. Also bumped the HaaLeo action v1 -> v2 and Node 18 -> 20.
  • tagger.yml: replaced the removed ::set-output with $GITHUB_OUTPUT, and fixed tag detection. It compared git tag -l output using a substring match and ran on a shallow clone, so it could miss existing tags and try to push a duplicate.

Points worth reviewing

  • --no-yarn disables vsce's production-dependency scan. This extension ships zero runtime dependencies, so nothing is lost today. If runtime deps are ever added, they will no longer be validated or bundled automatically and the packaging model needs revisiting.
  • .vscodeignore now excludes .yarn/**. This keeps the 239 KB install-state.gz out of the package, cutting the vsix from 273 KB to 34 KB.
  • publish.yml hardcodes the vsix filename as koishi-dev-${version}.vsix, derived from the name field in package.json. Renaming the extension means updating that line too.
  • yarn.lock metadata moved v8 -> v9, so this needs a Yarn 4 toolchain on both ends.

Verification

All commands run green locally: yarn install --immutable, yarn test (1 passing), yarn package (21 files, 34 KB), and all three workflow files parse as valid YAML.

MaikoTan and others added 2 commits October 5, 2026 18:36
Yarn 4 dropped yarn list --prod --json, which vsce invokes when it detects a yarn.lock. That broke yarn package outright and would also break the publish workflow, which packaged twice via the HaaLeo action.

Fixes:
- package: pass --no-yarn so vsce stops shelling out to the removed command
- tsconfig: stop excluding src/test, which meant out/test/runTest.js was never emitted
- src/test/suite/index.ts: glob v13 no longer has a callable default export; use globSync and drop the nested Promise
- .gitignore: ignore .vscode-test/ (the downloaded VS Code archive)
- .vscodeignore: exclude .yarn/** to keep install-state.gz out of the vsix (273 KB -> 34 KB)

CI:
- enable corepack and pin yarn via packageManager, use yarn install --immutable so the lockfile is actually verified
- run yarn test under xvfb-run; CI was not running tests at all
- publish: package once and hand the same vsix to both registries via extensionFile, so they ship identical bytes
- tagger: replace the removed ::set-output with GITHUB_OUTPUT, and fix tag detection, which used a substring match against tags that a shallow clone could not see

lockfile regenerated for Yarn 4 (metadata v8 -> v9).
Yarn 4 no longer runs the implicit pretest lifecycle hook, so
out/test/runTest.js was never built and CI failed with
Cannot find module .../out/test/runTest.js.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@MaikoTan
MaikoTan merged commit f7d4746 into master Oct 5, 2026
2 checks passed
@MaikoTan
MaikoTan deleted the maikotan-upgraded-succotash branch October 5, 2026 10:42
MaikoTan added a commit that referenced this pull request Oct 5, 2026
master picked up #8, which independently fixes the same Yarn 4 problems this
branch had worked around, and does so more completely: it pins yarn via
packageManager, regenerates the lockfile for Yarn 4, and makes CI actually run
the tests and the package step.

Resolved by taking #8's version of both conflicts:

- package.json: #8 folds compile and lint into `test` and passes --no-yarn to
  vsce. Yarn 4 no longer runs the implicit pretest hook, so the previous
  pretest script would have silently stopped running. Re-applied only this
  branch's feature metadata (categories, keywords, activationEvents, the yaml
  dependency).
- src/test/suite/index.ts: #8's globSync version is simpler and equivalent.
  Kept the .sort() this branch had, so test order does not depend on the order
  the filesystem reports.

yarn.lock needed no resolution and came out byte-identical to this branch's:
both sides converged on the same content.

Verified the same way CI will: yarn install --immutable, yarn test (63 passing),
and yarn package, which now succeeds and produces a 254 KB vsix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant