-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Implement Canister Build Adapter Framework and Script Adapter #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 51 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
e18974b
initial skeleton for build command
rikonor 72452ee
pull project functionality into its own crate
rikonor d76e032
create canister and project manifest definitions
rikonor 45507b8
add parsing logic for project and canister manifests
rikonor a40140e
revert some minor changes
rikonor c6c3de8
put adapter definitions in adapter enum
rikonor 14aeab5
clean up snafu errors
rikonor fd56d1c
switch from parsing yaml bytes to taking the path so we can report be…
rikonor f3b4e96
rename error for clarity
rikonor 5a905d6
specify path in certain errors
rikonor 63b8740
remove assets canister variant until it can be further discussed
rikonor 8c0ffbb
specify explicit defaults for project manifest
rikonor 0ea957b
remove redundant check for file existence
rikonor dab4ac2
create a load_yaml_file function and use it in icp-project and icp-ca…
rikonor 8cc67c6
Merge branch 'main' into or-build-skeleton
rikonor a6eb5ba
fix ProjectDirectory usage
rikonor 54e54bf
get project manifest path from project directory object
rikonor f3201f5
remove redundant path in error
rikonor e47f35f
put structs into model.rs
rikonor 596f19d
Merge branch 'main' into or-build-skeleton
rikonor a2f998d
update build code paths to use camino strings
rikonor e5a45e1
fix globbing not working from non-project root directory
rikonor a67b8f2
move project structure and directory to icp-project module
rikonor dcf6c8e
extract knowledge of canister yaml path into project directory structure
rikonor 372e3ab
single group imports
rikonor f5d73d3
use canister manifest path from directory structure
rikonor bdd98b7
leaf subcommands should use an exec name and not dispatch
rikonor 00afea2
move everything to model file
rikonor 4db8935
move definitions to model file
rikonor 00b365a
use project-directory-structure to load project manifest
rikonor 3ef371f
use pds when available
rikonor b702c48
rename conversion function to load
rikonor ee4fb21
remove unused error variant
rikonor b6a2dbd
add documentation about load function behavior
rikonor 21ea7c5
fix lint error
rikonor 30e4519
create initial adapter skeletons
rikonor 4a34b87
wip shell execution
rikonor 32dec84
initial implementation of script builder
rikonor a5eb1a1
Merge branch 'main' into or-adapters
rikonor cf53ef5
remove shell handling for unix/windows, use shellwords instead and do…
rikonor 59395c7
support command and commands for script builder
rikonor 7d6647e
use map_or instead of map and unwrap_or
rikonor df4f2fa
Merge branch 'main' into or-adapters
rikonor 7e901aa
quote printed variables, dont include source in template since its in…
rikonor 487ee51
Merge branch 'main' into or-adapters
rikonor da226e3
pass a reference instead of value
rikonor 70919ac
add various tests for the script build adapter
rikonor 6d8f795
Merge branch 'main' into or-adapters
rikonor 3f264be
canonicalize command path for script adapter
rikonor 7b0e770
provide utility function for CommandField to extract vec in both sing…
rikonor 174c4be
put unit tests under their respective package
rikonor a578810
run unit tests separately from integration tests
rikonor 54e75c9
log reason for invalid command
rikonor fbbbd14
add integration test for script adapter
rikonor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,16 @@ | ||
| [package] | ||
| name = "icp-adapter" | ||
| version = "0.1.0" | ||
| edition = "2024" | ||
|
|
||
| [dependencies] | ||
| async-trait = { workspace = true } | ||
| camino = { workspace = true } | ||
| dunce = { workspace = true } | ||
| serde = { workspace = true } | ||
| shellwords = { workspace = true } | ||
| snafu = { workspace = true } | ||
|
|
||
| [dev-dependencies] | ||
| tokio = { workspace = true } | ||
| camino-tempfile = { workspace = true } |
This file contains hidden or 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,27 @@ | ||
| use async_trait::async_trait; | ||
| use camino::Utf8Path; | ||
| use motoko::MotokoAdapterCompileError; | ||
| use rust::RustAdapterCompileError; | ||
| use script::ScriptAdapterCompileError; | ||
| use snafu::Snafu; | ||
|
|
||
| pub mod motoko; | ||
| pub mod rust; | ||
| pub mod script; | ||
|
|
||
| #[async_trait] | ||
| pub trait Adapter { | ||
| async fn compile(&self, path: &Utf8Path) -> Result<(), AdapterCompileError>; | ||
| } | ||
|
|
||
| #[derive(Debug, Snafu)] | ||
| pub enum AdapterCompileError { | ||
| #[snafu(transparent)] | ||
| Rust { source: RustAdapterCompileError }, | ||
|
|
||
| #[snafu(transparent)] | ||
| Motoko { source: MotokoAdapterCompileError }, | ||
|
|
||
| #[snafu(transparent)] | ||
| Script { source: ScriptAdapterCompileError }, | ||
| } |
This file contains hidden or 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,27 @@ | ||
| use crate::{Adapter, AdapterCompileError}; | ||
| use async_trait::async_trait; | ||
| use camino::Utf8Path; | ||
| use serde::Deserialize; | ||
| use snafu::Snafu; | ||
|
|
||
| /// Configuration for a Motoko-based canister build adapter. | ||
| #[derive(Debug, Deserialize)] | ||
| pub struct MotokoAdapter { | ||
| /// Optional path to the main Motoko source file. | ||
| /// If omitted, a default like `main.mo` may be assumed. | ||
| #[serde(default)] | ||
| pub main: Option<String>, | ||
| } | ||
|
|
||
| #[async_trait] | ||
| impl Adapter for MotokoAdapter { | ||
| async fn compile(&self, _path: &Utf8Path) -> Result<(), AdapterCompileError> { | ||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Snafu)] | ||
| pub enum MotokoAdapterCompileError { | ||
| #[snafu(display("an unexpected build error occurred"))] | ||
| Unexpected, | ||
| } |
This file contains hidden or 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,25 @@ | ||
| use crate::{Adapter, AdapterCompileError}; | ||
| use async_trait::async_trait; | ||
| use camino::Utf8Path; | ||
| use serde::Deserialize; | ||
| use snafu::Snafu; | ||
|
|
||
| /// Configuration for a Rust-based canister build adapter. | ||
| #[derive(Debug, Deserialize)] | ||
| pub struct RustAdapter { | ||
| /// The name of the Cargo package to build. | ||
| pub package: String, | ||
| } | ||
|
|
||
| #[async_trait] | ||
| impl Adapter for RustAdapter { | ||
| async fn compile(&self, _path: &Utf8Path) -> Result<(), AdapterCompileError> { | ||
| Ok(()) | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Snafu)] | ||
| pub enum RustAdapterCompileError { | ||
| #[snafu(display("an unexpected build error occurred"))] | ||
| Unexpected, | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.