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
2 changes: 1 addition & 1 deletion eng/scripts/detect-affected.config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"submodulePath": "core",
"ignore": ["**/test/**", "**/tests/**", "**/*.test.ts", "**/*.md"],
"sharedExtra": [".github/actions/setup/**"],
"sharedExtra": [".github/actions/setup/**", "pnpm-workspace.yaml"],
Comment thread
msyyc marked this conversation as resolved.
"targets": {
"python": {
"package": "@azure-tools/typespec-python",
Expand Down
10 changes: 10 additions & 0 deletions eng/scripts/detect-affected.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ describe("computeAffected", () => {
expect(computeAffected(NONE, ["core"], CONFIG)).toEqual(ALL_AFFECTED);
});

// Azure/typespec-azure#5010: catalog upstreams such as
// `@typespec/http-client-python` are not workspace packages, so pnpm reports no
// affected package when one is bumped. The root workspace file must trigger
// every target on its own.
it("pnpm-workspace.yaml change triggers all targets", () => {
expect(computeAffected(NONE, ["pnpm-workspace.yaml", "pnpm-lock.yaml"], CONFIG)).toEqual(
ALL_AFFECTED,
);
});

it("unrelated root file change triggers nothing", () => {
expect(computeAffected(NONE, ["README.md", "package.json"], CONFIG)).toEqual(NONE_AFFECTED);
});
Expand Down
14 changes: 12 additions & 2 deletions eng/scripts/detect-affected.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ import { pathToFileURL } from "node:url";
// TO ADD A NEW UPSTREAM LIBRARY (e.g. a new typespec-azure-* package that an
// emitter depends on): nothing to do — the workspace graph picks it up
// automatically as soon as the emitter declares the dependency.
//
// EXCEPTION — upstreams consumed from npm via the pnpm catalog (e.g.
// `@typespec/http-client-python`): these are not workspace packages, so the
// graph cannot see them. Bumping one edits only the root `pnpm-workspace.yaml`,
// which pnpm attributes to the root package alone, leaving every emitter
// unaffected (Azure/typespec-azure#5010). `pnpm-workspace.yaml` is therefore in
// `sharedExtra`: any change to it triggers all targets. It changes rarely and
// always affects dependency resolution repo-wide, so this is deliberately blunt
// rather than trying to work out which catalog entry moved.
// -----------------------------------------------------------------------------

interface Target {
Expand All @@ -35,7 +44,7 @@ interface Config {
submodulePath: string;
/** Globs whose sole change should NOT trigger anything; passed to pnpm via `--changed-files-ignore-pattern`. */
ignore: string[];
/** Paths that trigger every target (shared CI infrastructure). */
/** Paths that trigger every target (shared CI infra + the root pnpm workspace file). */
sharedExtra: string[];
targets: Record<string, Target>;
}
Expand Down Expand Up @@ -79,7 +88,8 @@ export function matchesAny(file: string, patterns: string[]): boolean {
* A target fires on any of three signals: its package is in the pnpm-derived
* affected set, OR one of the two things the graph cannot see changed — the
* `core` submodule pointer (which every emitter depends on, so it triggers all
* targets), or a non-package `extra` CI-infra path.
* targets), or an `extra` path outside any package (CI infra, and the root
* `pnpm-workspace.yaml` — see the header comment).
*
* @param affectedPackages Target package OR any graph-dependent of a meaningfully
* changed package (from `pnpm --filter "...[base]"`).
Expand Down
Loading