Skip to main content

moon v0.21 - Tiered language support with initial Go, PHP, Python, Ruby, and Rust

ยท 5 min read
Miles Johnson

Happy Holidays ๐ŸŽ„โ˜ƒ๏ธ! With our last release of the year, we're very excited to announce our tiered language support structure, which lays the foundation for turning moon into a multi-language build system! On top of this, we've worked heavily on bug fixing, optimizations, and overall quality of life improvements.

New tiered language supportโ€‹

The most common question we receive is whether we plan to support additional languages besides Node.js, with Rust, Deno, and Bun being top of that list. Adding new languages is non-trivial, as we need to build abstractions that support and integrate with the language's ecosystem, primarily dependency managers and resolution algorithms.

This is a very large upfront cost, with a huge time and resource commitment. To reduce this burden, we're introducing a tiered support structure, so that languages can be incrementally integrated into moon and adopted by consumers.

The tiers break down as follows:

  • ย Tier 0 ย  No direct integration - Tool is not directly supported in moon, but can still be ran using the "system" task platform, which expects the tool to exist in the current environment.
  • ย Tier 1 ย  Project categorization - Projects can configure their primary language in moon.yml.
  • ย Tier 2 ย  Ecosystem platformization - moon deeply integrates with the language's ecosystem by parsing manifests, lockfiles, and other semantic files to infer dependencies, tasks, and other necessary information.
  • ย Tier 3 ย  Toolchain integration - Language is directly supported in the toolchain, configured in .moon/toolchain.yml, and will automatically be downloaded and installed.

To learn more about our currently supported languages and their tiers, jump to the official documentation.

One important facet we'd like to express, is that all languages and tools fall into Tier 0. Feel free to use anything you'd like as a task command!

Basic support for Go, PHP, Python, Ruby, and, Rustโ€‹

As announced above, we now incrementally support new languages, and have integrated the following 5 languages with Tier 1 support: Go, PHP, Python, Ruby, and, Rust! Start using these languages today by setting the language field in moon.yml, or by letting moon infer the language based on files in the project root (for example, Cargo.toml is Rust).

language: 'rust'

command: 'cargo build'
- 'src/**/*'
- 'Cargo.toml'
command: 'cargo test'
- 'src/**/*'
- 'tests/**/*'
- 'Cargo.toml'

Because these languages are Tier 1, moon does not install the language automatically, and will require the command to already exist in the environment. Furthermore, the project language will automatically set all task's platform to "system", at least until it's supported directly in the toolchain.

Interactive project and dependency graphsโ€‹

Thanks to the amazing contribution from Diptesh Choudhuri, we now have interactive project and dependency graphs when running the moon project-graph and moon dep-graph commands respectively.

This is only the first iteration of these graphs. Expect more advanced features in the future, like filtering, node/edge inspection, exporting, and more!

New --updateCache command line optionโ€‹

Our caching layer is pretty powerful, as it helps to avoid tasks from running unnecessarily. However, there are situations where you need to refresh or force update the cache outside of the inputs list. This is currently achieved with the --cache option, like moon --cache off run ..., but this is non-ideal for a few reasons:

  1. It disables all caching, which means dependency installs/dedupes will continually be ran. This adds a lot of unwanted overhead.
  2. It requires you to backspace in the terminal to add the option before run or check, as it's a global option. A little tedious but important for experience.

So to work around these limitations, we've added a new --updateCache (or -u) to both moon run and moon check, which will bypass reading any existing cache items, but will force update the cache base on the latest run.

$ moon run app:build --updateCache

New multi-status affected filteringโ€‹

We support running tasks based on affected files using the moon run --affected command, which is great for reducing the amount of tasks being ran, and for applying code quality tooling like git hooks. However, you were only able to apply a single status filter, like "deleted" or "modified", which was non-ideal... but no more!

You can now apply multiple statuses by passing the --status option multiple times.

$ moon run :lint --affected --status modified --status added

This pairs nicely with the recent affectedFiles task option changes!

Other changesโ€‹

View the official release for a full list of changes.

  • Refactored project and dependency graphs for improved performance.
  • Added args and env var variants to the affectedFiles task option.
  • Added --minimal to moon init for quick scaffolding and prototyping.

What's next?โ€‹

Expect the following in the v0.22 release!

  • Generalized hashing for use in any context (improved deps installation).
  • More work on language integrations.