Skip to content
This repository has been archived by the owner on Feb 26, 2025. It is now read-only.

Commit

Permalink
app common skip hint
Browse files Browse the repository at this point in the history
  • Loading branch information
noise64 committed Jan 16, 2025
1 parent 521c108 commit e294837
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 8 deletions.
1 change: 1 addition & 0 deletions examples/c/c-app-common/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"description": "Composable App Common template for CPP",
"appCommonGroup": "default",
"appCommonSkipIfExists": "common-cpp/golem.yaml",
"adapterTarget": "common-adapters",
"requiresGolemHostWIT": true,
"requiresWASI": true,
Expand Down
1 change: 1 addition & 0 deletions examples/go/go-app-common/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"description": "Composable App Common template for Go",
"appCommonGroup": "default",
"appCommonSkipIfExists": "common-go/golem.yaml",
"adapterTarget": "common-adapters",
"requiresGolemHostWIT": true,
"requiresWASI": true,
Expand Down
1 change: 1 addition & 0 deletions examples/python/python-app-common/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"description": "Composable App Common template for Python",
"appCommonGroup": "default",
"appCommonSkipIfExists": "common-python/golem.yaml",
"requiresGolemHostWIT": true,
"requiresWASI": true,
"witDepsPaths": [
Expand Down
1 change: 1 addition & 0 deletions examples/rust/rust-app-common/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"description": "Composable App Common template for Rust",
"appCommonGroup": "default",
"appCommonSkipIfExists": "common-rust/golem.yaml",
"requiresGolemHostWIT": true,
"requiresWASI": true,
"witDepsPaths": [
Expand Down
1 change: 1 addition & 0 deletions examples/ts/ts-app-common/metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"description": "Composable App Common template for TypeScript",
"appCommonGroup": "default",
"appCommonSkipIfExists": "common-ts/golem.yaml",
"requiresGolemHostWIT": true,
"requiresWASI": true,
"witDepsPaths": [
Expand Down
27 changes: 21 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn all_composable_app_examples(
for example in all_examples() {
match &example.kind {
ExampleKind::Standalone => continue,
ExampleKind::ComposableAppCommon { group } => {
ExampleKind::ComposableAppCommon { group, .. } => {
let common = &mut app_examples(&mut examples, example.language, group).common;
if let Some(common) = common {
panic!(
Expand Down Expand Up @@ -175,11 +175,25 @@ pub fn add_component_by_example(
};

if let Some(common_example) = common_example {
instantiate_example(
common_example,
&parameters,
TargetExistsResolveMode::MergeOrSkip,
)?;
let skip = {
if let ExampleKind::ComposableAppCommon {
skip_if_exists: Some(file),
..
} = &common_example.kind
{
target_path.join(file).exists()
} else {
false
}
};

if !skip {
instantiate_example(
common_example,
&parameters,
TargetExistsResolveMode::MergeOrSkip,
)?;
}
}

instantiate_example(
Expand Down Expand Up @@ -450,6 +464,7 @@ fn parse_example(
(None, None) => ExampleKind::Standalone,
(Some(group), None) => ExampleKind::ComposableAppCommon {
group: ComposableAppGroupName::from_string(group),
skip_if_exists: metadata.app_common_skip_if_exists.map(PathBuf::from),
},
(None, Some(group)) => ExampleKind::ComposableAppComponent {
group: ComposableAppGroupName::from_string(group),
Expand Down
11 changes: 9 additions & 2 deletions src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,13 @@ impl fmt::Display for ComponentName {
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ExampleKind {
Standalone,
ComposableAppCommon { group: ComposableAppGroupName },
ComposableAppComponent { group: ComposableAppGroupName },
ComposableAppCommon {
group: ComposableAppGroupName,
skip_if_exists: Option<PathBuf>,
},
ComposableAppComponent {
group: ComposableAppGroupName,
},
}

#[derive(
Expand Down Expand Up @@ -403,6 +408,8 @@ pub(crate) struct ExampleMetadata {
pub description: String,
#[serde(rename = "appCommonGroup")]
pub app_common_group: Option<String>,
#[serde(rename = "appCommonSkipIfExists")]
pub app_common_skip_if_exists: Option<String>,
#[serde(rename = "appComponentGroup")]
pub app_component_group: Option<String>,
#[serde(rename = "requiresAdapter")]
Expand Down

0 comments on commit e294837

Please sign in to comment.