Skip to content
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

Build Android on Linux #1755

Merged
merged 6 commits into from
Jun 28, 2022
Merged
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
36 changes: 10 additions & 26 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ jobs:
matrix:
# Using macos-12 because we need Xcode 13.3 or later to build Sentry.Samples.Maui. (macos-latest currently points at macos-11 which uses Xcode 13.2)
os: [ubuntu-latest, windows-latest, macos-12]
include:
- os: ubuntu-latest
slnf: SentryLinux.slnf
- os: windows-latest
slnf: SentryWindows.slnf
- os: macos-12
slnf: SentryMac.slnf

steps:
- name: Checkout
Expand Down Expand Up @@ -61,38 +54,29 @@ jobs:
path: ~/.nuget/packages
# We don't use a lockfile, so hash all files where we might be keeping <PackageReference> tags
# Workloads also get installed in the nuget packages cache, so if you modify workloads below, increment the number in the cache keys
key: ${{ runner.os }}-nuget+workloads2-${{ hashFiles('**/*.*proj', '**/*.props') }}
restore-keys: ${{ runner.os }}-nuget+workloads2
key: ${{ runner.os }}-nuget+workloads3-${{ hashFiles('**/*.*proj', '**/*.props') }}
restore-keys: ${{ runner.os }}-nuget+workloads3

# .NET Android workloads don't support Linux https://github.com/dotnet/sdk/issues/22411
- name: Install .NET Workloads (Ubuntu)
if: startsWith(matrix.os, 'ubuntu')
run: 'dotnet workload install maui-android --temp-dir "${{ runner.temp }}"'
- name: Install .NET Workloads (Windows)
if: startsWith(matrix.os, 'windows')
run: dotnet workload install maui-android maui-windows
run: 'dotnet workload install maui-android maui-windows --temp-dir "${{ runner.temp }}"'
- name: Install .NET Workloads (macOS)
if: startsWith(matrix.os, 'macos')
run: dotnet workload install maui-android maui-ios maui-maccatalyst
run: 'dotnet workload install maui-android maui-ios maui-maccatalyst --temp-dir "${{ runner.temp }}"'

- name: Build
run: dotnet build ${{ matrix.slnf }} -c Release /p:CopyLocalLockFileAssemblies=true
run: dotnet build -c Release /p:CopyLocalLockFileAssemblies=true
mattjohnsonpint marked this conversation as resolved.
Show resolved Hide resolved

- name: Test
run: dotnet test ${{ matrix.slnf }} -c Release --no-build -l GitHubActions -l "trx;LogFileName=${{ matrix.os }}-test-results.trx"

# - name: Create Test Report
# uses: phoenix-actions/test-reporting@4b942144e31c4039ac808d9b29945864b628a574
# # run this step even if previous step failed
# if: success() || failure()
# with:
# name: Unit Test Results (${{ matrix.os }})
# path: '**/*.trx'
# reporter: dotnet-trx
# list-suites: 'failed'
# list-tests: 'failed'
run: dotnet test -c Release --no-build -l GitHubActions -l "trx;LogFileName=${{ matrix.os }}-test-results.trx"

- name: Pack
# Only pack in one build environment. We'll use macOS so we can build for ios/maccatalyst targets
if: startsWith(matrix.os, 'macos')
run: dotnet pack ${{ matrix.slnf }} -c Release --no-build
run: dotnet pack -c Release --no-build

- name: Upload Verify Results
if: failure()
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ jobs:
uses: actions/cache@v3
with:
path: ~/.nuget/packages
## we don't use a lockfile, so hash all files where we might be keeping <PackageReference> tags
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.*proj', '**/*.props') }}
restore-keys: ${{ runner.os }}-nuget
# We don't use a lockfile, so hash all files where we might be keeping <PackageReference> tags
# Workloads also get installed in the nuget packages cache, so if you modify workloads below, increment the number in the cache keys
key: ${{ runner.os }}-nuget+workloads3-${{ hashFiles('**/*.*proj', '**/*.props') }}
restore-keys: ${{ runner.os }}-nuget+workloads3

- name: Install .NET Workloads (Ubuntu)
run: 'dotnet workload install maui-android --temp-dir "${{ runner.temp }}"'

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand All @@ -42,10 +46,9 @@ jobs:
languages: ${{ matrix.language }}

- name: Build
# TODO: Won't run over code specific to Windows or macOS
# Prob best to use reusable workflows to have the setup shared with build.yml
# TODO: Prob best to use reusable workflows to have the setup shared with build.yml
# https://docs.github.com/en/actions/using-workflows/reusing-workflows#creating-a-reusable-workflow
run: dotnet build SentryLinux.slnf
run: dotnet build

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
48 changes: 0 additions & 48 deletions SentryLinux.slnf

This file was deleted.

52 changes: 0 additions & 52 deletions SentryMac.slnf

This file was deleted.

52 changes: 0 additions & 52 deletions SentryWindows.slnf

This file was deleted.

4 changes: 2 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ $ErrorActionPreference = "Stop"

$testLogger = if ($env:GITHUB_ACTIONS -eq "true") {"GitHubActions;report-warnings=false"} else {"console"}

dotnet test SentryWindows.slnf -c Release -l $testLogger `
dotnet test -c Release -l $testLogger `
/p:CopyLocalLockFileAssemblies=true
if ($LASTEXITCODE -ne 0) { exit 1 }

dotnet pack SentryWindows.slnf -c Release --no-build
dotnet pack -c Release --no-build
if ($LASTEXITCODE -ne 0) { exit 1 }
8 changes: 1 addition & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,5 @@ if [ "$GITHUB_ACTIONS" == "true" ]
testLogger="console"
fi

case "$OSTYPE" in
darwin*) export Filter=SentryMac.slnf ;;
linux*) export Filter=SentryLinux.slnf ;;
*) echo Unsupported $OSTYPE && exit -1 ;;
esac

dotnet test $Filter -c Release -l $testLogger \
dotnet test -c Release -l $testLogger \
/p:CopyLocalLockFileAssemblies=true
10 changes: 6 additions & 4 deletions samples/Sentry.Samples.Maui/Sentry.Samples.Maui.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

<PropertyGroup>
<!--
On Mac, we'll build for Android, iOS, and MacCatalyst.
On Windows, we'll build for Android and Windows 10
We can build for Android from all build platforms.
On Mac, we'll also build for iOS and MacCatalyst.
On Windows, we'll also build for Windows 10.
-->
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">net6.0-android;net6.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks>net6.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">$(TargetFrameworks);net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>Sentry.Samples.Maui</RootNamespace>
<UseMaui>true</UseMaui>
Expand Down
4 changes: 1 addition & 3 deletions src/Sentry/Sentry.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.0;netstandard2.1;netstandard2.0;net461</TargetFrameworks>
<!-- .NET Android Workload doesn't support Linux -->
<TargetFrameworks Condition="!$([MSBuild]::IsOSPlatform('Linux'))">$(TargetFrameworks);net6.0-android</TargetFrameworks>
<TargetFrameworks>net6.0;net5.0;netcoreapp3.0;netstandard2.1;netstandard2.0;net461;net6.0-android</TargetFrameworks>
<!-- We'll pin to C# 9 and ImplicitUsings false to allow us to compile within Unity -->
<LangVersion>9</LangVersion>
<ImplicitUsings>false</ImplicitUsings>
Expand Down