Skip to content
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

Split up into multiple packages #2

Merged
merged 5 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 35 additions & 8 deletions .github/workflows/_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ jobs:
build:
runs-on: ubuntu-latest
name: Build & Test
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
DOTNET_ADD_GLOBAL_TOOLS_TO_PATH: false
DOTNET_MULTILEVEL_LOOKUP: 0
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true

steps:
- uses: actions/checkout@v4
Expand All @@ -33,16 +40,22 @@ jobs:
buildNumber=$now.$GITHUB_RUN_NUMBER
echo "BUILD_NUMBER=$buildNumber" >> $GITHUB_ENV
echo "$buildNumber"

- name: Build
run: dotnet build --configuration Release --no-restore -p:BuildNumber=$BUILD_NUMBER -p:SourceRevisionId=$GITHUB_SHA -p:ContinuousIntegrationBuild=true
run: >-
dotnet build
--configuration Release
-p:BuildNumber=$BUILD_NUMBER
-p:SourceRevisionId=$GITHUB_SHA
-p:ContinuousIntegrationBuild=true

- name: Test
id: test
# Note that the space after the last double dash (--) is intentional
run: >
dotnet test
--logger console --logger trx --logger html --logger GitHubActions
dotnet test
--logger console --logger trx --logger html
--logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true"
--results-directory ./TestResults --blame
--
RunConfiguration.CollectSourceInformation=true
Expand All @@ -59,16 +72,30 @@ jobs:
# for projectPath in ./samples/**/*.csproj ; do
# projectFileName=${projectPath##*/}
# projectName=${projectFileName%.*}
# dotnet publish "$projectPath" --output "./artifacts/$projectName" --configuration Release --no-build --verbosity normal
# dotnet publish "$projectPath" --output "./artifacts/$projectName" --configuration Release --verbosity normal
# done;
# ./artifacts/Samples.Console/Samples.Console "MiniValidation"

- name: Pack (ci)
run: dotnet pack --configuration Release --output ./artifacts/ci --verbosity normal -p:BuildNumber=$BUILD_NUMBER -p:SourceRevisionId=$GITHUB_SHA -p:ContinuousIntegrationBuild=true
run: >-
dotnet pack
--configuration Release
--output ./artifacts/ci
--verbosity normal
-p:BuildNumber=$BUILD_NUMBER
-p:SourceRevisionId=$GITHUB_SHA
-p:ContinuousIntegrationBuild=true

- name: Pack (ship candidate)
if: ${{ inputs.packShipCandidate }}
run: dotnet pack --configuration Release --output ./artifacts/ship --verbosity normal -p:BuildNumber=$BUILD_NUMBER -p:SourceRevisionId=$GITHUB_SHA -p:ContinuousIntegrationBuild=true -p:IsShipCandidate=true
run: >-
dotnet pack
--configuration Release
--output ./artifacts/ship
--verbosity normal
-p:BuildNumber=$BUILD_NUMBER
-p:SourceRevisionId=$GITHUB_SHA
-p:ContinuousIntegrationBuild=true
-p:IsShipCandidate=true

- name: Upload artifacts (packages)
uses: actions/upload-artifact@v4
Expand Down
16 changes: 11 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ jobs:
name: Deploy
needs: build
runs-on: ubuntu-latest
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
DOTNET_ADD_GLOBAL_TOOLS_TO_PATH: false
DOTNET_MULTILEVEL_LOOKUP: 0
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true

permissions:
packages: write
Expand All @@ -42,9 +49,8 @@ jobs:
run: dotnet nuget push **/ci/*.nupkg --source "GPR" --skip-duplicate --api-key ${{ secrets.GITHUB_TOKEN }}

- name: Delete old packages
uses: smartsquaregmbh/delete-old-packages@v0.8.0
uses: actions/delete-package-versions@v4
with:
organization: ${{ github.repository_owner }}
type: nuget
keep: 5
names: ${{ env.PACKAGE_ID }}
min-versions-to-keep: 5
package-type: 'nuget'
package-name: '${{ env.PACKAGE_ID }}'
88 changes: 57 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ jobs:
push-package:
name: Release
runs-on: ubuntu-latest
env:
DOTNET_CLI_TELEMETRY_OPTOUT: 1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
DOTNET_ADD_GLOBAL_TOOLS_TO_PATH: false
DOTNET_MULTILEVEL_LOOKUP: 0
DOTNET_SYSTEM_CONSOLE_ALLOW_ANSI_COLOR_REDIRECTION: true

permissions:
contents: write
Expand All @@ -38,30 +45,58 @@ jobs:
workflow_conclusion: success
name: nupkg

- name: Get package version into an environment variable
run: |
_filepath="$(find ./ship -iname $PACKAGE_ID.*.nupkg)"
_filename="${_filepath##*/}"
_pkgname="${_filename%.*}"
_version="${_pkgname##$PACKAGE_ID.}"
echo "PACKAGE_VERSION=${_version}" >> $GITHUB_ENV
echo "PACKAGE_FILEPATH=${_filepath}" >> $GITHUB_ENV
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3

