Skip to content

Commit

Permalink
Tests: Added partial Rosetta 2 support (#580)
Browse files Browse the repository at this point in the history
adds partial Rosetta 2 support
  • Loading branch information
Aragas authored Feb 19, 2024
1 parent 125a6d7 commit 2a09e7a
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 3 deletions.
7 changes: 6 additions & 1 deletion .github/actions/test-execute-test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,13 @@ runs:
max_attempts: 3
retry_on: timeout
command: |
if ('${{inputs.os == 'macos-arm64' && inputs.architecture == 'x64' && inputs.runtime-type == 'dotnet'}}' -eq 'true') {
$dotnet = '/Users/runner/.dotnet/x64/dotnet';
} else {
$dotnet = '/Users/runner/.dotnet/dotnet';
}
foreach ($target_framework in ConvertFrom-Json "${{steps.test-args.outputs.target_frameworks}}") {
dotnet test "HarmonyTests/bin/Release/$target_framework/HarmonyTests.dll" -f $target_framework ${{steps.test-args.outputs.dotnet}} -- ${{steps.test-args.outputs.run_settings_args}};
& $dotnet test "HarmonyTests/bin/Release/$target_framework/HarmonyTests.dll" -f $target_framework ${{steps.test-args.outputs.dotnet}} -- ${{steps.test-args.outputs.run_settings_args}};
}
shell: pwsh

Expand Down
41 changes: 41 additions & 0 deletions .github/actions/test-setup-dotnet-macos-rosetta/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Setup .NET
description: Setup .NET using the provided target framework and architecture

inputs:
architecture:
description: 'The .NET architecture to setup'
required: true
target_framework:
description: 'The .NET target framework to setup'
required: true
target_framework_array:
description: 'The .NET target frameworks to setup'
required: true

runs:
using: "composite"
steps:
- name: Get .NET Channels
uses: ./.github/actions/get-dotnet-channel
id: get_channels
with:
target_framework: ${{inputs.target_framework}}
target_framework_array: ${{inputs.target_framework_array}}

- name: Setup .NET x64 ${{steps.get_channels.outputs.channels_multiline}}
uses: dlemstra/setup-dotnet@add-architecture-option
with:
dotnet-architecture: x64
dotnet-version: |
${{steps.get_channels.outputs.channel}}
${{steps.get_channels.outputs.channels_multiline}}
env:
DOTNET_INSTALL_DIR: /Users/runner/.dotnet/x64

- name: Setup .NET arm64 ${{steps.get_channels.outputs.channels_multiline}}
uses: dlemstra/setup-dotnet@add-architecture-option
with:
dotnet-architecture: arm64
dotnet-version: |
${{steps.get_channels.outputs.channel}}
${{steps.get_channels.outputs.channels_multiline}}
18 changes: 18 additions & 0 deletions .github/workflows/test-unix-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,31 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Rosetta 2 on macOS
if: ${{inputs.image == 'macos-14' && inputs.architecture == 'x64'}}
run: /usr/sbin/softwareupdate --install-rosetta --agree-to-license
shell: pwsh

- name: Setup .NET MacOS Rosetta
uses: ./.github/actions/test-setup-dotnet-macos-rosetta
if: ${{inputs.os == 'macos-arm64' && inputs.architecture == 'x64'}}
with:
architecture: ${{inputs.architecture}}
target_framework: ${{inputs.target_framework}}
target_framework_array: ${{inputs.target_framework_array}}

- name: Setup .NET ${{inputs.architecture}}
uses: ./.github/actions/test-setup-dotnet
if: ${{!(inputs.os == 'macos-arm64' && inputs.architecture == 'x64')}}
with:
architecture: ${{inputs.architecture}}
target_framework: ${{inputs.target_framework}}
target_framework_array: ${{inputs.target_framework_array}}

- name: Get Installed .NET Sdk Information
run: dotnet --info
shell: pwsh

- name: Download Build Cache
uses: ./.github/actions/test-build-cache
if: ${{!inputs.manual_build}}
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/test-unix-mono.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,16 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install Rosetta 2 on macOS
if: ${{inputs.image == 'macos-14' && inputs.architecture == 'x64'}}
run: /usr/sbin/softwareupdate --install-rosetta --agree-to-license

- name: Setup .NET Sdk
uses: actions/setup-dotnet@v4

- name: Get Installed .NET Sdk Information
run: dotnet --info

- name: Download Build Cache
uses: ./.github/actions/test-build-cache
if: ${{!inputs.manual_build}}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-windows-dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ jobs:
target_framework: ${{inputs.target_framework}}
target_framework_array: ${{inputs.target_framework_array}}

- name: Get Installed .NET Sdk Information
run: dotnet --info

- name: Download Build Cache
uses: ./.github/actions/test-build-cache
if: ${{!inputs.manual_build}}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-windows-framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ jobs:
- name: Setup .NET Sdk
uses: actions/setup-dotnet@v4

- name: Get Installed .NET Sdk Information
run: dotnet --info

- name: Download Build Cache
uses: ./.github/actions/test-build-cache
if: ${{!inputs.manual_build}}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test-windows-mono.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ jobs:
- name: Setup .NET Sdk
uses: actions/setup-dotnet@v4

- name: Get Installed .NET Sdk Information
run: dotnet --info

- name: Download Build Cache
uses: ./.github/actions/test-build-cache
if: ${{!inputs.manual_build}}
Expand Down
45 changes: 43 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,47 @@ jobs:
build_configuration: ${{matrix.build_configuration}}
manual_build: ${{needs.variables.outputs.PREBUILD != 'true'}}

macos-rosetta-dotnet:
name: MacOS .NET Rosetta 2
needs: [variables, build-binaries]
if: ${{needs.variables.outputs.EXPERIMENTAL == 'true'}}
strategy:
fail-fast: false
matrix:
image: [ { os: 'macos-arm64', code: 'macos-14' } ]
architecture: ['x64']
target_framework: ${{fromJson((needs.variables.outputs.PARALLEL == 'true' && needs.variables.outputs.DOTNET_TARGET_FRAMEWORKS_MACOS_ARM64) || '[""]')}}
build_configuration: ${{fromJson(needs.variables.outputs.BUILD_CONFIGURATIONS)}}
uses: ./.github/workflows/test-unix-dotnet.yml
with:
os: ${{matrix.image.os}}
image: ${{matrix.image.code}}
architecture: ${{matrix.architecture}}
target_framework: ${{matrix.target_framework }}
target_framework_array: ${{needs.variables.outputs.DOTNET_TARGET_FRAMEWORKS_MACOS_ARM64}}
build_configuration: ${{matrix.build_configuration}}
manual_build: ${{needs.variables.outputs.PREBUILD != 'true'}}

macos-rosetta-mono:
name: MacOS Mono Rosetta 2
needs: [variables, build-binaries]
strategy:
fail-fast: false
matrix:
image: [ { os: 'macos-arm64', code: 'macos-14' } ]
architecture: ['x64']
target_framework: ${{fromJson((needs.variables.outputs.PARALLEL == 'true' && needs.variables.outputs.FRAMEWORK_TARGET_FRAMEWORKS) || '[""]')}}
build_configuration: ${{fromJson(needs.variables.outputs.BUILD_CONFIGURATIONS)}}
uses: ./.github/workflows/test-unix-mono.yml
with:
os: ${{matrix.image.os}}
image: ${{matrix.image.code}}
architecture: ${{matrix.architecture}}
target_framework: ${{matrix.target_framework}}
target_framework_array: ${{needs.variables.outputs.FRAMEWORK_TARGET_FRAMEWORKS}}
build_configuration: ${{matrix.build_configuration}}
manual_build: ${{needs.variables.outputs.PREBUILD != 'true'}}

ubuntu-arm64-dotnet:
name: Ubuntu .NET arm64
needs: [variables, build-binaries]
Expand Down Expand Up @@ -232,13 +273,13 @@ jobs:

test-results:
name: Download and Upload Test Results
needs: [windows-dotnet, windows-framework, windows-mono, ubuntu-macos-x64-dotnet, ubuntu-macos-x64-mono, ubuntu-arm64-dotnet, ubuntu-arm64-mono, macos-arm64-dotnet]
needs: [windows-dotnet, windows-framework, windows-mono, ubuntu-macos-x64-dotnet, ubuntu-macos-x64-mono, macos-rosetta-dotnet, macos-rosetta-mono]
if: always()
uses: ./.github/workflows/test-result-upload.yml

test-results-experimental:
name: Download and Upload Test Results (Experimental)
needs: [windows-dotnet, windows-framework, windows-mono, ubuntu-macos-x64-dotnet, ubuntu-macos-x64-mono, ubuntu-arm64-dotnet, ubuntu-arm64-mono, macos-arm64-dotnet]
needs: [ubuntu-arm64-dotnet, ubuntu-arm64-mono, macos-arm64-dotnet]
if: ${{needs.variables.outputs.EXPERIMENTAL == 'true' && always()}}
uses: ./.github/workflows/test-result-upload.yml
with:
Expand Down
6 changes: 6 additions & 0 deletions Harmony.sln
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{71B8832A-3
.github\workflows\test-windows-mono.yml = .github\workflows\test-windows-mono.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test-setup-dotnet-macos-rosetta", "test-setup-dotnet-macos-rosetta", "{821995BE-A095-4C39-95F5-8E54A5E6944D}"
ProjectSection(SolutionItems) = preProject
.github\actions\test-setup-dotnet-macos-rosetta\action.yml = .github\actions\test-setup-dotnet-macos-rosetta\action.yml
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
DebugFat|Any CPU = DebugFat|Any CPU
Expand Down Expand Up @@ -150,5 +155,6 @@ Global
{145A597F-00D3-42D0-930D-85EF1257FA6D} = {9A886F28-B059-46CC-BE43-EA234CE1DD78}
{E625C76C-C4AA-43A9-AFB5-BD1D605A4F48} = {9A886F28-B059-46CC-BE43-EA234CE1DD78}
{15C84537-CCEF-43F5-B556-34369D7B320D} = {9A886F28-B059-46CC-BE43-EA234CE1DD78}
{821995BE-A095-4C39-95F5-8E54A5E6944D} = {9A886F28-B059-46CC-BE43-EA234CE1DD78}
EndGlobalSection
EndGlobal

0 comments on commit 2a09e7a

Please sign in to comment.