website/blog/2024-04-17_moon-v1.24.mdx
This is a light release that focused solely on requests and improvements from the community.
<!--truncate-->Some tasks may require exclusive access to a resource, like a database, file, or network connection, but other parallel running tasks may also require access to the same resource. When both of these tasks run, they may conflict with each other, causing one or both to fail. This wasn't an easy problem to solve in moon, until now!
Thanks to Andrés Correa Casablanca for the idea and implementation,
tasks now support a new option called mutex. This option allows you
to specify a unique name (across the entire workspace) for the mutex, which will be used to lock the
task from running if another task with the same mutex name is already running.
Take the following for example:
# server/moon.yml
tasks:
build:
command: 'build-server'
options:
mutex: 'app'
# client/moon.yml
tasks:
build:
command: 'build-client'
options:
mutex: 'app'
When moon run :build or moon ci is ran, both tasks
will be parallelized within our pipeline, but only one of them will run at a time. If the server
task is running, the client task will wait until the server task is complete. This ensures that
both tasks don't conflict with each other.
This could technically be solved through task deps, but with a mutex, it allows you to decouple
project and task dependencies, and instead focus on a virtual resource that is being locked.
moon ciWe've updated moon ci to try and detect the base and head revisions
automatically when running in a popular CI provider, like GitLab and Jenkins. For the base revision,
we'll use the base/target commit SHA or target branch, while the head revision will use the source
commit SHA or HEAD. This is great for pull requests and forks!
With that said, these values can be overwritten with environment variables, or command line arguments. Below is the order of precedence:
MOON_BASE / MOON_HEAD environment variables--base / --head command line argumentsbase_revision / head_revision via CI providervcs.defaultBranch setting / HEAD literal valueThis functionality is provided by the
ci_envRust crate. Please refer to that crate for supported providers, and which of them support revision detection (primarily thebase_revisionandhead_revisionfields).
When running moon project-graph <id>, we visualize a graph of the
focused project and all of its dependencies (other projects it depends on). However, if you wanted
to also visualize dependents (other projects that depend on the focused project), this was currently
not possible.
We felt this information could be useful, so we've added a --dependents
flattenDiagnosticMessageText, which will include direct dependents in the graph.
$ moon project-graph server --dependents
We also felt dependent information can be useful when querying projects, so have also added support
for the --dependents flag to the moon query projects command.
$ moon query projects --affected --dependents
View the official release for a full list of changes.
moon templates command, that lists all available codegen templates.runner.autoCleanCache setting to .moon/workspace.yml, allowing the post-run clean
mechanism to be controlled.moon generate with better argument to variable handling.**/*.