|
| 1 | +--- |
| 2 | +slug: moon-v1.36 |
| 3 | +title: moon v1.36 - Toolchain plugins beta, optimized remote caching, and codegen improvements |
| 4 | +authors: [milesj] |
| 5 | +tags: [toolchain, wasm, plugin, remote, cache, integrity, codegen, template] |
| 6 | +image: ./img/moon/v1.36.png |
| 7 | +--- |
| 8 | + |
| 9 | +In this release, we're very excited to fully release toolchain plugins! |
| 10 | + |
| 11 | +<!--truncate--> |
| 12 | + |
| 13 | +## Beta release of toolchain WASM plugins |
| 14 | + |
| 15 | +Two months ago we announced [alpha toolchain plugins](./moon-v1.33) with support for tier 3, but not |
| 16 | +tier 2. The reason for this was that tier 3 is powered by [proto APIs](/docs/proto/wasm-plugin), |
| 17 | +which already existed! We simply hooked them up to moon. The bulk of the remaining plugin work was |
| 18 | +tier 2 support, which we are excited to announce has been completed! The following APIs have been |
| 19 | +implemented: |
| 20 | + |
| 21 | +- `extend_project_graph` - Extend projects with toolchain specific info. |
| 22 | +- `extend_task_command` - Extend the command child process with parameters. |
| 23 | +- `extend_task_script` - Extend the script child process with parameters. |
| 24 | +- `locate_dependencies_root` - Locate the package dependencies workspace root. |
| 25 | +- `parse_manifest` - Parse a manifest file to extract dependencies. |
| 26 | +- `parse_lock` - Parse a lock file to extract resolved dependencies. |
| 27 | + |
| 28 | +And the following surface areas have been integrated with: |
| 29 | + |
| 30 | +- In the project graph: |
| 31 | + - Extend projects with dependencies, tasks, and an alias. |
| 32 | +- In the action pipeline: |
| 33 | + - Added `SetupEnvironment` action that executes the `setup_environment` API. |
| 34 | + - Added `InstallDependencies` action that executes the `install_dependencies` API. |
| 35 | +- When running tasks: |
| 36 | + - Extend the command/script with additional parameters before executing. |
| 37 | + - Inject dependency and lock information into the hash. |
| 38 | +- With Docker: |
| 39 | + - Updated `docker prune` to utilize the new WASM APIs for toolchain plugins. |
| 40 | + |
| 41 | +As of this release, all 27 APIs have been implemented, and toolchain plugins are now available for |
| 42 | +general use! However, they are still quite unstable, not fully tested, and the APIs may change |
| 43 | +between releases, but you can start using them today if you're feeling adventurous! |
| 44 | + |
| 45 | +With all this said, we do not have documentation yet. We plan to slowly work on this across the next |
| 46 | +few releases. In the meantime, check out the following resources for more information: |
| 47 | + |
| 48 | +- [`moon_pdk`](https://docs.rs/moon_pdk/) - Rust plugin development kit. |
| 49 | +- Existing [toolchain plugins](https://github.com/moonrepo/plugins/tree/master/toolchains). |
| 50 | +- In development [Rust toolchain](https://github.com/moonrepo/plugins/pull/48). |
| 51 | + |
| 52 | +## Optimized remote caching |
| 53 | + |
| 54 | +Like the past few releases, we've made some improvements to the remote caching layer. |
| 55 | + |
| 56 | +To start, we're adding a new |
| 57 | +[`unstable_remote.cache.verifyIntegrity`](/docs/config/workspace#verifyintegrity) setting, that will |
| 58 | +verify the digest (hash) of downloaded blobs to ensure they aren't corrupted or incomplete. We |
| 59 | +currently check the file size, but this will also now check the content. This setting will slightly |
| 60 | +degrade performance but ensure reliability. |
| 61 | + |
| 62 | +```yaml title=".moon/workspace.yml" |
| 63 | +unstable_remote: |
| 64 | + cache: |
| 65 | + verifyIntegrity: true |
| 66 | +``` |
| 67 | + |
| 68 | +While we're on the topic of reliability, we're also introducing an implicit rollback mechanic that |
| 69 | +will remove partially downloaded or incomplete blobs if hydration ever fails at some point. This |
| 70 | +will also run between executions to ensure there are no stale artifacts lying around. |
| 71 | + |
| 72 | +And lastly, we've parallelized the blob existence checks, reducing the amount of large requests for |
| 73 | +heavy tasks, and reworked how we inherit `MOON_REMOTE_*` environment variables. |
| 74 | + |
| 75 | +## Improved code generation |
| 76 | + |
| 77 | +It's been a while since we've added new features to code generation, but thanks to some great |
| 78 | +requests from the community, we have 2 this release! |
| 79 | + |
| 80 | +### Archive URLs |
| 81 | + |
| 82 | +The first is that [remote archives](/docs/guides/codegen#archive-urls) (zip, tar, etc) can be used |
| 83 | +as template locations. The archive will then be downloaded and unpacked into `~/.moon/templates`. |
| 84 | + |
| 85 | +```yaml title=".moon/workspace.yml" |
| 86 | +generator: |
| 87 | + templates: |
| 88 | + - 'https://domain.com/some/path/to/archive.zip' |
| 89 | +``` |
| 90 | + |
| 91 | +### Array and object types |
| 92 | + |
| 93 | +The second is that we now support `array` and `object` |
| 94 | +[variable types](/docs/config/template#variables) in `template.yml`. The values within each of these |
| 95 | +collections can be any JSON-compatible type. |
| 96 | + |
| 97 | +```yaml title="template.yml" |
| 98 | +variables: |
| 99 | + type: |
| 100 | + type: 'array' |
| 101 | + prompt: 'Type?' |
| 102 | + default: ['app', 'lib'] |
| 103 | + metadata: |
| 104 | + type: 'object' |
| 105 | + prompt: 'Metadata?' |
| 106 | + default: |
| 107 | + internal: true |
| 108 | +``` |
| 109 | + |
| 110 | +These variables and their nested values can then be accessed within templates using dot or bracket |
| 111 | +notation. |
| 112 | + |
| 113 | +```twig |
| 114 | +{{ type[0] }} |
| 115 | +{{ metadata.internal }} |
| 116 | +``` |
| 117 | + |
| 118 | +## Other changes |
| 119 | + |
| 120 | +View the [official release](https://github.com/moonrepo/moon/releases/tag/v1.36.0) for a full list |
| 121 | +of changes. |
| 122 | + |
| 123 | +- Added `--host` and `--port` options to `moon action-graph`, `moon task-graph`, and |
| 124 | + `moon project-graph`. |
| 125 | +- Added `--stdin` option to `moon ci` and `moon run`, which will allow touched files to be passed |
| 126 | + via stdin, instead of running VCS commands to determine them. |
| 127 | +- Removed the restriction around `moon.{yml,pkl}` not being allowed as a task input. However, will |
| 128 | + not be included when using `**/*`. |
| 129 | + |
| 130 | +## What's next? |
| 131 | + |
| 132 | +Now that toolchain plugins are in beta, we can take the next step in migrating an existing platform |
| 133 | +into a toolchain. |
| 134 | + |
| 135 | +- Migrate the Rust toolchain to a WASM plugin. |
0 commit comments