moonrepo / moon

A build system and monorepo management tool for the web ecosystem, written in Rust.
https://moonrepo.dev/moon
MIT License
2.88k stars 157 forks source link

[bug] Dependant change does not trigger targets for main app #1588

Open MichalCiesliczka opened 2 months ago

MichalCiesliczka commented 2 months ago

Describe the bug

Change in dependant does not trigger target with --affected run in the main app.

I have one app and one library in JS moon workspace. Both have test task and app depends on package (both explicitly and implicitly <through package.json and workspace:^ dependency>).

apps/webApp/moon.yml

language: 'javascript'
type: 'application'
dependsOn:
  - 'simplePackage'
tasks:
  test:
   command: "yarn test"

packlages/simple/moon.yml

language: 'javascript'
type: 'library'
tasks:
  test:
   command: 'yarn test'

Steps to reproduce

  1. Set up 1 application and 1 library, both with test task.
  2. Import library as dependency to the application AKA make application depends on library
  3. Introduce some changes to the library
  4. Run moon :test --affected
  5. Only library's tests are run, even though this change affects the app

Expected behavior

Once shared library has any change also apps/other packages using this one should be triggered in affected way. Usually introducing changes to shared code requires rebuild of the main app

Screenshots

Screenshot 2024-07-26 at 13 19 37

Environment

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M1 Pro
    Memory: 36.83 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    Yarn: 3.6.1 - ~/.nvm/versions/node/v20.11.1/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
    Watchman: 2024.07.01.00 - /opt/homebrew/bin/watchman
  Managers:
    Homebrew: 4.3.9 - /opt/homebrew/bin/brew
    pip3: 24.0 - /opt/homebrew/bin/pip3
    RubyGems: 3.0.3.1 - /Users/michalciesliczka/.rbenv/shims/gem
  Utilities:
    Make: 3.81 - /usr/bin/make
    GCC: 15.0.0 - /usr/bin/gcc
    Git: 2.39.3 - /usr/bin/git
    Clang: 15.0.0 - /usr/bin/clang
    Curl: 8.6.0 - /usr/bin/curl
    OpenSSL: 3.3.1 - /opt/homebrew/bin/openssl
  Servers:
    Apache: 2.4.58 - /usr/sbin/apachectl
  Virtualization:
    Docker: 25.0.3 - /usr/local/bin/docker
    Docker Compose: 2.24.6 - /usr/local/bin/docker-compose
  SDKs:
    iOS SDK:
      Platforms: DriverKit 23.5, iOS 17.5, macOS 14.5, tvOS 17.5, visionOS 1.2, watchOS 10.5
    Android SDK:
      API Levels: 33, 34
      Build Tools: 33.0.0, 34.0.0
      System Images: android-30 | Google Play ARM 64 v8a, android-34 | Google APIs ARM 64 v8a
  IDEs:
    Android Studio: 2022.3 AI-223.8836.35.2231.10811636
    VSCode: 1.91.1 - /usr/local/bin/code
    Vim: 9.0 - /usr/bin/vim
    Xcode: 15.4/15F31d - /usr/bin/xcodebuild
  Languages:
    Bash: 3.2.57 - /bin/bash
    Go: 1.21.2 - /usr/local/go/bin/go
    Java: 17.0.11 - /Users/michalciesliczka/.jenv/shims/javac
    Perl: 5.34.1 - /usr/bin/perl
    Python3: 3.12.4 - /opt/homebrew/bin/python3
    Ruby: 2.6.10 - /Users/michalciesliczka/.rbenv/shims/ruby
  Databases:
    SQLite: 3.39.2 - /Users/michalciesliczka/Library/Android/sdk/platform-tools/sqlite3
  Browsers:
    Brave Browser: 125.1.66.113
    Chrome: 126.0.6478.183
    Safari: 17.5
  Monorepos:
    Yarn Workspaces: 3.6.1

Additional context

milesj commented 2 months ago

Yeah right now --affected is purely a match against touched files and doesn't take project relations into account. We can look into that for the next release.