Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Experimental support for osx-arm64 (Apple M1) #2

Closed
wants to merge 10 commits into from
Closed
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
40 changes: 40 additions & 0 deletions .github/workflows/build-osx-arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: osx-arm64 Release Build

on:
workflow_dispatch:
push:
branches:
- macos-arm64
- macos-arm64-test

jobs:
build:
runs-on: [self-hosted, macOS, ARM64]
steps:
- uses: actions/checkout@v1

# Build runner layout
- name: Build & Layout Release
run: |
./dev.sh layout Release osx-arm64
working-directory: src

# Run tests
- name: L0
run: |
./dev.sh test
working-directory: src

# Create runner package tar.gz/zip
- name: Package Release
run: |
./dev.sh package Release osx-arm64
working-directory: src

# Upload runner package tar.gz/zip as artifact.
# Since each package name is unique, so we don't need to put ${{matrix}} info into artifact name
- name: Publish Artifact
uses: actions/upload-artifact@v1
with:
name: runner-packages
path: _package
5 changes: 4 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
<DefineConstants>$(DefineConstants);X86</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(BUILD_OS)' == 'OSX'">
<PropertyGroup Condition="'$(BUILD_OS)' == 'OSX' AND '$(PackageRuntime)' == 'osx-x64'">
<DefineConstants>$(DefineConstants);X64</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(BUILD_OS)' == 'OSX' AND '$(PackageRuntime)' == 'osx-arm64'">
<DefineConstants>$(DefineConstants);ARM64</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(BUILD_OS)' == 'Linux' AND ('$(PackageRuntime)' == 'linux-x64' OR '$(PackageRuntime)' == '')">
<DefineConstants>$(DefineConstants);X64</DefineConstants>
Expand Down
1 change: 1 addition & 0 deletions src/Misc/contentHash/dotnetRuntime/osx-arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a1860fe3695b8aa71ad9ff748cfb011c51edb42f15b490aa8a617112b25a7ae8
1 change: 1 addition & 0 deletions src/Misc/contentHash/externals/osx-arm64
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3e7f1001760d4c84e7d77aaba3f2d2427920194b03099cc12e55c337a8b003f2
10 changes: 9 additions & 1 deletion src/Misc/externals.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,20 @@ if [[ "$PACKAGERUNTIME" == "win-x64" || "$PACKAGERUNTIME" == "win-x86" ]]; then
fi
fi

# Download the external tools only for OSX.
# Download the external tools only for OSX X64.
if [[ "$PACKAGERUNTIME" == "osx-x64" ]]; then
acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/node-v${NODE12_VERSION}-darwin-x64.tar.gz" node12 fix_nested_dir
acquireExternalTool "$NODE_URL/v${NODE16_VERSION}/node-v${NODE16_VERSION}-darwin-x64.tar.gz" node16 fix_nested_dir
fi

# Download the external tools only for OSX ARM64.
if [[ "$PACKAGERUNTIME" == "osx-arm64" ]]; then
# Node 12 is not available, fallback to Node 16 instead
NODE12_VERSION="${NODE16_VERSION}"
acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/node-v${NODE12_VERSION}-darwin-arm64.tar.gz" node12 fix_nested_dir
acquireExternalTool "$NODE_URL/v${NODE16_VERSION}/node-v${NODE16_VERSION}-darwin-arm64.tar.gz" node16 fix_nested_dir
fi

# Download the external tools for Linux PACKAGERUNTIMEs.
if [[ "$PACKAGERUNTIME" == "linux-x64" ]]; then
acquireExternalTool "$NODE_URL/v${NODE12_VERSION}/node-v${NODE12_VERSION}-linux-x64.tar.gz" node12 fix_nested_dir
Expand Down
2 changes: 1 addition & 1 deletion src/Runner.Common/Runner.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603</NoWarn>
<Version>$(Version)</Version>
Expand Down
2 changes: 1 addition & 1 deletion src/Runner.Listener/Runner.Listener.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603</NoWarn>
<Version>$(Version)</Version>
Expand Down
2 changes: 2 additions & 0 deletions src/Runner.Listener/Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ private async Task<int> RunAsync(RunnerSettings settings, bool runOnce = false)
HostContext.WritePerfCounter($"MessageReceived_{message.MessageType}");
if (string.Equals(message.MessageType, AgentRefreshMessage.MessageType, StringComparison.OrdinalIgnoreCase))
{
#if !(OS_OSX && ARM64)
if (autoUpdateInProgress == false)
{
autoUpdateInProgress = true;
Expand Down Expand Up @@ -437,6 +438,7 @@ private async Task<int> RunAsync(RunnerSettings settings, bool runOnce = false)
{
Trace.Info("Refresh message received, skip autoupdate since a previous autoupdate is already running.");
}
#endif
}
else if (string.Equals(message.MessageType, JobRequestMessageTypes.PipelineAgentJobRequest, StringComparison.OrdinalIgnoreCase))
{
Expand Down
2 changes: 1 addition & 1 deletion src/Runner.PluginHost/Runner.PluginHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603</NoWarn>
<Version>$(Version)</Version>
Expand Down
2 changes: 1 addition & 1 deletion src/Runner.Plugins/Runner.Plugins.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603</NoWarn>
<Version>$(Version)</Version>
Expand Down
2 changes: 1 addition & 1 deletion src/Runner.Sdk/Runner.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603</NoWarn>
<Version>$(Version)</Version>
Expand Down
2 changes: 1 addition & 1 deletion src/Runner.Worker/Runner.Worker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603</NoWarn>
<Version>$(Version)</Version>
Expand Down
2 changes: 1 addition & 1 deletion src/Sdk/Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603</NoWarn>
<Version>$(Version)</Version>
Expand Down
3 changes: 2 additions & 1 deletion src/Test/L0/ConstantGenerationL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public void BuildConstantGenerateSucceed()
"linux-x64",
"linux-arm",
"linux-arm64",
"osx-x64"
"osx-x64",
"osx-arm64"
};

Assert.True(BuildConstants.Source.CommitHash.Length == 40, $"CommitHash should be SHA-1 hash {BuildConstants.Source.CommitHash}");
Expand Down
2 changes: 2 additions & 0 deletions src/Test/L0/Listener/RunnerL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ public async void TestRunOnceOnlyTakeOneJobMessage()
}
}

