Skip to content

feat: env-specific builds - #696

Open
adamspofford-dfinity wants to merge 7 commits into
mainfrom
spofford/env-specific-builds
Open

feat: env-specific builds#696
adamspofford-dfinity wants to merge 7 commits into
mainfrom
spofford/env-specific-builds

Conversation

@adamspofford-dfinity

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI balanced review requested due to automatic review settings August 6, 2026 17:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ENVIRONMENT into script build step execution and thread the environment through build operations.
  • Add -e/--environment to icp project bundle (defaulting to ic) 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.

Comment thread CHANGELOG.md Outdated
Comment thread crates/icp-cli/src/operations/build.rs
Comment thread crates/icp-cli/tests/build_tests.rs
@adamspofford-dfinity
adamspofford-dfinity marked this pull request as ready for review August 6, 2026 18:03
@adamspofford-dfinity
adamspofford-dfinity requested a review from a team as a code owner August 6, 2026 18:03
Comment thread crates/icp-cli/src/commands/build.rs Outdated
Comment thread crates/icp-cli/src/commands/deploy.rs Outdated
Comment thread docs/reference/cli.md Outdated
&Params {
path: canister_path.to_owned(),
output: wasm_output_path.to_owned(),
environment: environment.to_owned(),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants