-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- `dfx build` now optionally takes a `canister_name` and optionally takes `--all` (`--all` and `canister_name` are mutually exclusive) - builds direct and transitive dependencies specified in `dfx.json` i.e. if dfx.json has `"dependencies": ["{canister_B}"]` for a `canister_A`, `dfx build canister_A` builds `canister_A` and `canister_B` # Breaking Changes - removes `dfx build --skip-frontend` as it is no longer required
- Loading branch information
Showing
15 changed files
with
304 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
actor { | ||
public func greet(name : Text) : async Text { | ||
return "Namaste, " # name # "!"; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
actor { | ||
public func greet(name : Text) : async Text { | ||
return "Hola, " # name # "!"; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
actor { | ||
public func greet(name : Text) : async Text { | ||
return "Hello, " # name # "!"; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
actor { | ||
public func greet(name : Text) : async Text { | ||
return "Hello, " # name # "!"; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"canisters": { | ||
"canister_a": { | ||
"main": "./a/main.mo", | ||
"type": "motoko" | ||
}, | ||
"canister_b": { | ||
"dependencies": ["canister_a"], | ||
"main": "./b/main.mo", | ||
"type": "motoko" | ||
}, | ||
"canister_c": { | ||
"dependencies": ["canister_b"], | ||
"main": "./c/main.mo", | ||
"type": "motoko" | ||
}, | ||
"canister_d": { | ||
"dependencies": ["canister_e"], | ||
"main": "./d/main.mo", | ||
"type": "motoko" | ||
}, | ||
"canister_e": { | ||
"dependencies": ["canister_d"], | ||
"main": "./e/main.mo", | ||
"type": "motoko" | ||
} | ||
}, | ||
"defaults": { | ||
"build": { | ||
"packtool": "" | ||
} | ||
}, | ||
"networks": { | ||
"local": { | ||
"bind": "127.0.0.1:8000" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
actor { | ||
public func greet(name : Text) : async Text { | ||
return "Hello, " # name # "!"; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Do nothing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/usr/bin/env bats | ||
|
||
load utils/_ | ||
|
||
setup() { | ||
# We want to work from a temporary directory, different for every test. | ||
cd $(mktemp -d -t dfx-e2e-XXXXXXXX) | ||
|
||
dfx_new | ||
} | ||
|
||
teardown() { | ||
dfx_stop | ||
} | ||
|
||
@test "direct dependencies are built" { | ||
dfx_start | ||
dfx canister create --all | ||
#specify build for only assets_canister | ||
dfx build e2e_project_assets | ||
|
||
#validate direct dependency built and is callable | ||
assert_command dfx canister install e2e_project | ||
assert_command dfx canister call e2e_project greet World | ||
} | ||
|
||
@test "transitive dependencies are built" { | ||
install_asset transitive_deps_canisters | ||
dfx_start | ||
dfx canister create --all | ||
#install of tertiary dependency canister will fail since its not built | ||
assert_command_fail dfx canister install canister_a | ||
#specify build for primary canister | ||
dfx build canister_c | ||
|
||
#validate tertiary transitive dependency is built and callable | ||
assert_command dfx canister install canister_a | ||
assert_command dfx canister call canister_a greet World | ||
assert_match '("Namaste, World!")' | ||
} | ||
|
||
@test "unspecified dependencies are not built" { | ||
dfx_start | ||
dfx canister create --all | ||
# only build motoko canister | ||
dfx build e2e_project | ||
# validate assets canister wasn't built and can't be installed | ||
assert_command_fail dfx canister install e2e_project_assets | ||
assert_match "No such file or directory" | ||
} | ||
|
||
|
||
@test "manual build of specified canisters succeeds" { | ||
install_asset assetscanister | ||
|
||
dfx_start | ||
dfx canister create e2e_project | ||
dfx build e2e_project | ||
assert_command dfx canister install e2e_project | ||
assert_command dfx canister call e2e_project greet World | ||
|
||
assert_command_fail dfx canister install e2e_project_assets | ||
assert_match "Cannot find canister id. Please issue 'dfx canister create e2e_project_assets'." | ||
dfx canister create e2e_project_assets | ||
dfx build e2e_project_assets | ||
dfx canister install e2e_project_assets | ||
|
||
assert_command dfx canister call --query e2e_project_assets retrieve '("binary/noise.txt")' | ||
assert_eq '(vec { 184; 1; 32; 128; 10; 119; 49; 50; 32; 0; 120; 121; 10; 75; 76; 11; 10; 106; 107; })' | ||
|
||
assert_command dfx canister call --query e2e_project_assets retrieve '("text-with-newlines.txt")' | ||
assert_eq '(vec { 99; 104; 101; 114; 114; 105; 101; 115; 10; 105; 116; 39; 115; 32; 99; 104; 101; 114; 114; 121; 32; 115; 101; 97; 115; 111; 110; 10; 67; 72; 69; 82; 82; 73; 69; 83; })' | ||
|
||
} | ||
|
||
@test "cyclic dependencies are detected" { | ||
install_asset transitive_deps_canisters | ||
dfx_start | ||
dfx canister create --all | ||
assert_command dfx build canister_e | ||
assert_match "Possible circular dependency detected during evaluation of canister_d's dependency on canister_e." | ||
} | ||
|
||
@test "the all flag builds everything" { | ||
dfx_start | ||
dfx canister create --all | ||
assert_command dfx build --all | ||
assert_command dfx canister install --all | ||
} | ||
|
||
|
||
@test "the all flags conflicts with canister name" { | ||
dfx_start | ||
dfx canister create --all | ||
assert_command_fail dfx build e2e_project --all | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.