#if !(OS_OSX && ARM64)
[Fact]
[Trait("Level", "L0")]
[Trait("Category", "Runner")]
Expand Down Expand Up @@ -503,5 +504,6 @@ public async void TestRunOnceHandleUpdateMessage()
_messageListener.Verify(x => x.DeleteMessageAsync(It.IsAny<TaskAgentMessage>()), Times.Once());
}
}
#endif
}
}
4 changes: 4 additions & 0 deletions src/Test/L0/Listener/SelfUpdaterL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
using Moq;
using Xunit;

#if !(OS_OSX && ARM64)

namespace GitHub.Runner.Common.Tests.Listener
{
public sealed class SelfUpdaterL0
Expand Down Expand Up @@ -791,3 +793,5 @@ public async void TestSelfUpdateAsync_FallbackToFullPackage()
}
}
}

#endif
4 changes: 2 additions & 2 deletions src/Test/L0/PackagesTrimL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public async Task RunnerLayoutParts_CheckDotnetRuntimeHash()
killProcessOnCancel: true,
cancellationToken: CancellationToken.None);

Assert.True(string.Equals(hashResult, File.ReadAllText(dotnetRuntimeHashFile).Trim()), $"Hash mismatch for dotnet runtime. You might need to update `Misc/contentHash/dotnetRuntime/{BuildConstants.RunnerPackage.PackageName}` or check if `hashFiles.ts` ever changed recently.");
Assert.True(string.Equals(hashResult, File.ReadAllText(dotnetRuntimeHashFile).Trim()), $"Hash mismatch for dotnet runtime. You might need to update `Misc/contentHash/dotnetRuntime/{BuildConstants.RunnerPackage.PackageName}` to '{hashResult}' or check if `hashFiles.ts` ever changed recently.");
}
}

Expand Down Expand Up @@ -270,7 +270,7 @@ public async Task RunnerLayoutParts_CheckExternalsHash()
killProcessOnCancel: true,
cancellationToken: CancellationToken.None);

Assert.True(string.Equals(hashResult, File.ReadAllText(externalsHashFile).Trim()), $"Hash mismatch for externals. You might need to update `Misc/contentHash/externals/{BuildConstants.RunnerPackage.PackageName}` or check if `hashFiles.ts` ever changed recently.");
Assert.True(string.Equals(hashResult, File.ReadAllText(externalsHashFile).Trim()), $"Hash mismatch for externals. You might need to update `Misc/contentHash/externals/{BuildConstants.RunnerPackage.PackageName}` to '{hashResult}' or check if `hashFiles.ts` ever changed recently.");
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/Test/L0/Worker/StepHostL0.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public async Task DetermineNodeRuntimeVersionInContainerAsync()
[Trait("Category", "Worker")]
public async Task DetermineNodeRuntimeVersionInAlpineContainerAsync()
{
if (!Constants.Runner.PlatformArchitecture.Equals(Constants.Architecture.X64)) {
// Test only works on X64.
return;
}

using (TestHostContext hc = CreateTestContext())
{
// Arrange.
Expand Down
2 changes: 1 addition & 1 deletion src/Test/Test.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win-x64;win-x86;linux-x64;linux-arm64;linux-arm;osx-x64;osx-arm64</RuntimeIdentifiers>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<NoWarn>NU1701;NU1603;NU1603;xUnit2013;</NoWarn>
</PropertyGroup>
Expand Down
10 changes: 8 additions & 2 deletions src/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ elif [[ "$CURRENT_PLATFORM" == 'linux' ]]; then
fi
elif [[ "$CURRENT_PLATFORM" == 'darwin' ]]; then
RUNTIME_ID='osx-x64'
if command -v uname > /dev/null; then
CPU_NAME=$(uname -m)
if [[ "$CPU_NAME" == "arm64" ]]; then
RUNTIME_ID="osx-arm64"
fi
fi
fi

if [[ -n "$DEV_TARGET_RUNTIME" ]]; then
Expand All @@ -63,7 +69,7 @@ fi
# Make sure current platform support publish the dotnet runtime
# Windows can publish win-x86/x64
# Linux can publish linux-x64/arm/arm64
# OSX can publish osx-x64
# OSX can publish osx-x64/arm64
if [[ "$CURRENT_PLATFORM" == 'windows' ]]; then
if [[ ("$RUNTIME_ID" != 'win-x86') && ("$RUNTIME_ID" != 'win-x64') ]]; then
echo "Failed: Can't build $RUNTIME_ID package $CURRENT_PLATFORM" >&2
Expand All @@ -75,7 +81,7 @@ elif [[ "$CURRENT_PLATFORM" == 'linux' ]]; then
exit 1
fi
elif [[ "$CURRENT_PLATFORM" == 'darwin' ]]; then
if [[ ("$RUNTIME_ID" != 'osx-x64') ]]; then
if [[ ("$RUNTIME_ID" != 'osx-x64') && ("$RUNTIME_ID" != 'osx-arm64') ]]; then
echo "Failed: Can't build $RUNTIME_ID package $CURRENT_PLATFORM" >&2
exit 1
fi
Expand Down