Skip to content

Bump Microsoft.AspNetCore.Components.Analyzers from 9.0.14 to 10.0.7 #1218

Bump Microsoft.AspNetCore.Components.Analyzers from 9.0.14 to 10.0.7

Bump Microsoft.AspNetCore.Components.Analyzers from 9.0.14 to 10.0.7 #1218

# This workflow will build and push a web application to an Azure Static Web App when you change your code.
#
# This workflow assumes you have already created the target Azure Static Web App.
# For instructions see https://docs.microsoft.com/azure/static-web-apps/get-started-portal?tabs=vanilla-javascript
#
# To configure this workflow:
#
# 1. Set up a secret in your repository named AZURE_STATIC_WEB_APPS_API_TOKEN with the value of your Static Web Apps deployment token.
# For instructions on obtaining the deployment token see: https://docs.microsoft.com/azure/static-web-apps/deployment-token-management
#
# 3. Change the values for the APP_LOCATION, API_LOCATION and APP_ARTIFACT_LOCATION, AZURE_STATIC_WEB_APPS_API_TOKEN environment variables (below).
# For instructions on setting up the appropriate configuration values go to https://docs.microsoft.com/azure/static-web-apps/front-end-frameworks
name: Deploy to Azure Static Web Apps
on:
push:
branches: ["master"]
pull_request:
types: [opened, synchronize, reopened, closed]
branches: ["master"]
# Environment variables available to all jobs and steps in this workflow
env:
APP_LOCATION: "src/redmuffin.Blazor.StaticWeb" # location of your client code
API_LOCATION: "src/redmuffin.Blazor.StaticWeb.Api" # location of your api source code - optional
APP_ARTIFACT_LOCATION: "wwwroot" # location of client code build output
AZURE_STATIC_WEB_APPS_API_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_LIVELY_CLIFF_0945BE603 }} # secret containing deployment token for your static web app
permissions:
contents: read
jobs:
check_changes:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_output.outputs.should_skip }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Full history for reliable change detection
show-progress: false # Reduce log noise
- name: Check if only documentation files changed
id: check
uses: tj-actions/changed-files@v47.0.6
with:
since_last_remote_commit: true
files: |
README.md
AGENTS.md
CHANGELOG.md
docs/**/*.md
tasks/**/*.md
spec/**/*
.github/guides/**/*.md
.github/prompts/**/*.md
.github/chatmodes/**/*.md
.opencode/**/*
tests/**/*
scripts/**/*
.editorconfig
.mcp.json
.coverletrc
.vscode/**/*
*.code-workspace
*.sln.DotSettings
.config/**/*
.filenesting.json
.trae/**/*
swa-cli.config.json
Start.ps1
test.ps1
config/**/*
.changelog-state
src/**/Properties/launchSettings.json
src/**/appsettings.Development.json
src/**/*.local.settings.json*
.gitattributes
.gitignore
- name: Set skip output
id: skip_output
run: |
# Use the changed-files action's built-in logic instead of complex shell script
if [[ "${{ steps.check.outputs.only_changed }}" == "true" ]]; then
echo "Only documentation and non-deployed files changed, skipping deployment"
echo "should_skip=true" >> $GITHUB_OUTPUT
else
echo "Code files changed, proceeding with deployment"
echo "should_skip=false" >> $GITHUB_OUTPUT
fi
test_and_build_job:
needs: check_changes
if: |
needs.check_changes.outputs.should_skip != 'true' &&
(github.event_name != 'pull_request' || github.event.action != 'closed')
runs-on: ubuntu-latest
name: Test, Build and Deploy
env:
# Environment variables for Azure Functions testing
# These are automatically picked up by:
# - TestBase class via AddEnvironmentVariables() for tests
# - Settings class via Environment.GetEnvironmentVariable() for Azure Functions
# No local.settings.json file needed in CI/CD - optimized for faster execution
Values__RainDropClientId: ${{ secrets.RAINDROP_CLIENT_ID }}
Values__RainDropClientSecret: ${{ secrets.RAINDROP_CLIENT_SECRET }}
Values__RainDropTestToken: ${{ secrets.RAINDROP_TEST_TOKEN }}
steps:
- name: Check out code
uses: actions/checkout@v6
with:
fetch-depth: 1 # Shallow clone for faster checkout
show-progress: false # Reduce log noise
- name: Display job context
run: |
echo "=== Job Context ==="
echo "Job: test_and_build_job"
echo "Trigger: ${{ github.event_name }}"
echo "Ref: ${{ github.ref }}"
echo "Commit: ${{ github.sha }}"
echo "Actor: ${{ github.actor }}"
echo "Runner: ${{ runner.os }}"
echo ""
- name: Display system resources
run: |
echo "=== System Resources ==="
echo "CPU: $(nproc) cores"
echo "Memory: $(free -h | grep Mem | awk '{print $2}' | sed 's/i//g')"
echo "Disk available: $(df -h / | tail -1 | awk '{print $4}')"
echo ""
# OPTIMIZATION: Single .NET setup with WASM workload for Blazor builds
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: "9.x"
workloads: wasm-tools
# OPTIMIZATION: Cache NuGet packages for faster subsequent builds
- name: Cache NuGet packages
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj', '**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
# OPTIMIZATION: Single dependency restoration
- name: Restore dependencies
run: dotnet restore
# TESTING PHASE: Fast fail if tests don't pass with parallel execution
# Note: Tests automatically use environment variables set in the job environment
# No local.settings.json file needed as TestBase class uses AddEnvironmentVariables()
# OPTIMIZATION: Run tests in Release mode to avoid double compilation
- name: Run tests
run: |
echo "Running tests..."
echo "Configuration: Release mode, parallel execution enabled"
dotnet test -c Release --no-restore --verbosity quiet --logger trx --results-directory TestResults /p:CollectCoverage=false
TEST_EXIT_CODE=$?
if [ $TEST_EXIT_CODE -ne 0 ]; then
echo ""
echo "❌ STEP FAILED: Test Execution"
echo "Exit code: $TEST_EXIT_CODE"
echo ""
exit $TEST_EXIT_CODE
fi
# BUILD AND DEPLOY PHASE: Only runs if tests pass
- name: Setup Node.js for Azure Static Web Apps CLI
uses: actions/setup-node@v6
with:
node-version: "18"
# OPTIMIZATION: Cache npm global packages for SWA CLI
# Using static key since we install a specific global package version
- name: Cache npm and SWA CLI
uses: actions/cache@v5
with:
path: |
~/.npm
$(npm root -g)
~/.swa
key: ${{ runner.os }}-npm-swa-cli-v2
restore-keys: |
${{ runner.os }}-npm-swa-cli-
# Supply chain protection: reject packages published less than 7 days ago
- name: Configure npm supply chain protection
run: |
echo "min-release-age=10080" >> ~/.npmrc
echo "Supply chain protection: minimum release age set to 7 days"
# Install Azure Static Web Apps CLI (uses cache when available)
- name: Install Azure Static Web Apps CLI
run: |
echo "Installing Azure Static Web Apps CLI..."
npm install -g @azure/static-web-apps-cli --silent --no-audit --no-fund
echo "Azure Static Web Apps CLI version: $(swa --version)"
- name: Build and Deploy to Azure Static Web Apps
env:
AZURE_STATIC_WEB_APPS_API_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_LIVELY_CLIFF_0945BE603 }}
run: |
# OPTIMIZED AZURE STATIC WEB APPS DEPLOYMENT
# Benefits of this optimized approach:
# - Single job reduces runner overhead and speeds up pipeline
# - Tests run first for fast failure (fail-fast principle)
# - No duplicate .NET setup, checkout, or dependency restoration
# - Shared environment and context between test and deploy phases
# - No local.settings.json file creation - uses environment variables directly
set -e # Exit on any error
echo "Environment Information:"
echo "Working Directory: $(pwd)"
echo "Node Version: $(node --version)"
echo "NPM Version: $(npm --version)"
echo ".NET Version: $(dotnet --version)"
echo "SWA CLI Version: $(swa --version)"
echo ""
echo "Project Structure:"
echo "App Location: ${{ env.APP_LOCATION }}"
echo "API Location: ${{ env.API_LOCATION }}"
echo "Output Location: ${{ env.APP_ARTIFACT_LOCATION }}"
echo ""
echo "Building Blazor WebAssembly Application..."
# Build with optimizations for production deployment
dotnet publish ${{ env.APP_LOCATION }} \
-c Release \
-o ${{ env.APP_LOCATION }}/bin/Release/publish \
--no-restore \
--verbosity quiet \
--nologo
echo ""
echo "Verifying trimming effectiveness..."
ASSEMBLY_COUNT=$(jq '.resources.assembly | length' "${{ env.APP_LOCATION }}/bin/Release/publish/wwwroot/_framework/blazor.boot.json")
echo "Number of assemblies in blazor.boot.json: $ASSEMBLY_COUNT"
if [ "$ASSEMBLY_COUNT" -gt 100 ]; then
echo "❌ WARNING: High assembly count ($ASSEMBLY_COUNT) suggests trimming may not be working properly"
else
echo "✅ Assembly count ($ASSEMBLY_COUNT) looks good for trimmed build"
fi
echo ""
echo "Building Azure Functions API..."
dotnet publish ${{ env.API_LOCATION }} \
-c Release \
-o ${{ env.API_LOCATION }}/bin/Release/publish \
--no-restore \
--no-dependencies \
--verbosity quiet \
--nologo
echo ""
echo "Deploying to Azure Static Web Apps..."
# Deploy with minimal output (removed --print-config for faster execution)
swa deploy \
--app-location ${{ env.APP_LOCATION }}/bin/Release/publish \
--api-location ${{ env.API_LOCATION }}/bin/Release/publish \
--output-location ${{ env.APP_ARTIFACT_LOCATION }} \
--deployment-token $AZURE_STATIC_WEB_APPS_API_TOKEN \
--env production \
--no-use-keychain
echo ""
echo "=== Pipeline Summary ==="
echo "Tests: Completed"
echo "Build: Success"
echo "Deploy: Success"
echo ""
echo "✅ All checks passed"
# JOB: Verify both frontend and API are healthy after deployment
health_check:
needs: test_and_build_job
runs-on: ubuntu-latest
name: Health Check
steps:
- name: Verify deployment health
run: |
set -e # Exit on any error
echo "=== Health Check ==="
echo "Checking both frontend and API endpoints..."
# Wait for deployment to settle
sleep 5
# Run both checks in parallel
check_site() {
echo "Checking frontend: https://redmuffin.net"
curl -f -s --max-time 10 --retry 2 --retry-delay 5 "https://redmuffin.net" > /dev/null
echo "✅ Frontend is accessible"
}
check_api() {
echo "Checking API: https://redmuffin.net/api/HelloWorld"
RESPONSE=$(curl -f -s --max-time 10 --retry 2 --retry-delay 5 "https://redmuffin.net/api/HelloWorld")
if echo "$RESPONSE" | grep -q "Welcome to Azure Functions!"; then
echo "✅ API is accessible and returning expected response"
else
echo "❌ API response unexpected: $RESPONSE"
return 1
fi
}
# Execute both checks in parallel
check_site &
SITE_PID=$!
check_api &
API_PID=$!
# Wait for both to complete
wait $SITE_PID || { echo "❌ Frontend check failed"; kill $API_PID 2>/dev/null; exit 1; }
wait $API_PID || { echo "❌ API check failed"; exit 1; }
echo ""
echo "=== Health Check Complete ==="
echo "✅ All endpoints verified successfully"
echo "Total time: ~20-25 seconds"
# JOB: Handle documentation-only changes (skipped deployment)
docs_only_changed_job:
needs: check_changes
if: |
(github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')) &&
needs.check_changes.outputs.should_skip == 'true'
runs-on: ubuntu-latest
name: Documentation Only Changed
steps:
- name: Skip Deployment
run: |
echo "Only documentation and non-deployed files changed."
echo "Skipping deployment process as no code changes were detected."
echo ""
echo "WHAT THIS MEANS FOR YOU:"
echo " - Tests and builds are skipped to save time and resources"
echo " - Documentation changes don't require application redeployment"
echo " - Your live application remains unchanged and operational"
echo " - GitHub Pages documentation will still be updated automatically"
# JOB: Handle pull request closures
close_pull_request_job:
permissions:
contents: none
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_LIVELY_CLIFF_0945BE603 }}
action: "close"