- name: Add nuget.org source
run: dotnet nuget add source --name NUGET https://www.nuget.org

- name: Verify package version doesn't exist
- name: Push packages to nuget.org
run: |
_packageId="$PACKAGE_ID"
_packageVersion="$PACKAGE_VERSION"
_packageIdLower="${_packageId,,}"
_packageUrl="https://api.nuget.org/v3/registration5-semver1/${_packageIdLower}/${_packageVersion}.json"
echo "Checking for existing package at ${_packageUrl}"
_statusCode=$(curl -s -o /dev/null -I -w '%{http_code}' "${_packageUrl}")
if [ $_statusCode == "200" ]; then
echo "The package ${_packageId} with version ${_packageVersion} already exists on nuget.org"; exit 1
elif [ $_statusCode == "404" ]; then
echo "Confirmed package ${_packageId} with version ${_packageVersion} does not already exist on nuget.org"
else
echo "Unexpected status code ${_statusCode} received from nuget.org"; exit 1
fi
_filepaths=$(find ./ship -iname "*.nupkg")
_releaseVersion=""
for f in ${_filepaths};
do
echo "Found package $f"
# strip dir path from file path
_filename="${f##*/}"
# strip file extension from file name
_filenamewithoutext="${_filename%.*}"
# get version from file name
_packageVersion=$( \
echo "$_filenamewithoutext" | \
# Regex to match semantic version at end of string
grep -oP '(?<=\.)[0-9]+\.[0-9]+\.[0-9]+((-[a-zA-Z]+)?(\.[0-9]+)*)*$' \
)
# get package id by truncating the version from the file name
_packageId="${_filenamewithoutext%%.$_version}"
# verify all packages have the same version
if [ $_releaseVersion != "" ] && [ $_packageVersion != $_releaseVersion ] ; then
# mulitple package versions detected
echo "Multiple package versions detected. Expected '${_releaseVersion}' but found '${_packageVersion}' for '${_packageId}'."; exit 1
else
_releaseVersion=$_packageVersion
fi
# verify package doesn't already exist
_packageIdLower="${_packageId,,}"
_packageUrl="https://api.nuget.org/v3/registration5-semver1/${_packageIdLower}/${_packageVersion}.json"
echo "Checking for existing package at ${_packageUrl}"
_statusCode=$(curl -s -o /dev/null -I -w '%{http_code}' "${_packageUrl}")
if [ $_statusCode == "200" ]; then
echo "The package ${_packageId} with version ${_packageVersion} already exists on nuget.org"; exit 1
elif [ $_statusCode == "404" ]; then
echo "Confirmed package ${_packageId} with version ${_packageVersion} does not already exist on nuget.org"
else
echo "Unexpected status code ${_statusCode} received from nuget.org"; exit 1
fi
done;
# push packages to nuget
for f in ${_filepaths};
do
dotnet nuget push "$f" -s "NUGET" -k ${{ secrets.NUGET_API_KEY }}
done;
# store package version in an environment variable for release step
echo "PACKAGE_VERSION=${_releaseVersion}" >> $GITHUB_ENV

- name: Create release
uses: ncipollo/release-action@v1
Expand All @@ -71,12 +106,3 @@ jobs:
generateReleaseNotes: true
draft: true
prerelease: ${{ contains(env.PACKAGE_VERSION, '-') }}

- name: Setup .NET SDK
uses: actions/setup-dotnet@v4

- name: Add nuget.org source
run: dotnet nuget add source --name NUGET https://www.nuget.org

