Skip to content

Commit 32d6b11

Browse files
authored
Add ATS API surface tracking workflow (#14418)
* Add ATS API surface tracking workflow with SqlServer example Add generate-ats-diffs.yml workflow that: - Runs aspire sdk dump --ci for each Aspire.Hosting.* project with [AspireExport] attributes - Saves output as .ats.txt files in each project's api/ directory - Dynamically discovers integration projects (excludes Analyzers, CodeGeneration, RemoteHost) - Auto-creates PR with NO-MERGE label (matching generate-api-diffs.yml pattern) Include SqlServer .ats.txt as an example of the generated output. Add workflow to CI exclusion list. * Fix review issues in generate-ats-diffs workflow - Fix subdirectory discovery: walk up from matched file to find nearest .csproj instead of assuming flat project layout - Fix silent failures: remove set +e and continue-on-error, track failures per project, exit non-zero if any fail, exit immediately if core dump fails - Fix inefficiency: build CLI once in a separate step, use --no-build in the loop
1 parent c900804 commit 32d6b11

File tree

3 files changed

+298
-0
lines changed

3 files changed

+298
-0
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
\.github/workflows/backport.yml
4747
\.github/workflows/dogfood-comment.yml
4848
\.github/workflows/generate-api-diffs.yml
49+
\.github/workflows/generate-ats-diffs.yml
4950
\.github/workflows/labeler-*.yml
5051
\.github/workflows/markdownlint*.yml
5152
\.github/workflows/refresh-manifests.yml
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Generate ATS Diffs
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 16 * * *' # 8am PST (16:00 UTC)
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
generate-and-pr:
14+
runs-on: ubuntu-latest
15+
if: ${{ github.repository_owner == 'dotnet' }}
16+
steps:
17+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
18+
19+
- name: Restore
20+
run: ./restore.sh
21+
22+
- name: Build CLI
23+
run: ./dotnet.sh build src/Aspire.Cli/Aspire.Cli.csproj --configuration Release
24+
25+
- name: Discover and dump ATS capabilities
26+
run: |
27+
ASPIRE_CLI="./dotnet.sh run --no-build --project src/Aspire.Cli/Aspire.Cli.csproj --configuration Release --"
28+
FAILURES=0
29+
30+
# Dump core Aspire.Hosting capabilities (no integration argument)
31+
echo "::group::Aspire.Hosting (core)"
32+
if ! $ASPIRE_CLI sdk dump --ci -o src/Aspire.Hosting/api/Aspire.Hosting.ats.txt; then
33+
echo "::error::Failed to dump core Aspire.Hosting capabilities"
34+
exit 1
35+
fi
36+
echo "::endgroup::"
37+
38+
# Discover Aspire.Hosting.* integration projects with [AspireExport] attributes
39+
# Find project directories by resolving matched files to their nearest .csproj
40+
# Exclude infrastructure projects that define/analyze the attribute rather than use it
41+
PROJECTS=$(grep -rl '\[AspireExport(' src/Aspire.Hosting.*/ --include='*.cs' \
42+
| grep -v '/obj/' | grep -v '/bin/' \
43+
| grep -v 'Aspire.Hosting.Analyzers' \
44+
| grep -v 'Aspire.Hosting.CodeGeneration' \
45+
| grep -v 'Aspire.Hosting.RemoteHost' \
46+
| while read -r file; do
47+
# Walk up from the file to find the directory containing a .csproj
48+
dir=$(dirname "$file")
49+
while [ "$dir" != "." ] && [ "$dir" != "/" ]; do
50+
if ls "$dir"/*.csproj 1>/dev/null 2>&1; then
51+
echo "$dir"
52+
break
53+
fi
54+
dir=$(dirname "$dir")
55+
done
56+
done | sort -u)
57+
58+
for proj in $PROJECTS; do
59+
proj_name=$(basename "$proj")
60+
csproj="$proj/$proj_name.csproj"
61+
if [ -f "$csproj" ]; then
62+
echo "::group::$proj_name"
63+
mkdir -p "$proj/api"
64+
if ! $ASPIRE_CLI sdk dump --ci "$csproj" -o "$proj/api/$proj_name.ats.txt"; then
65+
echo "::error::Failed to dump ATS capabilities for $proj_name"
66+
FAILURES=$((FAILURES + 1))
67+
fi
68+
echo "::endgroup::"
69+
fi
70+
done
71+
72+
if [ "$FAILURES" -gt 0 ]; then
73+
echo "::error::$FAILURES project(s) failed ATS capability dump"
74+
exit 1
75+
fi
76+
77+
- name: Create or update pull request
78+
uses: dotnet/actions-create-pull-request@e8d799aa1f8b17f324f9513832811b0a62f1e0b1
79+
with:
80+
token: ${{ secrets.GITHUB_TOKEN }}
81+
branch: update-ats-diffs
82+
base: main
83+
labels: |
84+
NO-MERGE
85+
title: "[Automated] Update ATS API Surface Area"
86+
body: "Auto-generated update to the ATS (Aspire Type System) capability surface to compare current surface vs latest release. This should only be merged once this surface area ships in a new release."

0 commit comments

Comments
 (0)