Skip to content

[IGNORE] Testing pr scripts #10859

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions .github/workflows/build-cli-native-archives.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: Build native CLI archives

on:
workflow_call:
inputs:
versionOverrideArg:
required: false
type: string

jobs:

Expand Down Expand Up @@ -36,6 +40,7 @@ jobs:
/p:ContinuousIntegrationBuild=true
/p:SkipManagedBuild=true
/p:TargetRids=${{ matrix.targets.rids }}
${{ inputs.versionOverrideArg }}
- name: Build CLI packages (Unix)
env:
Expand All @@ -51,6 +56,7 @@ jobs:
/p:ContinuousIntegrationBuild=true
/p:SkipManagedBuild=true
/p:TargetRids=${{ matrix.targets.rids }}
${{ inputs.versionOverrideArg }}
- name: Upload logs
if: always()
Expand Down
120 changes: 120 additions & 0 deletions .github/workflows/build-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Build Packages (Reusable)

on:
workflow_call:
inputs:
versionOverrideArg:
required: false
type: string
outputs:
arch_rids:
description: JSON array of architecture-specific RIDs discovered during packaging
value: ${{ jobs.build_packages.outputs.arch_rids }}

jobs:
build_packages:
name: Build packages
runs-on: ubuntu-latest
outputs:
arch_rids: ${{ steps.stage_rid_specific.outputs.rids }}
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Build with packages
env:
CI: false
run: ./build.sh -restore -build -ci -pack -bl -p:InstallBrowsersForPlaywright=false -p:SkipTestProjects=true ${{ inputs.versionOverrideArg }}

