-
Notifications
You must be signed in to change notification settings - Fork 164
Perl hosting integration #1155
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
Omnideth
wants to merge
14
commits into
CommunityToolkit:main
Choose a base branch
from
Omnideth:feature-perl-integration
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
Perl hosting integration #1155
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4249b09
I believe this is the full setup after syncing main.
Omnideth b4a11b9
Modifications to allow for parallel tests, a root endpoint for one of…
Omnideth 2bb12da
Cleaning up some of the copilot suggestions on the PR.
Omnideth fab0c9d
I believe this will resolve the rest of the comments on the PR.
Omnideth fd0b27b
Per Aaron's review:
Omnideth e7501f5
Per review: Pragma warnings sent to inline.
Omnideth b2d59ae
Per Review:
Omnideth 7e306c2
This commit resolves the following notes:
Omnideth b0d150c
I believe this addresses the rest of the concerns on the PR except fo…
Omnideth c74d398
This commit addresses the extremely long readme, the next commit will…
Omnideth 804095b
This is _hopefully_ the final commit.
Omnideth c85a9fd
The last comment I had missed requested I remove logging and surface …
Omnideth ebf4968
Addressing final feedback. Unclear about property group. I removed …
Omnideth fdf6a17
Clean up SLNX examples for perl after consolidating examples into one.
Omnideth 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
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
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
14 changes: 14 additions & 0 deletions
14
examples/perl/cpanm-api-integration/CpanmApiIntegration.AppHost/AppHost.cs
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,14 @@ | ||
| var builder = DistributedApplication.CreateBuilder(args); | ||
|
|
||
| var perlApi = builder.AddPerlApi("perl-api", ".", "../scripts/API.pl") | ||
| .WithCpanMinus() | ||
| .WithPackage("Mojolicious::Lite", force: true, skipTest: true) | ||
| .WithLocalLib("local") //to avoid 'sudo' applying to system perl. | ||
| .WithHttpEndpoint(name: "http", env: "PORT"); | ||
|
|
||
| builder.AddPerlScript("perl-driver", "../scripts", "driver.pl") | ||
| .WithEnvironment("API_URL", perlApi.GetEndpoint("http")) | ||
| .WithReference(perlApi) | ||
| .WaitFor(perlApi); | ||
|
|
||
| builder.Build().Run(); |
11 changes: 11 additions & 0 deletions
11
...perl/cpanm-api-integration/CpanmApiIntegration.AppHost/CpanmApiIntegration.AppHost.csproj
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,11 @@ | ||
| <Project Sdk="Aspire.AppHost.Sdk/13.2.0"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\..\..\src\CommunityToolkit.Aspire.Hosting.Perl\CommunityToolkit.Aspire.Hosting.Perl.csproj" IsAspireProjectResource="false" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
29 changes: 29 additions & 0 deletions
29
...les/perl/cpanm-api-integration/CpanmApiIntegration.AppHost/Properties/launchSettings.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,29 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/launchsettings.json", | ||
| "profiles": { | ||
| "https": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "applicationUrl": "https://localhost:17453;http://localhost:15453", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development", | ||
| "DOTNET_ENVIRONMENT": "Development", | ||
| "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21453", | ||
| "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22453" | ||
| } | ||
| }, | ||
| "http": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "applicationUrl": "http://localhost:15453", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development", | ||
| "DOTNET_ENVIRONMENT": "Development", | ||
| "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19453", | ||
| "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20453" | ||
| } | ||
| } | ||
| } | ||
| } |
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,21 @@ | ||
| # cpanm-api-integration | ||
|
|
||
| Minimal Perl API example for integration tests using `cpanm` and `Mojolicious::Lite`. | ||
|
|
||
| ## Project | ||
| - `CpanmApiIntegration.AppHost` (Aspire AppHost) | ||
|
|
||
| ## Perl focus | ||
| - Uses `AddPerlApi(...)` | ||
| - Uses `WithCpanMinus()` | ||
| - Uses `WithPackage("Mojolicious::Lite")` | ||
| - Uses HTTP endpoint wiring with `PORT` | ||
| - No HTTPS and no OpenTelemetry setup | ||
|
|
||
| ## Endpoint | ||
| - `/` | ||
|
|
||
| ## Run | ||
| ```powershell | ||
| aspire run | ||
| ``` |
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,15 @@ | ||
| use Mojolicious::Lite -signatures; | ||
|
|
||
| my $port = $ENV{PORT} // 3000; | ||
|
|
||
| my @listeners = ("http://*:$port"); | ||
|
|
||
| get '/' => sub ($c) { | ||
| $c->render(text => 'HEY!'); | ||
| }; | ||
|
|
||
| get '/fleeting' => sub ($c) { | ||
| $c->render(text => 'fragile'); | ||
| }; | ||
|
|
||
| app->start('daemon', map { ('-l', $_) } @listeners); |
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,28 @@ | ||
| use strict; | ||
| use warnings; | ||
| use HTTP::Tiny; | ||
|
|
||
| $| = 1; # autoflush stdout so prints appear in Aspire dashboard immediately | ||
|
|
||
| my $api_url = $ENV{API_URL}; | ||
| die "API_URL environment variable is not set\n" unless defined $api_url && $api_url ne ''; | ||
|
|
||
| # Strip trailing slash if present | ||
| $api_url =~ s{/\z}{}; | ||
|
|
||
| my $target = "$api_url/fleeting"; | ||
| my $http = HTTP::Tiny->new(timeout => 5); | ||
|
|
||
| print "Driver started — polling $target every 3 seconds...\n"; | ||
|
|
||
| while (1) { | ||
| my $response = $http->get($target); | ||
|
|
||
| if ($response->{success}) { | ||
| print "[OK] $target => $response->{content}\n"; | ||
| } else { | ||
| print "[ERR] $target => $response->{status} $response->{reason}\n"; | ||
| } | ||
|
|
||
| sleep 3; | ||
| } |
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 |
|---|---|---|
| @@ -1,6 +1,9 @@ | ||
| { | ||
| "sdk": { | ||
| "allowPrerelease": true | ||
| }, | ||
| "test": { | ||
| "runner": "Microsoft.Testing.Platform" | ||
| } | ||
| } | ||
|
|
16 changes: 16 additions & 0 deletions
16
src/CommunityToolkit.Aspire.Hosting.Perl/Annotations/PerlCartonDeploymentAnnotation.cs
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 @@ | ||
| using Aspire.Hosting.ApplicationModel; | ||
|
|
||
| namespace CommunityToolkit.Aspire.Hosting.Perl.Annotations; | ||
|
|
||
| /// <summary> | ||
| /// Records whether <c>carton install --deployment</c> should be used during publish-mode Dockerfile generation. | ||
| /// When <see langword="true"/>, Carton uses <c>--deployment</c> to install from a locked <c>cpanfile.snapshot</c>. | ||
| /// </summary> | ||
| /// <param name="useDeployment">Whether to pass <c>--deployment</c> to <c>carton install</c>.</param> | ||
| internal sealed class PerlCartonDeploymentAnnotation(bool useDeployment) : IResourceAnnotation | ||
| { | ||
| /// <summary> | ||
| /// Gets a value indicating whether <c>--deployment</c> should be used with <c>carton install</c>. | ||
| /// </summary> | ||
| public bool UseDeployment { get; } = useDeployment; | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/CommunityToolkit.Aspire.Hosting.Perl/Annotations/PerlCertificateTrustAnnotation.cs
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,8 @@ | ||
| using Aspire.Hosting.ApplicationModel; | ||
|
|
||
| namespace CommunityToolkit.Aspire.Hosting.Perl.Annotations; | ||
|
|
||
| /// <summary> | ||
| /// Marker annotation that prevents duplicate <c>WithPerlCertificateTrust</c> registrations. | ||
| /// </summary> | ||
| internal sealed class PerlCertificateTrustAnnotation : IResourceAnnotation; |
15 changes: 15 additions & 0 deletions
15
src/CommunityToolkit.Aspire.Hosting.Perl/Annotations/PerlEntrypointAnnotation.cs
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,15 @@ | ||
| using Aspire.Hosting.ApplicationModel; | ||
| using CommunityToolkit.Aspire.Hosting.Perl; | ||
|
|
||
| namespace CommunityToolkit.Aspire.Hosting.Perl.Annotations; | ||
|
|
||
| /// <summary> | ||
| /// An annotation that stores the entrypoint type and path for a Perl application resource, | ||
| /// used to determine how the application is launched (e.g., as a script or via a framework runner). | ||
| /// </summary> | ||
| /// <see cref="EntrypointType"/> | ||
| internal class PerlEntrypointAnnotation : IResourceAnnotation | ||
| { | ||
| public required EntrypointType Type { get; set; } | ||
| public required string Entrypoint { get; set; } | ||
| } |
8 changes: 8 additions & 0 deletions
8
src/CommunityToolkit.Aspire.Hosting.Perl/Annotations/PerlLocalLibAnnotation.cs
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,8 @@ | ||
| using Aspire.Hosting.ApplicationModel; | ||
|
|
||
| namespace CommunityToolkit.Aspire.Hosting.Perl.Annotations; | ||
|
|
||
| internal sealed class PerlLocalLibAnnotation(string path) : IResourceAnnotation | ||
| { | ||
| public string Path { get; } = path; | ||
| } |
7 changes: 7 additions & 0 deletions
7
...nityToolkit.Aspire.Hosting.Perl/Annotations/PerlLocalLibInstallerEnvironmentAnnotation.cs
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 @@ | ||
| using Aspire.Hosting.ApplicationModel; | ||
|
|
||
| namespace CommunityToolkit.Aspire.Hosting.Perl.Annotations; | ||
|
|
||
| internal sealed class PerlLocalLibInstallerEnvironmentAnnotation : IResourceAnnotation | ||
| { | ||
| } |
7 changes: 7 additions & 0 deletions
7
...unityToolkit.Aspire.Hosting.Perl/Annotations/PerlLocalLibResourceEnvironmentAnnotation.cs
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 @@ | ||
| using Aspire.Hosting.ApplicationModel; | ||
|
|
||
| namespace CommunityToolkit.Aspire.Hosting.Perl.Annotations; | ||
|
|
||
| internal sealed class PerlLocalLibResourceEnvironmentAnnotation : IResourceAnnotation | ||
| { | ||
| } |
13 changes: 13 additions & 0 deletions
13
src/CommunityToolkit.Aspire.Hosting.Perl/Annotations/PerlModuleInstallerAnnotation.cs
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,13 @@ | ||
| using Aspire.Hosting.ApplicationModel; | ||
|
|
||
| namespace CommunityToolkit.Aspire.Hosting.Perl.Annotations; | ||
|
|
||
| /// <summary> | ||
| /// Links a <see cref="PerlAppResource"/> to its installer child resource. | ||
| /// This annotation tracks the <see cref="ExecutableResource"/> that performs the installation. | ||
| /// </summary> | ||
| /// <param name="installerResource">The child executable resource that runs the install command.</param> | ||
| internal sealed class PerlModuleInstallerAnnotation(ExecutableResource installerResource) : IResourceAnnotation | ||
| { | ||
| public ExecutableResource Resource { get; } = installerResource; | ||
| } |
20 changes: 20 additions & 0 deletions
20
src/CommunityToolkit.Aspire.Hosting.Perl/Annotations/PerlPackageManagerAnnotation.cs
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,20 @@ | ||
| using Aspire.Hosting.ApplicationModel; | ||
|
|
||
| namespace CommunityToolkit.Aspire.Hosting.Perl.Annotations; | ||
|
|
||
| /// <summary> | ||
| /// Represents the annotation for the Perl package manager used in a resource. | ||
| /// </summary> | ||
| /// <param name="packageManager">The package manager to use for module installation.</param> | ||
| internal sealed class PerlPackageManagerAnnotation(PerlPackageManager packageManager) : IResourceAnnotation | ||
| { | ||
| /// <summary> | ||
| /// Gets the package manager variant. | ||
| /// </summary> | ||
| public PerlPackageManager PackageManager { get; } = packageManager; | ||
|
|
||
| /// <summary> | ||
| /// Gets the executable name used to invoke this package manager on the command line. | ||
| /// </summary> | ||
| public string ExecutableName => PackageManager.ToExecutableName(); | ||
| } |
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.
What will we be doing with Windows runners? Or are those tests not going to be run on Windows?
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.
Okay so, strawberry perl on windows comes with cpanm, which is a better package manager for CLI than the cpan.
So on Linux distros often you need to use cpan to install cpanm. That's what this is trying to do.
I was assuming the tests would run on both, and that on the Linux side we'd just sneak in cpanm before the tests run.
This is my first time using actions though so it may not be right.