Skip to content

Aspire 13.1.0, .NET 10 support, and TUnit migration #60

Aspire 13.1.0, .NET 10 support, and TUnit migration

Aspire 13.1.0, .NET 10 support, and TUnit migration #60

Workflow file for this run

name: "CI/CD Pipeline"
on:
push:
paths-ignore:
- "**.md"
- LICENSE
branches:
- "master"
pull_request:
paths-ignore:
- "**.md"
- LICENSE
branches:
- master
- "feature/*"
env:
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_NOLOGO: true
jobs:
build-and-test:
name: "Build & Test (${{ matrix.name }})"
runs-on: ${{ matrix.os }}
env:
NUGET_PACKAGES: ${{ contains(matrix.os, 'windows') && format('{0}\.nuget\packages', github.workspace) || format('{0}/.nuget/packages', github.workspace) }}
BASE_TEST_RESULTS_DIR: ${{ contains(matrix.os, 'windows') && format('{0}\test-results', github.workspace) || format('{0}/test-results', github.workspace) }}
UNIT_TEST_PROJECT_PATH: ${{ contains(matrix.os, 'windows') && format('{0}\tests\Aspire.Hosting.LocalStack.Unit.Tests\Aspire.Hosting.LocalStack.Unit.Tests.csproj', github.workspace) || format('{0}/tests/Aspire.Hosting.LocalStack.Unit.Tests/Aspire.Hosting.LocalStack.Unit.Tests.csproj', github.workspace) }}
INTEGRATION_TEST_PROJECT_PATH: ${{ contains(matrix.os, 'windows') && format('{0}\tests\Aspire.Hosting.LocalStack.Integration.Tests\Aspire.Hosting.LocalStack.Integration.Tests.csproj', github.workspace) || format('{0}/tests/Aspire.Hosting.LocalStack.Integration.Tests/Aspire.Hosting.LocalStack.Integration.Tests.csproj', github.workspace) }}
BADGE_API_ENDPOINT: "https://api.localstackfor.net"
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
name: "Windows"
- os: ubuntu-22.04
name: "Linux"
- os: macos-latest
name: "macOS"
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for better caching
- name: "Setup .NET SDK"
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: "Setup Node.js"
if: runner.os == 'Linux'
uses: actions/setup-node@v4
with:
node-version: '22'
- name: "Install AWS CDK CLI"
if: runner.os == 'Linux'
run: npm install -g aws-cdk@2.x
- name: "Cache NuGet packages"
uses: actions/cache@v4
with:
path: ${{ runner.os == 'Windows' && format('{0}\.nuget\packages', github.workspace) || format('{0}/.nuget/packages', github.workspace) }}
key: ${{ runner.os }}-nugetv2-${{ hashFiles('**/Directory.Packages.props') }}-${{ hashFiles('**/*.csproj') }}-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nugetv2-
- name: "Build"
run: dotnet build --configuration Release
- name: "Run Unit Tests"
uses: ./.github/actions/run-dotnet-tests
with:
project-path: ${{ env.UNIT_TEST_PROJECT_PATH }}
results-dir: ${{ runner.os == 'Windows' && format('{0}\unit', env.BASE_TEST_RESULTS_DIR) || format('{0}/unit', env.BASE_TEST_RESULTS_DIR) }}
configuration: "Release"
- name: "Run Integration Tests"
if: runner.os == 'Linux'
uses: ./.github/actions/run-dotnet-tests
with:
project-path: ${{ env.INTEGRATION_TEST_PROJECT_PATH }}
results-dir: ${{ runner.os == 'Windows' && format('{0}\integration', env.BASE_TEST_RESULTS_DIR) || format('{0}/integration', env.BASE_TEST_RESULTS_DIR) }}
configuration: "Release"
- name: "Publish Test Results"
id: test-results
uses: dorny/test-reporter@v1
if: success() || failure()
# Allow fork PRs to fail gracefully (permission error) without breaking the workflow
continue-on-error: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}
with:
name: "Test Results (${{ matrix.name }})"
path: "${{ env.BASE_TEST_RESULTS_DIR }}/**/*.trx"
reporter: "dotnet-trx"
path-replace-backslashes: true
fail-on-error: true
max-annotations: 50
- name: Update test badge via BadgeSmith API
if: always() && github.event_name == 'push' && github.ref == 'refs/heads/master'
continue-on-error: true
uses: ./.github/actions/update-test-badge
with:
platform: ${{ matrix.name }}
test_passed: '${{ steps.test-results.outputs.passed || 0 }}'
test_failed: '${{ steps.test-results.outputs.failed || 0 }}'
test_skipped: '${{ steps.test-results.outputs.skipped || 0 }}'
test_url_html: ${{ steps.test-results.outputs.url_html || '' }}
commit_sha: '${{ github.sha }}'
run_id: '${{ github.run_id }}'
repository: '${{ github.repository }}'
server_url: '${{ github.server_url }}'
api_domain: 'api.localstackfor.net'
hmac_secret: '${{ secrets.TESTDATASECRET }}'
- name: "Upload Test Artifacts"
uses: actions/upload-artifact@v4
if: always()
continue-on-error: true
with:
name: test-results-${{ matrix.name }}-${{ github.event.pull_request.number || github.run_number }}
path: |
${{ env.BASE_TEST_RESULTS_DIR }}/**/*
retention-days: 7
continuous-deployment:
name: "Continuous Deployment"
runs-on: ubuntu-22.04
needs: build-and-test
if: |
github.repository == 'localstack-dotnet/dotnet-aspire-for-localstack' &&
((github.event_name == 'push' && github.ref == 'refs/heads/master') ||
(github.event_name == 'pull_request' && startsWith(github.head_ref, 'feature/')))
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
permissions:
contents: read
packages: write
steps:
- name: "Checkout"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "Setup .NET SDK"
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x
9.0.x
10.0.x
- name: "Cache NuGet packages"
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nugetv2-${{ hashFiles('**/Directory.Packages.props') }}-${{ hashFiles('**/*.csproj') }}-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nugetv2-
- name: "Restore Dependencies"
run: dotnet restore
- name: "Build"
run: dotnet build --configuration Release --no-restore
- name: "Run Unit Tests"
run: dotnet test --project ./tests/Aspire.Hosting.LocalStack.Unit.Tests/Aspire.Hosting.LocalStack.Unit.Tests.csproj --verbosity normal --configuration Release --no-build
- name: "Setup GitHub Packages Authentication"
run: |
echo "🔐 Adding GitHub Packages authentication..."
dotnet nuget add source https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json \
--name github-packages \
--username ${{ github.actor }} \
--password ${{ secrets.GITHUB_TOKEN }} \
--store-password-in-clear-text
- name: "Determine Package Version"
id: version
run: |
# Extract base version from project file
PROJECT_FILE="src/Aspire.Hosting.LocalStack/Aspire.Hosting.LocalStack.csproj"
BASE_VERSION=$(grep -oP '<Version>\K[^<]+' "$PROJECT_FILE")
if [ -z "$BASE_VERSION" ]; then
echo "❌ Could not extract version from $PROJECT_FILE"
exit 1
fi
echo "📦 Base Version: $BASE_VERSION"
# Generate build metadata
RUN_NUMBER="${{ github.run_number }}" # monotonic
COMMIT_SHA=$(echo "${{ github.sha }}" | cut -c1-8)
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
# Feature branches: 9.5.0-feature-name.buildnumber (NuGet SemVer 2.0.0)
BRANCH_NAME="${{ github.head_ref }}"
# Sanitize branch name for use in version and artifact names
SAFE_BRANCH=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9]/-/g' | tr '[:upper:]' '[:lower:]')
VERSION="${BASE_VERSION}-${SAFE_BRANCH}.${RUN_NUMBER}"
ARTIFACT_SUFFIX="${SAFE_BRANCH}-${RUN_NUMBER}"
else
# Master CI builds: 9.5.0-ci.buildnumber (NuGet SemVer 2.0.0 pre-release)
VERSION="${BASE_VERSION}-ci.${RUN_NUMBER}"
ARTIFACT_SUFFIX="ci-${RUN_NUMBER}"
fi
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "artifact_suffix=${ARTIFACT_SUFFIX}" >> $GITHUB_OUTPUT
echo "📦 Final Package Version: ${VERSION}"
echo "📦 Artifact Suffix: ${ARTIFACT_SUFFIX}"
- name: "Pack NuGet Package"
run: |
echo "📦 Packing LocalStack.Aspire.Hosting package..."
dotnet pack src/Aspire.Hosting.LocalStack/Aspire.Hosting.LocalStack.csproj \
--configuration Release \
--no-build \
--output ./artifacts \
/p:PackageVersion=${{ steps.version.outputs.version }} \
/p:PackageId=LocalStack.Aspire.Hosting
- name: "Push to GitHub Packages"
run: |
echo "📦 Publishing to GitHub Packages..."
dotnet nuget push ./artifacts/*.nupkg \
--source github-packages \
--api-key ${{ secrets.GITHUB_TOKEN }} \
--skip-duplicate
- name: "Upload Package Artifacts"
uses: actions/upload-artifact@v4
with:
name: "packages-${{ steps.version.outputs.artifact_suffix }}"
path: |
artifacts/*.nupkg
artifacts/*.snupkg
retention-days: 7
- name: "Generate Build Summary"
run: |
echo "📦 Generating build summary..."
echo "## 📦 Package Build Summary" >> $GITHUB_STEP_SUMMARY
echo "- **Package**: LocalStack.Aspire.Hosting" >> $GITHUB_STEP_SUMMARY
echo "- **Version**: ${{ steps.version.outputs.version }} (NuGet SemVer 2.0.0)" >> $GITHUB_STEP_SUMMARY
echo "- **Branch/Ref**: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}" >> $GITHUB_STEP_SUMMARY
echo "- **Commit**: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
echo "- **Published to**: GitHub Packages" >> $GITHUB_STEP_SUMMARY
echo "- **Artifact**: packages-${{ steps.version.outputs.artifact_suffix }}" >> $GITHUB_STEP_SUMMARY