- name: Push to nuget.org
run: dotnet nuget push "$PACKAGE_FILEPATH" -s "NUGET" -k ${{ secrets.NUGET_API_KEY }}
23 changes: 22 additions & 1 deletion Aspirant.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{6E773CFD-975
src\Directory.Build.props = src\Directory.Build.props
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspirant", "src\Aspirant\Aspirant.csproj", "{035BD3FC-BB20-4BC8-9142-91C52D5756D9}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Aspirant.Hosting", "src\Aspirant.Hosting\Aspirant.Hosting.csproj", "{035BD3FC-BB20-4BC8-9142-91C52D5756D9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6FD05746-1D60-4FB7-B70C-1120465CE120}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -32,6 +32,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{25313666
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamplesTests", "tests\SamplesTests\SamplesTests.csproj", "{B9B6EF97-17DE-4E0B-B1CF-2F5134F5558E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspirant.Hosting.Yarp", "src\Aspirant.Hosting.Yarp\Aspirant.Hosting.Yarp.csproj", "{82915081-DF0A-49E3-A310-FD356DC508FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspirant.Hosting.Testing", "src\Aspirant.Hosting.Testing\Aspirant.Hosting.Testing.csproj", "{9A87F6D8-2C5C-4365-8201-1EF8EFC58771}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aspirant.Hosting.Testing.xunit", "src\Aspirant.Hosting.Testing.xunit\Aspirant.Hosting.Testing.xunit.csproj", "{3DC79FE3-C731-48AF-9F46-958FA3866C2B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -62,6 +68,18 @@ Global
{B9B6EF97-17DE-4E0B-B1CF-2F5134F5558E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9B6EF97-17DE-4E0B-B1CF-2F5134F5558E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9B6EF97-17DE-4E0B-B1CF-2F5134F5558E}.Release|Any CPU.Build.0 = Release|Any CPU
{82915081-DF0A-49E3-A310-FD356DC508FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82915081-DF0A-49E3-A310-FD356DC508FA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82915081-DF0A-49E3-A310-FD356DC508FA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82915081-DF0A-49E3-A310-FD356DC508FA}.Release|Any CPU.Build.0 = Release|Any CPU
{9A87F6D8-2C5C-4365-8201-1EF8EFC58771}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A87F6D8-2C5C-4365-8201-1EF8EFC58771}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A87F6D8-2C5C-4365-8201-1EF8EFC58771}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A87F6D8-2C5C-4365-8201-1EF8EFC58771}.Release|Any CPU.Build.0 = Release|Any CPU
{3DC79FE3-C731-48AF-9F46-958FA3866C2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3DC79FE3-C731-48AF-9F46-958FA3866C2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3DC79FE3-C731-48AF-9F46-958FA3866C2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3DC79FE3-C731-48AF-9F46-958FA3866C2B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -74,6 +92,9 @@ Global
{35444AB4-827D-4450-9C7D-182F6AEA5E94} = {C942640B-A960-403F-8A3A-763733FB6D29}
{2DC7F355-42CC-48F4-BEC9-BB9F0E708336} = {C942640B-A960-403F-8A3A-763733FB6D29}
{B9B6EF97-17DE-4E0B-B1CF-2F5134F5558E} = {25313666-00D4-4FD9-9759-49D96BE94BEC}
{82915081-DF0A-49E3-A310-FD356DC508FA} = {6E773CFD-9758-4C09-96F6-5EDCED0E3A34}
{9A87F6D8-2C5C-4365-8201-1EF8EFC58771} = {6E773CFD-9758-4C09-96F6-5EDCED0E3A34}
{3DC79FE3-C731-48AF-9F46-958FA3866C2B} = {6E773CFD-9758-4C09-96F6-5EDCED0E3A34}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {52627286-38AF-4E95-BDA0-B21166B2B18C}
Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageVersion Include="xunit" Version="2.8.0" />
<PackageVersion Include="xunit.abstractions" Version="2.0.3" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.0" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.3.3" />
</ItemGroup>
Expand Down
45 changes: 40 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,46 @@
# Aspirant ![CI](https://github.com/aspirant-project/aspirant/actions/workflows/ci.yml/badge.svg) [![NuGet](https://img.shields.io/nuget/v/Aspirant?logo=nuget)](https://www.nuget.org/packages/Aspirant/)
# Aspirant ![CI](https://github.com/aspirant-project/aspirant/actions/workflows/ci.yml/badge.svg)

Aspirant is a set of extensions and experiments for [.NET Aspire](https://github.com/dotnet/aspire) App Host projects.

### Installing Aspirant
## Installing Aspirant packages

Install the `Aspirant` package. Using the `dotnet` command line in the project directory:
Aspirant consists of the following packages:

| Package | NuGet | Description |
| ------- | ----- | ----------- |
| [Aspirant.Hosting](#aspiranthosting) | [![NuGet](https://img.shields.io/nuget/v/Aspirant.Hosting.svg)](https://www.nuget.org/packages/Aspirant.Hosting) | Base set of extensions for Aspire App Host projects that only depends on Aspire.Hosting. |
| [Aspirant.Hosting.Yarp](#aspiranthostingyarp) | [![NuGet](https://img.shields.io/nuget/v/Aspirant.Hosting.Yarp.svg)](https://www.nuget.org/packages/Aspirant.Hosting.Yarp) | A YARP ingress resource for Aspire App Host projects. |
| [Aspirant.Hosting.Testing](#aspiranthostingtesting) | [![NuGet](https://img.shields.io/nuget/v/Aspirant.Hosting.Testing.svg)](https://www.nuget.org/packages/Aspirant.Hosting.Testing) | A set of testing extension for test projects that use [Aspire.Hosting.Testing](https://nuget.org/packages/Aspire.Hosting.Testing). |
| [Aspirant.Hosting.Testing.xunit](#aspiranthostingtestingxunit) | [![NuGet](https://img.shields.io/nuget/v/Aspirant.Hosting.Testing.xunit.svg)](https://www.nuget.org/packages/Aspirant.Hosting.Testing.xunit) | A set of testing extension for xUnit test projects that use [Aspire.Hosting.Testing](https://nuget.org/packages/Aspire.Hosting.Testing). |

Install the Aspirant package you want into the relevant Aspire App Host or testing project, e.g. using the `dotnet` command line in the project directory:

```shell
dotnet add package Aspirant
```
dotnet add package Aspirant.Hosting
```

## Aspirant.Hosting

TODO: Add documentation for Aspirant.Hosting

## Aspirant.Hosting.Yarp

TODO: Add documentation for Aspirant.Hosting.Yarp

## Aspirant.Hosting.Testing

TODO: Add documentation for Aspirant.Hosting.Testing

## Aspirant.Hosting.Testing.xunit

TODO: Add documentation for Aspirant.Hosting.Testing.xunit

## License

Aspirant is licensed under the [MIT License](./LICENSE).

## Contributing

We welcome contributions to Aspirant. Please [log an issue](https://github.com/aspirant-project/aspirant/issues/new) to discuss your contribution before submitting a pull request.

TODO: Add a contributors guide.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\src\Aspirant\Aspirant.csproj" IsAspireProjectResource="False" />
<ProjectReference Include="..\..\..\src\Aspirant.Hosting.Yarp\Aspirant.Hosting.Yarp.csproj" IsAspireProjectResource="False" />
<ProjectReference Include="..\WebApplication1\WebApplication1.csproj" />
<ProjectReference Include="..\WebApplication2\WebApplication2.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Description>A set of useful extensions for .NET Aspire App Host xUnit.net testing projects.</Description>
<PackageTags>aspire hosting testing xunit</PackageTags>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="xunit.abstractions" />
<PackageReference Include="Microsoft.SourceLink.GitHub" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Aspirant.Hosting.Testing\Aspirant.Hosting.Testing.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Aspire.Hosting.Testing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Xunit.Abstractions;

namespace IntegrationTests.Infrastructure;
namespace Aspirant.Hosting.Testing;

internal static partial class DistributedApplicationTestFactory
/// <summary>
/// Extension methods for configuring xUnit output.
/// </summary>
public static partial class DistributedApplicationTestFactory
{
///// <summary>
///// Creates an <see cref="IDistributedApplicationTestingBuilder"/> for the specified app host assembly and outputs logs to the provided <see cref="ITestOutputHelper"/>.
///// </summary>
//public static async Task<IDistributedApplicationTestingBuilder> CreateAsync(string appHostAssemblyPath, ITestOutputHelper testOutputHelper)
//{
// var builder = await CreateAsync(appHostAssemblyPath, new XUnitTextWriter(testOutputHelper));
// builder.Services.AddSingleton<ILoggerProvider, XUnitLoggerProvider>();
// builder.Services.AddSingleton(testOutputHelper);
// return builder;
//}

/// <summary>
/// Writes <see cref="ILogger"/> messages and resource logs to the provided <see cref="ITestOutputHelper"/>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Microsoft.Extensions.Logging;
using Xunit.Abstractions;

namespace IntegrationTests.Infrastructure;
namespace Aspirant.Hosting.Testing;

/// <summary>
/// An <see cref="ILogger"/> that writes log messages to an <see cref="ITestOutputHelper"/>.
Expand Down
Loading