feat: env-specific builds - #696
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Expose the selected environment name to build scripts (and bundling) by introducing ICP_CLI_ENVIRONMENT, and document/test the behavior end-to-end.
Changes:
- Pass
ICP_CLI_ENVIRONMENTintoscriptbuild step execution and thread the environment through build operations. - Add
-e/--environmenttoicp project bundle(defaulting toic) and verify propagation via integration tests. - Update reference docs/guides and changelog to describe the new environment variable.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/reference/environment-variables.md | Documents ICP_CLI_ENVIRONMENT and clarifies CWD behavior for script steps. |
| docs/reference/configuration.md | Adds ICP_CLI_ENVIRONMENT to the build-script environment variable list. |
| docs/guides/creating-recipes.md | Mentions ICP_CLI_ENVIRONMENT availability in build recipe scripts. |
| docs/concepts/build-deploy-sync.md | Notes ICP_CLI_ENVIRONMENT in build scripting section. |
| crates/icp/src/canister/build/script.rs | Injects ICP_CLI_ENVIRONMENT into script build execution and adds a unit test. |
| crates/icp/src/canister/build/mod.rs | Extends build Params with an environment field. |
| crates/icp-cli/tests/deploy_tests.rs | Verifies deploy passes environment name into build scripts. |
| crates/icp-cli/tests/bundle_tests.rs | Adds coverage for bundle default environment (ic) and override behavior. |
| crates/icp-cli/tests/build_tests.rs | Verifies icp build exposes environment selection via ICP_CLI_ENVIRONMENT. |
| crates/icp-cli/src/operations/bundle.rs | Threads environment through bundle creation to builds. |
| crates/icp-cli/src/operations/build.rs | Threads environment into build execution and params. |
| crates/icp-cli/src/commands/project/bundle.rs | Adds bundle --environment flag w/ default and env-var support. |
| crates/icp-cli/src/commands/deploy.rs | Passes selected environment name into multi-canister build. |
| crates/icp-cli/src/commands/build.rs | Passes selected environment name into multi-canister build. |
| CHANGELOG.md | Records the new build-script environment variable and bundle flag. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| &Params { | ||
| path: canister_path.to_owned(), | ||
| output: wasm_output_path.to_owned(), | ||
| environment: environment.to_owned(), |
There was a problem hiding this comment.
Build output can now vary by environment, but the artifact store still has one slot per canister (artifacts.save(&canister.name, …) 18 lines down, .icp/cache/artifacts/<name>). That was safe under the reproducibility rule this PR removes from build-deploy-sync.md. Now icp canister install <c> without --wasm serves whatever was built last — so deploy -e staging then install -e local installs the staging wasm, and project bundle (defaults to ic) silently clobbers the local artifacts for every canister.
Key the artifact dir by environment, or keep a caveat in the docs in place of the deleted bullet.
| /// exist when bundling validates the sync sources, before the build. Validation | ||
| /// must resolve sync paths lexically (no canonicalization) so a not-yet-built | ||
| /// directory is accepted; the build then creates it before it is archived. | ||
| /// The environment reaching build steps as `ICP_CLI_ENVIRONMENT` defaults to `ic` |
There was a problem hiding this comment.
This test landed between the doc comment and the fn it documents — the "resolve sync paths lexically" comment now describes bundle_builds_for_ic_by_default, and bundle_accepts_synced_dir_created_by_build_step has none. Move the new test above the comment block.
| arg_struct_change_help!( | ||
| EnvironmentOpt => BuildEnvironmentOpt, | ||
| arg = "environment", | ||
| help = "Override the environment to build for. By default, the local environment is used." |
There was a problem hiding this comment.
Drop the trailing period — clap strips it from doc comments, so every other --environment renders without one, and it shows up in the generated cli.md. Same on deploy.rs:104. Regenerate cli.md after.
No description provided.