Download updated expected app size files from Azure DevOps CI artifacts for the current branch. Use when app size tests fail in CI and the user wants to update the expected files locally. Trigger on "update app size", "download expected files", "fix app size test", or "update expected app size files".
72
88%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Low
Low-risk findings worth noting
Download updated expected app size files from Azure DevOps artifacts for the current branch's PR build, and apply them to the repository.
The app size tests (tests/dotnet/UnitTests/AppSizeTest.cs) compare the built app's size and preserved APIs against expected files stored in tests/dotnet/UnitTests/expected/. When the test detects a difference and WRITE_KNOWN_FAILURES is not set, it writes the updated expected file to $(Build.ArtifactStagingDirectory)/updated-expected-sizes/, and a pipeline step publishes this directory as a build artifact.
The artifact name follows the pattern {uploadPrefix}updated-expected-sizes-{testPrefix}-{attempt} (e.g., updated-expected-sizes-dotnettests_ios-1). Because the expected files can be very big, the test uploads a unified diff for each changed expected file rather than the whole file. Inside the artifact, files are named after the test variant with a .diff suffix:
{Platform}-{Variant}-size.txt.diff — e.g., iOS-MonoVM-size.txt.diff, iOS-MonoVM-interpreter-size.txt.diff, iOS-NativeAOT-TrimmableStatic-size.txt.diff, MacOSX-CoreCLR-Interpreter-size.txt.diff{Platform}-{Variant}-preservedapis.txt.diff — e.g., iOS-MonoVM-preservedapis.txt.diff, MacCatalyst-MonoVM-interpreter-preservedapis.txt.diffEach diff is a unified diff (relative to the repository root) that can be applied with git apply -p1 or patch -p1. The expected files on disk are at:
tests/dotnet/UnitTests/expected/{Platform}-{Variant}-size.txttests/dotnet/UnitTests/expected/{Platform}-{Variant}-preservedapis.txtBRANCH=$(git branch --show-current)
# Find the PR number for this branch
gh pr list --head "$BRANCH" --repo dotnet/macios --json number,url --jq '.[0]'If no PR is found, inform the user that this skill requires a PR to exist for the current branch (so that CI has run).
The CI builds for PRs in dotnet/macios run in the devdiv Azure DevOps organization, project DevDiv.
Use the GitHub PR checks to find the Azure DevOps build URL:
gh pr checks <PR_NUMBER> --repo dotnet/maciosLook for a check that links to Azure DevOps. The build URL will look like:
https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=XXXXXXXExtract the buildId from the URL.
Use the Azure DevOps REST API to list and download artifacts:
# List artifacts for the build
TOKEN=$(az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 --query accessToken -o tsv)
curl -s "https://devdiv.visualstudio.com/DevDiv/_apis/build/builds/{buildId}/artifacts?api-version=7.0" \
-H "Authorization: Bearer $TOKEN"Look for artifacts whose names contain updated-expected-sizes (e.g., updated-expected-sizes-dotnettests_ios-1). Get the artifact's downloadUrl and download it:
# Get the download URL for a specific artifact
ARTIFACT_INFO=$(curl -s "https://devdiv.visualstudio.com/DevDiv/_apis/build/builds/{buildId}/artifacts?artifactName={artifactName}&api-version=7.0" \
-H "Authorization: Bearer $TOKEN")
DOWNLOAD_URL=$(echo "$ARTIFACT_INFO" | python3 -c "import sys,json; print(json.load(sys.stdin)['resource']['downloadUrl'])")
# Download the artifact zip
curl -sL "$DOWNLOAD_URL" -H "Authorization: Bearer $TOKEN" -o artifact.zipIf az is not available or not authenticated, direct the user to download manually from the Azure DevOps build artifacts page.
Extract the downloaded artifact zip and apply each diff to the expected directory from the repository root:
unzip -o artifact.zip -d /tmp/updated-sizes/
# Each '*.txt.diff' is a unified diff relative to the repository root.
for diff in /tmp/updated-sizes/*/*.txt.diff; do
git apply -p1 "$diff"
doneThe diffs reference tests/dotnet/UnitTests/expected/<name>.txt directly, so applying them updates (or creates) the expected files in place. If a diff fails to apply cleanly (e.g., the expected file changed since the CI build), re-run the failing app size test locally with WRITE_KNOWN_FAILURES=1 to regenerate the file (see the "Run Locally" fallback).
After placing the files:
git diff to show what changedgit add tests/dotnet/UnitTests/expected/
git commit -m "[tests] Update expected app size files"If automated download fails (auth issues, etc.), provide the user with:
updated-expected-sizes.txt.diff files (e.g., iOS-MonoVM-interpreter-size.txt.diff) from the repository root with git apply -p1 <file>If the user can build locally, they can update the expected files directly:
WRITE_KNOWN_FAILURES=1 tests-dotnet AppSizeTestThis runs the tests, updates the expected files in place, and marks the tests as passed.
d259b5f
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.