- name: Stage RID-specific NuGets and remaining packages
id: stage_rid_specific
shell: bash
run: |
set -euo pipefail
set -x
shopt -s nullglob
mkdir -p staging/built-nugets staging/rid
# Copy full packages tree first (so structure expected by downstream tests is preserved)
rsync -a artifacts/packages/ staging/built-nugets/
declare -A RID_SET=()
# Find target packages (dcp and dashboard)
while IFS= read -r -d '' pkg; do
bn="$(basename "$pkg")"
rid=""
if [[ $bn =~ ^Aspire\.Hosting\.Orchestration\.([^.]+)\..*\.nupkg$ ]]; then
rid="${BASH_REMATCH[1]}"
elif [[ $bn =~ ^Aspire\.Dashboard\.Sdk\.([^.]+)\..*\.nupkg$ ]]; then
rid="${BASH_REMATCH[1]}"
else
continue
fi
if [[ -n $rid ]]; then
RID_SET["$rid"]=1
mkdir -p "staging/rid/$rid"
cp "$pkg" "staging/rid/$rid/"
# Remove from built-nugets staging copy so it is excluded there
rel="${pkg#artifacts/packages/}"
rm -f "staging/built-nugets/$rel" || true
fi
done < <(find artifacts/packages -type f \( -name 'Aspire.Hosting.Orchestration.*.nupkg' -o -name 'Aspire.Dashboard.Sdk.*.nupkg' \) -print0)
# Build JSON array of RIDs
if (( ${#RID_SET[@]} )); then
printf '%s\n' "${!RID_SET[@]}" | sort -u > /tmp/rids.txt
# Build a compact single-line JSON array (avoid pretty-print newlines which break $GITHUB_OUTPUT)
json=$(jq -R . < /tmp/rids.txt | jq -s -c .)
else
json='[]'
fi
echo "Discovered RIDs: $json"
# Use printf to safely write (single line) to GITHUB_OUTPUT
printf 'rids=%s\n' "$json" >> "$GITHUB_OUTPUT"
- name: Upload built NuGets (excluding RID-specific orchestration/dashboard)
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: built-nugets
path: staging/built-nugets
if-no-files-found: error
retention-days: 15

- name: Upload consolidated RID-specific NuGets
if: ${{ steps.stage_rid_specific.outputs.rids != '[]' }}
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: built-nugets-for-rid-all
path: staging/rid
if-no-files-found: error
retention-days: 1

- name: Upload logs
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: build_packages_logs
path: artifacts/log

upload_arch_specific_nugets:
name: Upload arch-specific NuGets
needs: build_packages
if: ${{ needs.build_packages.outputs.arch_rids != '[]' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
rid: ${{ fromJson(needs.build_packages.outputs.arch_rids) }}
steps:
- name: Download consolidated RID-specific NuGets
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
name: built-nugets-for-rid-all
path: rid-nugets

- name: Upload per-RID NuGets
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
with:
name: built-nugets-for-${{ matrix.rid }}
path: rid-nugets/${{ matrix.rid }}/*.nupkg
if-no-files-found: error
retention-days: 15

42 changes: 34 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}


jobs:

check_changes:
prepare_for_ci:
runs-on: ubuntu-latest
name: Check Changed Files
name: Prepare for CI
if: ${{ github.repository_owner == 'dotnet' }}
outputs:
skip_workflow: ${{ (steps.check_docs.outputs.no_changes == 'true' || steps.check_docs.outputs.only_changed == 'true') && 'true' || 'false' }}
VERSION_SUFFIX_OVERRIDE: ${{ steps.compute_version_suffix.outputs.VERSION_SUFFIX_OVERRIDE }}

steps:
- name: Checkout code
if: ${{ github.event_name == 'pull_request' }}
Expand All @@ -38,24 +41,47 @@ jobs:
patterns: |
\.md$

- id: compute_version_suffix
name: Compute version suffix for PRs
if: ${{ github.event_name == 'pull_requestx' }}
shell: pwsh
env:
# Use the pull request head SHA instead of GITHUB_SHA (which can be a merge commit)
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PR_NUMBER: ${{ github.event.number }}
run: |
Write-Host "Determining VERSION_SUFFIX_OVERRIDE (PR only step)..."
if ([string]::IsNullOrWhiteSpace($Env:PR_HEAD_SHA)) {
Write-Error "PR_HEAD_SHA not set; cannot compute version suffix."
exit 1
}
$SHORT_SHA = $Env:PR_HEAD_SHA.Substring(0,8)
$VERSION_SUFFIX = "/p:VersionSuffix=pr.$($Env:PR_NUMBER).$SHORT_SHA"
Write-Host "Computed VERSION_SUFFIX_OVERRIDE=$VERSION_SUFFIX"
"VERSION_SUFFIX_OVERRIDE=$VERSION_SUFFIX" | Out-File -FilePath $Env:GITHUB_OUTPUT -Append -Encoding utf8

tests:
uses: ./.github/workflows/tests.yml
name: Tests
needs: [check_changes]
if: ${{ github.repository_owner == 'dotnet' && needs.check_changes.outputs.skip_workflow != 'true' }}
needs: [prepare_for_ci]
if: ${{ github.repository_owner == 'dotnet' && needs.prepare_for_ci.outputs.skip_workflow != 'true' }}
with:
versionOverrideArg: ${{ needs.prepare_for_ci.outputs.VERSION_SUFFIX_OVERRIDE }}

build_cli_archives:
uses: ./.github/workflows/build-cli-native-archives.yml
name: Build native CLI archives
needs: [check_changes]
if: ${{ github.repository_owner == 'dotnet' && needs.check_changes.outputs.skip_workflow != 'true' }}
needs: [prepare_for_ci]
if: ${{ github.repository_owner == 'dotnet' && needs.prepare_for_ci.outputs.skip_workflow != 'true' }}
with:
versionOverrideArg: ${{ needs.prepare_for_ci.outputs.VERSION_SUFFIX_OVERRIDE }}

# This job is used for branch protection. It fails if any of the dependent jobs failed
results:
if: ${{ always() && github.repository_owner == 'dotnet' }}
runs-on: ubuntu-latest
name: Final Results
needs: [check_changes, tests, build_cli_archives]
needs: [prepare_for_ci, tests, build_cli_archives]

steps:
- name: Fail if any of the dependent jobs failed
Expand All @@ -66,7 +92,7 @@ jobs:
# 'skipped'
if: >-
${{ always() &&
needs.check_changes.outputs.skip_workflow != 'true' &&
needs.prepare_for_ci.outputs.skip_workflow != 'true' &&
(contains(needs.*.result, 'failure') ||
contains(needs.*.result, 'cancelled') ||
contains(needs.*.result, 'skipped')) }}
Expand Down
50 changes: 49 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ on:
extraTestArgs:
required: false
type: string
versionOverrideArg:
required: false
type: string
# Triggers downloading the built nugets, and running the tests
# from the archive outside the repo
requiresNugets:
Expand Down Expand Up @@ -113,6 +116,50 @@ jobs:
run:
Move-Item -Path "${{ github.workspace }}/artifacts/packages/built-nugets/Debug" -Destination "${{ github.workspace }}/artifacts/packages"

- name: Compute RID for arch-specific packages
if: ${{ inputs.requiresNugets }}
id: compute_rid
shell: pwsh
run: |
$os = "${{ inputs.os }}"
switch ($os) {
'ubuntu-latest' { $rid = 'linux-x64' }
'macos-latest' { $rid = 'osx-arm64' }
'windows-latest'{ $rid = 'win-x64' }
Default { Write-Error "Unknown OS '$os' for RID mapping"; exit 1 }
}
Write-Host "Using RID=$rid"
"RID=$rid" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"rid=$rid" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
- name: Download arch-specific nugets
if: ${{ inputs.requiresNugets }}
continue-on-error: true
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
with:
name: built-nugets-for-${{ steps.compute_rid.outputs.rid }}
path: ${{ github.workspace }}/arch-specific

- name: Merge arch-specific nugets into package feed
if: ${{ inputs.requiresNugets }}
shell: pwsh
run: |
$dest = "${{ github.workspace }}/artifacts/packages/Debug/Shipping"
if (-not (Test-Path $dest)) { New-Item -ItemType Directory -Path $dest -Force | Out-Null }
$source = "${{ github.workspace }}/arch-specific"
if (-not (Test-Path $source)) {
Write-Error "Source folder '$source' does not exist."; exit 1
}
$nupkgs = Get-ChildItem -Path $source -Filter *.nupkg -ErrorAction SilentlyContinue
if (-not $nupkgs -or $nupkgs.Count -eq 0) {
Write-Error "No arch-specific nugets found in '$source'"; exit 1
} else {
foreach ($pkg in $nupkgs) {
Copy-Item -Path $pkg.FullName -Destination $dest -Force
}
Write-Host "Merged $($nupkgs.Count) arch-specific nugets for RID=$env:RID into $dest"
}
- name: Install sdk for nuget based testing
if: ${{ inputs.requiresTestSdk }}
env:
Expand Down Expand Up @@ -159,7 +206,7 @@ jobs:
env:
CI: false
run: |
${{ env.BUILD_SCRIPT }} -restore -ci -build -projects ${{ env.TEST_PROJECT_PATH }}
${{ env.BUILD_SCRIPT }} -restore -ci -build -projects ${{ env.TEST_PROJECT_PATH }} ${{ inputs.versionOverrideArg }}
- name: Build and archive test project
if: ${{ inputs.requiresNugets }}
Expand All @@ -169,6 +216,7 @@ jobs:
${{ env.BUILD_SCRIPT }} -restore -ci -build -projects ${{ env.TEST_PROJECT_PATH }}
/p:PrepareForHelix=true
/bl:${{ github.workspace }}/artifacts/log/Debug/PrepareForHelix.binlog
${{ inputs.versionOverrideArg }}
# Workaround for bug in Azure Functions Worker SDK. See https://github.com/Azure/azure-functions-dotnet-worker/issues/2969.
- name: Rebuild for Azure Functions project
Expand Down
Loading
Loading