moonrepo / moon

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

[feature] ```local: false``` still allows task to run outside CI #1580

Closed artsiommiksiuk closed 6 days ago

artsiommiksiuk commented 1 month ago

Describe the bug

I have a docker build process, and have two versions of a tasks - for local build and for ci build. Setting ci version to local: false still allows this task to be launched from local machine.

Steps to reproduce

tasks:
    build:
       script: echo 1
       local: true
    build-ci:
       script: echo 2
       local: false
➜  backend git:(moon-monorepo) ✗ moon node-python-docker:build         
1
▪▪▪▪ node-python-docker:build
▪▪▪▪ node-python-docker:build (3ms)

Tasks: 1 completed
 Time: 6ms

➜  backend git:(moon-monorepo) ✗ moon node-python-docker:build-ci
▪▪▪▪ node-python-docker:build-ci (47dfeeb3)
2
▪▪▪▪ node-python-docker:build-ci (3ms, 47dfeeb3)

Tasks: 1 completed
 Time: 20ms

Expected behavior

local: false marked task (build-ci) is not running locally.

Environment

  System:
    OS: macOS 14.4.1
    CPU: (12) arm64 Apple M3 Pro
    Memory: 119.02 MB / 36.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.11.1 - ~/.nvm/versions/node/v20.11.1/bin/node
    npm: 10.2.4 - ~/.nvm/versions/node/v20.11.1/bin/npm
    pnpm: 8.15.6 - /opt/homebrew/bin/pnpm
  Managers:
    Homebrew: 4.3.10 - /opt/homebrew/bin/brew
    pip3: 24.0 - /opt/homebrew/bin/pip3
    RubyGems: 3.0.3.1 - /usr/bin/gem
  Utilities:
    Bazel: 7.1.2 - /opt/homebrew/bin/bazel
    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.4.0 - /usr/bin/curl
    OpenSSL: 3.3.1 - /opt/homebrew/bin/openssl
  Servers:
    Apache: 2.4.58 - /usr/sbin/apachectl
  Virtualization:
    Docker: 25.0.4 - /opt/homebrew/bin/docker
    Docker Compose: 2.24.6 - /usr/local/bin/docker-compose
  IDEs:
    VSCode: 1.91.1 - /usr/local/bin/code
    Vim: 9.0 - /usr/bin/vim
    Xcode: /undefined - /usr/bin/xcodebuild
  Languages:
    Bash: 3.2.57 - /bin/bash
    Perl: 5.34.1 - /usr/bin/perl
    Python3: 3.12.4 - /opt/homebrew/bin/python3
    Ruby: 2.6.10 - /usr/bin/ruby
  Databases:
    PostgreSQL: 14.11 - /opt/homebrew/bin/postgres
    SQLite: 3.43.2 - /usr/bin/sqlite3
  Browsers:
    Chrome: 126.0.6478.183
    Safari: 17.4.1

Additional context

Probably something like localOnlyRun, ciOnlyRun options for a task will do better and more explicit.

But the overall feeling is that some advanced tasks filtering capabilities for their execution is missing, like with https://github.com/moonrepo/moon/issues/1538 request.

Would be nice to have more general solution to be able to set of tasks (same name union based) where each tasks is marked with some attributes, and then moon selects which version of a task to run based on the attributes match, like [win, ci], [win, local], [arm, ci], [arm, local] and etc.

milesj commented 1 month ago

Yeah local was never meant to work both ways. I'll change this to a feature request.

artsiommiksiuk commented 1 month ago

Well, this might be problematic. As per documentation local also overrides quite a set of options for task it did work for me e.g. because of conflicting cache and persistent options when referenced later as deps, so I'm not quite using it anymore.

milesj commented 1 month ago

Yeah local is really only meant for dev servers/watchers/other tasks that run forever.

milesj commented 6 days ago

Gonna close this as local is going to be deprecated: https://moonrepo.dev/blog/moon-v1.28#new-task-presets