Skip to content

Conversation

@david-luna
Copy link
Contributor

@david-luna david-luna commented Nov 6, 2025

ref: #3136

This is an alternative to using a cache for speeding up the CI time spent in PRs.

This approach uses a different way to resolve which packages need to be compiled and tested. The result is we get only the list of packages which sources are modified and this is what we pass to the nx run-many command.

Why nx affected -t compile compiles so many packages?

The reason is because internally the command takes in consideration nx.json dependencies on tasks. The script iterates over each package and runs the "compile" task if:

  • the package itself is modified
  • the compile task depends on another compile task in another package that has been modified

So nx.json is expanding the dependency graph. Now we know a bit more about the behaviour of the command.

Which solution is proposed?

The command nx affected if called without params gives a list with only the changed packages (which is what we want). Then we can pass that list to nx run-many command to narrow the list of packages that should run the given task (compile, test). Here is an example

npx nx run-many -t compile -p "@opentelemetry/instrumentation-aws-sdk" "@opentelemetry/instrumentation-undici"
   ✔  nx run @opentelemetry/instrumentation-aws-sdk:version:update (923ms)
   ✔  nx run @opentelemetry/instrumentation-undici:version:update (926ms)
   ✔  nx run @opentelemetry/contrib-test-utils:compile (3s)
   ✔  nx run @opentelemetry/instrumentation-undici:compile (3s)
   ✔  nx run @opentelemetry/instrumentation-aws-sdk:compile (3s)

you can see that the command takes care of dependencies like @opentelemetry/contrib-test-utils

@david-luna
Copy link
Contributor Author

david-luna commented Nov 6, 2025

In https://github.com/open-telemetry/opentelemetry-js-contrib/actions/runs/19137279065/job/54692601282?pr=3208 some of the test fails because network issues in npm ci. But the list of packages on compilation and test are what I think we're looking for.

Commit 20e7409 added a change in pg instrumentation and the contrib-test-utils package has been compiled since its a dependency of the instrumentation.

@david-luna david-luna marked this pull request as ready for review November 6, 2025 14:30
@david-luna david-luna requested a review from a team as a code owner November 6, 2025 14:30
@trentm trentm removed the request for review from maryliag November 6, 2025 17:27

// No need to instrument files/modules
protected override init() {
override init() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: mismerge? (Same thing below)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this change on purpose to validate the workflow was picking correctly. Will remove it before merging. Thanks for the heads up

@david-luna
Copy link
Contributor Author

In a conversation with @trentm we agreed that this approach is not what we want in some situations. An example is if @opentelemetry/contrib-test-utils package is changed and no other then we need to run the tests for all packages that are depending on it because that change may break tests.

After that discussion I think the only packages we may want to skip compiling/testing if not changed is @opentelemetry/auto-instrumentations-node and @opentelemetry/auto-instrumentations-web so I think we could tell nx to ignore them if not modified

@david-luna david-luna marked this pull request as draft November 26, 2025 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants