diff --git a/.github/actions/environment/action.yml b/.github/actions/environment/action.yml index 4b39841de0..ac61ac303b 100644 --- a/.github/actions/environment/action.yml +++ b/.github/actions/environment/action.yml @@ -22,14 +22,35 @@ runs: with: log-accepted-android-sdk-licenses: false + # https://github.com/actions/runner-images/issues/10814 + - name: Workaround build-tools issue + if: runner.os == 'macOS' + shell: bash + run: | + curl https://dl.google.com/android/repository/build-tools_r35_macosx.zip > $ANDROID_HOME/build-tools_r35_macosx.zip + cd $ANDROID_HOME + mkdir -p build-tools + unzip build-tools_r35_macosx.zip + mv android-15 build-tools/35.0.0 + cd - + - name: Set Java Version uses: actions/setup-java@v3 with: distribution: 'temurin' java-version: '11' - # .NET 6 and .NET 8 are not built-in with macos-13 + - name: Install Mono + if: runner.os == 'macOS' + shell: bash + # Attempt to install Mono, allowing it to fail silently + # Then ensure mono is correctly linked, overwriting any conflicting symlinks + run: | + brew install mono || true + brew link --overwrite mono + - name: Install .NET SDK + if: runner.os != 'Windows' uses: actions/setup-dotnet@v3 with: dotnet-version: | diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0afa61169c..967fd16fa0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,11 +15,12 @@ env: jobs: build-sentry-native: name: sentry-native (${{ matrix.os }}) - runs-on: ${{ matrix.os }}-latest + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [ubuntu, windows, macos] + # Pin macos to get the version of XCode that we need: https://github.com/actions/runner-images/issues/10703 + os: [ubuntu-latest, windows-latest, macos-15] steps: - name: Checkout @@ -35,7 +36,7 @@ jobs: enableCrossOsArchive: true - name: Free Disk Space (Ubuntu) - if: matrix.os == 'ubuntu-latest' + if: runner.os == 'Linux' uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be with: android: true @@ -63,7 +64,8 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + # Pin macos to get the version of XCode that we need: https://github.com/actions/runner-images/issues/10703 + os: [ubuntu-latest, windows-latest, macos-15] steps: - name: Cancel Previous Runs @@ -71,23 +73,11 @@ jobs: uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # Tag: 0.12.1 - name: Setup Xcode - if: matrix.os == 'macos-latest' + if: runner.os == 'macOS' run: | sudo xcode-select --switch /Applications/Xcode_${{env.XCODE_VERSION}}.app/Contents/Developer xcodebuild -version - # We only use Xcode 16 - - name: Remove unused applications - if: matrix.os == 'macos-latest' - run: | - df -hI /dev/disk3s1s1 - sudo rm -rf /Applications/Xcode_14.3.1.app - sudo rm -rf /Applications/Xcode_15.0.1.app - sudo rm -rf /Applications/Xcode_15.1.app - sudo rm -rf /Applications/Xcode_15.2.app - sudo rm -rf /Applications/Xcode_15.3.app - df -hI /dev/disk3s1s1 - - name: Checkout uses: actions/checkout@v4 with: @@ -96,7 +86,7 @@ jobs: # We use macOS for the final publishing build so we we get all the iOS/macCatalyst targets in the packages - name: Set Environment Variables - if: startsWith(matrix.os, 'macos') + if: runner.os == 'macOS' run: echo "CI_PUBLISHING_BUILD=true" >> $GITHUB_ENV - name: Download sentry-native (Linux) @@ -133,6 +123,12 @@ jobs: - name: Restore .NET Dependencies run: dotnet restore Sentry-CI-Build-${{ runner.os }}.slnf --nologo + - name: Install Android SDKs + if: runner.os == 'macOS' + run: | + dotnet build src/Sentry/Sentry.csproj -t:InstallAndroidDependencies -f:net7.0-android -p:AcceptAndroidSDKLicenses=True -p:AndroidSdkPath="/usr/local/lib/android/sdk/" + dotnet build src/Sentry/Sentry.csproj -t:InstallAndroidDependencies -f:net8.0-android -p:AcceptAndroidSDKLicenses=True -p:AndroidSdkPath="/usr/local/lib/android/sdk/" + - name: Build run: dotnet build Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-restore --nologo -v:minimal -flp:logfile=build.log -p:CopyLocalLockFileAssemblies=true @@ -173,7 +169,8 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + # Pin macos to get the version of XCode that we need: https://github.com/actions/runner-images/issues/10703 + os: [ubuntu-latest, windows-latest, macos-15] steps: - uses: actions/checkout@v4 @@ -183,6 +180,7 @@ jobs: sparse-checkout: | Directory.Build.props integration-test + .github - name: Fetch Nuget Packages uses: actions/download-artifact@v4 with: @@ -195,26 +193,8 @@ jobs: sudo apt update sudo apt install libcurl4-openssl-dev - - uses: actions/setup-dotnet@v4 - with: - dotnet-version: 8.0.x - - - name: Setup Xcode - if: matrix.os == 'macos-latest' - run: | - sudo xcode-select --switch /Applications/Xcode_${{env.XCODE_VERSION}}.app/Contents/Developer - xcodebuild -version - - # Needed for Android SDK setup step - - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: '17' - - - name: Setup Android SDK - uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2 - - - run: dotnet workload install android maui-android + - name: Setup Environment + uses: ./.github/actions/environment - name: Test uses: getsentry/github-workflows/sentry-cli/integration-test/@v2 diff --git a/.github/workflows/format-code.yml b/.github/workflows/format-code.yml index 9a867477be..453d598fbc 100644 --- a/.github/workflows/format-code.yml +++ b/.github/workflows/format-code.yml @@ -10,9 +10,9 @@ on: jobs: format-code: name: Format Code - # Running on 'macos' because Linux is missing the `ios` workload - # See: https://github.com/dotnet/runtime/issues/85505 - runs-on: macos-latest + # Run on 'macos' because Linux is missing the `ios` workload: https://github.com/dotnet/runtime/issues/85505 + # Pin macos to get the version of XCode that we need: https://github.com/actions/runner-images/issues/10703 + runs-on: macos-15 steps: - name: Checkout uses: actions/checkout@v4 @@ -29,7 +29,7 @@ jobs: run: dotnet tool install -g dotnet-format - name: Format Code - # We're excluding `./**/*OptionsSetup.cs` from the format because the tool struggles with + # We're excluding `./**/*OptionsSetup.cs` from the format because the tool struggles with # source generators run: dotnet format Sentry.sln --no-restore --exclude ./modules --exclude ./**/*OptionsSetup.cs @@ -37,4 +37,4 @@ jobs: # we need to pass the current branch, otherwise we can't commit the changes. # GITHUB_HEAD_REF is the name of the head branch. GitHub Actions only sets this for PRs. - name: Commit Formatted Code - run: ./scripts/commit-formatted-code.sh $GITHUB_HEAD_REF \ No newline at end of file + run: ./scripts/commit-formatted-code.sh $GITHUB_HEAD_REF diff --git a/.github/workflows/vulnerabilities.yml b/.github/workflows/vulnerabilities.yml index 24e0684fc7..d7f1d994f5 100644 --- a/.github/workflows/vulnerabilities.yml +++ b/.github/workflows/vulnerabilities.yml @@ -10,7 +10,8 @@ on: jobs: list-vulnerable-packages: name: List vulnerable packages - runs-on: macos-latest + # Pin macos to get the version of XCode that we need: https://github.com/actions/runner-images/issues/10703 + runs-on: macos-15 steps: - name: Checkout diff --git a/integration-test/cli.Tests.ps1 b/integration-test/cli.Tests.ps1 index 54b4102a9b..bd9d26ff78 100644 --- a/integration-test/cli.Tests.ps1 +++ b/integration-test/cli.Tests.ps1 @@ -141,6 +141,15 @@ Describe 'MAUI' -ForEach @( } AddPackageReference $name 'Sentry.Maui' + + if (Test-Path env:CI) + { + dotnet build $name/$name.csproj -t:InstallAndroidDependencies -f:$framework-android -p:AcceptAndroidSDKLicenses=True -p:AndroidSdkPath="/usr/local/lib/android/sdk/" | ForEach-Object { Write-Host $_ } + if ($LASTEXITCODE -ne 0) + { + throw "Failed to install android dependencies." + } + } } It "uploads symbols and sources for an Android build" {