MCPcopy Create free account
hub / github.com/dmno-dev/bumpy / ciCheckCommand

Function ciCheckCommand

packages/bumpy/src/commands/ci.ts:118–286  ·  view source on GitHub ↗
(rootDir: string, opts: CheckOptions)

Source from the content-addressed store, hash-verified

116 * Designed for PR workflows — shows what would be released and optionally comments on the PR.
117 */
118export async function ciCheckCommand(rootDir: string, opts: CheckOptions): Promise<void> {
119 // Seed an empty artifact first so it always exists for the workflow_run poster,
120 // regardless of which branch below we return from.
121 if (opts.emitComment) initCommentArtifact(opts.emitComment);
122
123 const config = await loadConfig(rootDir);
124 const { packages } = await discoverWorkspace(rootDir, config);
125 const depGraph = new DependencyGraph(packages);
126 // Read channel dirs too: on promotion (channel → main) and graduation (channel →
127 // channel) PRs, the pending bump files live in `.bumpy/<channel>/`. Feature PRs
128 // never have shipped channel files in their diff vs the PR base, so this only
129 // surfaces files where they're genuinely pending.
130 const { bumpFiles: allBumpFiles, errors: parseErrors } = await readBumpFiles(rootDir, {
131 channels: channelNames(config),
132 });
133
134 // Skip on the version PR branch (and channel release PR branches) — they move/consume
135 // bump files by design
136 const prBranchName = detectPrBranch(rootDir);
137 const channels = resolveChannels(config);
138 const releasePrBranches = new Set([
139 config.versionPr.branch,
140 ...[...channels.values()].map((c) => c.versionPr.branch),
141 ]);
142 if (prBranchName && releasePrBranches.has(prBranchName)) {
143 log.dim(' Skipping — this is a release PR branch.');
144 return;
145 }
146
147 const inCI = !!process.env.CI;
148 const shouldComment = opts.comment ?? inCI;
149 const prNumber = detectPrNumber();
150 const pm = await detectPackageManager(rootDir);
151
152 // Filter to only bump files added/modified in this PR.
153 // For PRs targeting a channel branch, compare against that branch (GITHUB_BASE_REF),
154 // not baseBranch — otherwise the whole cycle's changes would show up.
155 const compareBranch = process.env.GITHUB_BASE_REF || config.baseBranch;
156 // If this PR targets a channel branch, the comment makes that explicit (prerelease,
157 // dist-tag) rather than implying a normal stable release.
158 const prChannel = matchChannelByBranch(config, process.env.GITHUB_BASE_REF || null);
159 const changedFiles = getChangedFiles(rootDir, compareBranch);
160 const { branchBumpFiles: prBumpFiles, emptyBumpFileIds } = filterBranchBumpFiles(
161 allBumpFiles,
162 changedFiles,
163 rootDir,
164 parseErrors,
165 );
166
167 // Surface any parse errors
168 if (parseErrors.length > 0) {
169 for (const err of parseErrors) {
170 log.error(err);
171 }
172 }
173
174 if (prBumpFiles.length === 0) {
175 // An empty bump file signals intentionally no releases needed

Callers 1

mainFunction · 0.85

Calls 15

loadConfigFunction · 0.90
discoverWorkspaceFunction · 0.90
readBumpFilesFunction · 0.90
channelNamesFunction · 0.90
resolveChannelsFunction · 0.90
detectPackageManagerFunction · 0.90
matchChannelByBranchFunction · 0.90
getChangedFilesFunction · 0.90
filterBranchBumpFilesFunction · 0.90
findChangedPackagesFunction · 0.90
assembleReleasePlanFunction · 0.90
colorizeFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…