-
Notifications
You must be signed in to change notification settings - Fork 239
Add generic depdency graph implementation to smithy-utils and use it for handling topological sorting #2774
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
Open
JordonPhillips
wants to merge
4
commits into
main
Choose a base branch
from
plugin-ordering
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4ac0d87
Add a generic dependency graph to smithy-utils
JordonPhillips 3ed4df0
Use DependencyGraph in integration sorting
JordonPhillips 2529ebd
Add ordering to SmithyBuildPlugin
JordonPhillips f794a27
Throw CycleException when cycles are detected
JordonPhillips 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
7 changes: 7 additions & 0 deletions
7
.changes/next-release/feature-9d99ada83fb4eaabb1f0d929c0da87d73134dd3e.json
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,7 @@ | ||
{ | ||
"type": "feature", | ||
"description": "Add the ability for smithy build plugins to declare that they must be run before or after other plugins. These dependencies are soft, so missing dependencies will be logged and ignored.", | ||
"pull_requests": [ | ||
"[#2774](https://github.com/smithy-lang/smithy/pull/2774)" | ||
] | ||
} |
7 changes: 7 additions & 0 deletions
7
.changes/next-release/feature-d368237cdeb1655c7c10969e36c6aa3ca3b3034a.json
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,7 @@ | ||
{ | ||
"type": "feature", | ||
"description": "Add a generic dependency graph to smithy-utils to be used for sorting various dependent objects, such as integrations and plugins.", | ||
"pull_requests": [ | ||
"[#2774](https://github.com/smithy-lang/smithy/pull/2774)" | ||
] | ||
} |
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
23 changes: 23 additions & 0 deletions
23
smithy-build/src/test/java/software/amazon/smithy/build/CyclicPlugin1.java
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,23 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package software.amazon.smithy.build; | ||
|
||
import java.util.List; | ||
import software.amazon.smithy.utils.ListUtils; | ||
|
||
public class CyclicPlugin1 implements SmithyBuildPlugin { | ||
@Override | ||
public String getName() { | ||
return "cyclicplugin1"; | ||
} | ||
|
||
@Override | ||
public void execute(PluginContext context) {} | ||
|
||
@Override | ||
public List<String> runBefore() { | ||
return ListUtils.of("cyclicplugin2"); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
smithy-build/src/test/java/software/amazon/smithy/build/CyclicPlugin2.java
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,23 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package software.amazon.smithy.build; | ||
|
||
import java.util.List; | ||
import software.amazon.smithy.utils.ListUtils; | ||
|
||
public class CyclicPlugin2 implements SmithyBuildPlugin { | ||
@Override | ||
public String getName() { | ||
return "cyclicplugin2"; | ||
} | ||
|
||
@Override | ||
public void execute(PluginContext context) {} | ||
|
||
@Override | ||
public List<String> runBefore() { | ||
return ListUtils.of("cyclicplugin1"); | ||
} | ||
} |
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
30 changes: 30 additions & 0 deletions
30
smithy-build/src/test/java/software/amazon/smithy/build/TimestampPlugin1.java
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,30 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package software.amazon.smithy.build; | ||
|
||
import java.time.Instant; | ||
|
||
public class TimestampPlugin1 implements SmithyBuildPlugin { | ||
@Override | ||
public String getName() { | ||
return "timestampPlugin1"; | ||
} | ||
|
||
@Override | ||
public void execute(PluginContext context) { | ||
context.getFileManifest().writeFile("timestamp", String.valueOf(Instant.now().toEpochMilli())); | ||
try { | ||
Thread.sleep(1); | ||
} catch (InterruptedException ignored) {} | ||
} | ||
|
||
// This is made serial to protect against test failures if we decide later to | ||
// have plugins run in parallel. These plugins MUST run serially with respect | ||
// to each other to function. | ||
@Override | ||
public boolean isSerial() { | ||
return true; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
smithy-build/src/test/java/software/amazon/smithy/build/TimestampPlugin2.java
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,37 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package software.amazon.smithy.build; | ||
|
||
import java.time.Instant; | ||
import java.util.List; | ||
import software.amazon.smithy.utils.ListUtils; | ||
|
||
public class TimestampPlugin2 implements SmithyBuildPlugin { | ||
@Override | ||
public String getName() { | ||
return "timestampPlugin2"; | ||
} | ||
|
||
@Override | ||
public void execute(PluginContext context) { | ||
context.getFileManifest().writeFile("timestamp", String.valueOf(Instant.now().toEpochMilli())); | ||
try { | ||
Thread.sleep(1); | ||
} catch (InterruptedException ignored) {} | ||
} | ||
|
||
@Override | ||
public List<String> runBefore() { | ||
return ListUtils.of("timestampPlugin1"); | ||
} | ||
|
||
// This is made serial to protect against test failures if we decide later to | ||
// have plugins run in parallel. These plugins MUST run serially with respect | ||
// to each other to function. | ||
@Override | ||
public boolean isSerial() { | ||
return true; | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's a reliance on these plugins being serial, but all of them are listed that way. Can these be non-serial (my read is they can) or is it a secret dependency on this behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is in case we ever decide to run plugins in parallel. We don't now, but we could.