Skip to content

Commit

Permalink
Support macOS ARM + macOS Intel and update proto generation (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
cretz authored Apr 26, 2024
1 parent 9c1c127 commit f1b8dde
Show file tree
Hide file tree
Showing 54 changed files with 385 additions and 201 deletions.
28 changes: 14 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-12, windows-latest, ubuntu-arm]
os: [ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest]
include:
- os: windows-latest
checkTarget: true
Expand All @@ -20,6 +20,10 @@ jobs:
cloudTestTarget: true
- os: ubuntu-arm
runsOn: buildjet-4vcpu-ubuntu-2204-arm
- os: macos-intel
runsOn: macos-12
- os: macos-arm
runsOn: macos-14
runs-on: ${{ matrix.runsOn || matrix.os }}
steps:
- name: Checkout repository
Expand All @@ -38,23 +42,19 @@ jobs:
workspaces: src/Temporalio/Bridge

- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
# Specific .NET version required because GitHub macos ARM image has
# bad pre-installed .NET version
dotnet-version: 6.x

- name: Install protoc (x64)
# Does not work on arm
if: ${{ matrix.os != 'ubuntu-arm' }}
uses: arduino/setup-protoc@v1
- name: Install protoc
uses: arduino/setup-protoc@v3
with:
# TODO(cretz): Upgrade when https://github.com/arduino/setup-protoc/issues/33 fixed
version: '3.x'
# TODO(cretz): Can upgrade proto when https://github.com/arduino/setup-protoc/issues/99 fixed
version: "23.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install protoc (Linux ARM)
if: ${{ matrix.os == 'ubuntu-arm' }}
run: |
sudo apt update -y
sudo apt install -y protobuf-compiler
- name: Build
# We intentionally just build debug mode in this CI. We build before
# regen to confirm no interop header changes.
Expand Down
45 changes: 17 additions & 28 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, ubuntu-arm, macos-latest, macos-arm, windows-latest]
os: [ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest]
include:
- os: ubuntu-latest
out-file: libtemporal_sdk_bridge.so
Expand All @@ -25,14 +25,14 @@ jobs:
# We use the Python manylinux image for glibc compatibility
container: quay.io/pypa/manylinux2014_aarch64
protobuf-url: https://github.com/protocolbuffers/protobuf/releases/download/v22.3/protoc-22.3-linux-aarch_64.zip
- os: macos-latest
- os: macos-intel
out-file: libtemporal_sdk_bridge.dylib
out-prefix: osx-x64
runsOn: macos-12
- os: macos-arm
out-file: libtemporal_sdk_bridge.dylib
out-prefix: osx-arm64
alternative-target: aarch64-apple-darwin
runsOn: macos-latest
runsOn: macos-14
- os: windows-latest
out-file: temporal_sdk_bridge.dll
out-prefix: win-x64
Expand All @@ -56,17 +56,11 @@ jobs:
workspaces: src/Temporalio/Bridge
key: ${{ matrix.os }}

- name: Add alternative Rust target
if: ${{ matrix.alternative-target }}
run: rustup target add ${{ matrix.alternative-target }}

- name: Install protoc (non-Linux)
# Does not work on Linux
if: ${{ matrix.os != 'ubuntu-latest' && matrix.os != 'ubuntu-arm' }}
uses: arduino/setup-protoc@v1
uses: arduino/setup-protoc@v3
with:
# TODO(cretz): Upgrade when https://github.com/arduino/setup-protoc/issues/33 fixed
version: '3.x'
version: "23.x"
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install protoc (Linux)
Expand All @@ -78,27 +72,14 @@ jobs:
echo $(realpath .)/protobuf-compiler/bin >> $GITHUB_PATH
- name: Build
if: ${{ !matrix.alternative-target }}
run: cargo build --manifest-path src/Temporalio/Bridge/Cargo.toml --release

- name: Build alternative target
if: ${{ matrix.alternative-target != '' }}
run: cargo build --manifest-path src/Temporalio/Bridge/Cargo.toml --release --target ${{ matrix.alternative-target }}

- name: Upload bridge library
if: ${{ !matrix.alternative-target }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.out-prefix }}-bridge
path: src/Temporalio/Bridge/target/release/${{ matrix.out-file }}

- name: Upload bridge library alternative target
if: ${{ matrix.alternative-target != '' }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.out-prefix }}-bridge
path: src/Temporalio/Bridge/target/${{ matrix.alternative-target }}/release/${{ matrix.out-file }}

build-nuget-package:
needs:
- build-bridge-libraries
Expand All @@ -115,7 +96,7 @@ jobs:
path: bridge-libraries

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

- name: Build package
run: dotnet pack -c Release /p:BridgeLibraryRoot=${{ github.workspace }}/bridge-libraries
Expand All @@ -140,10 +121,14 @@ jobs:
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, ubuntu-arm, macos-latest, windows-latest]
os: [ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest]
include:
- os: ubuntu-arm
runsOn: buildjet-4vcpu-ubuntu-2204-arm
- os: macos-intel
runsOn: macos-12
- os: macos-arm
runsOn: macos-14
runs-on: ${{ matrix.runsOn || matrix.os }}
steps:
- name: Checkout repository
Expand All @@ -158,7 +143,11 @@ jobs:
path: nuget-package

- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
# Specific .NET version required because GitHub macos ARM image has
# bad pre-installed .NET version
dotnet-version: 6.x

- name: Run smoke test
run: |
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1207,10 +1207,9 @@ DLL.

### Regenerating protos

Must have `protoc` on the `PATH`. Note, for now you must use `protoc` 3.x until
[our GH action downloader](https://github.com/arduino/setup-protoc/issues/33) is fixed or we change how we download
protoc and check protos (since protobuf
[changed some C# source](https://github.com/protocolbuffers/protobuf/pull/9981)).
Must have `protoc` on the `PATH`. Note, for now users should use `protoc` 23.x until
[our GH action downloader](https://github.com/arduino/setup-protoc/issues/99) can support later versions.
[Here](https://github.com/protocolbuffers/protobuf/releases/tag/v23.4) is the latest 23.x release as of this writing.
Then:

Expand Down
2 changes: 1 addition & 1 deletion src/Temporalio/Api/Batch/V1/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: temporal/api/batch/v1/message.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code

using pb = global::Google.Protobuf;
Expand Down
4 changes: 2 additions & 2 deletions src/Temporalio/Api/Command/V1/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: temporal/api/command/v1/message.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code

using pb = global::Google.Protobuf;
Expand Down Expand Up @@ -3590,7 +3590,7 @@ public void MergeFrom(RecordMarkerCommandAttributes other) {
if (other.MarkerName.Length != 0) {
MarkerName = other.MarkerName;
}
details_.Add(other.details_);
details_.MergeFrom(other.details_);
if (other.header_ != null) {
if (header_ == null) {
Header = new global::Temporalio.Api.Common.V1.Header();
Expand Down
2 changes: 1 addition & 1 deletion src/Temporalio/Api/Common/V1/GrpcStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: grpc_status.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code

using pb = global::Google.Protobuf;
Expand Down
58 changes: 43 additions & 15 deletions src/Temporalio/Api/Common/V1/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: temporal/api/common/v1/message.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code

using pb = global::Google.Protobuf;
Expand Down Expand Up @@ -661,7 +661,7 @@ public void MergeFrom(Payload other) {
if (other == null) {
return;
}
metadata_.Add(other.metadata_);
metadata_.MergeFrom(other.metadata_);
if (other.Data.Length != 0) {
Data = other.Data;
}
Expand Down Expand Up @@ -854,7 +854,7 @@ public void MergeFrom(SearchAttributes other) {
if (other == null) {
return;
}
indexedFields_.Add(other.indexedFields_);
indexedFields_.MergeFrom(other.indexedFields_);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

Expand Down Expand Up @@ -1035,7 +1035,7 @@ public void MergeFrom(Memo other) {
if (other == null) {
return;
}
fields_.Add(other.fields_);
fields_.MergeFrom(other.fields_);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

Expand Down Expand Up @@ -1217,7 +1217,7 @@ public void MergeFrom(Header other) {
if (other == null) {
return;
}
fields_.Add(other.fields_);
fields_.MergeFrom(other.fields_);
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

Expand Down Expand Up @@ -3067,12 +3067,26 @@ public ResetOptions Clone() {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public long WorkflowTaskId {
get { return targetCase_ == TargetOneofCase.WorkflowTaskId ? (long) target_ : 0L; }
get { return HasWorkflowTaskId ? (long) target_ : 0L; }
set {
target_ = value;
targetCase_ = TargetOneofCase.WorkflowTaskId;
}
}
/// <summary>Gets whether the "workflow_task_id" field is set</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public bool HasWorkflowTaskId {
get { return targetCase_ == TargetOneofCase.WorkflowTaskId; }
}
/// <summary> Clears the value of the oneof if it's currently set to "workflow_task_id" </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void ClearWorkflowTaskId() {
if (HasWorkflowTaskId) {
ClearTarget();
}
}

/// <summary>Field number for the "build_id" field.</summary>
public const int BuildIdFieldNumber = 4;
Expand All @@ -3086,12 +3100,26 @@ public long WorkflowTaskId {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public string BuildId {
get { return targetCase_ == TargetOneofCase.BuildId ? (string) target_ : ""; }
get { return HasBuildId ? (string) target_ : ""; }
set {
target_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
targetCase_ = TargetOneofCase.BuildId;
}
}
/// <summary>Gets whether the "build_id" field is set</summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public bool HasBuildId {
get { return targetCase_ == TargetOneofCase.BuildId; }
}
/// <summary> Clears the value of the oneof if it's currently set to "build_id" </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void ClearBuildId() {
if (HasBuildId) {
ClearTarget();
}
}

/// <summary>Field number for the "reset_reapply_type" field.</summary>
public const int ResetReapplyTypeFieldNumber = 10;
Expand Down Expand Up @@ -3178,8 +3206,8 @@ public override int GetHashCode() {
int hash = 1;
if (targetCase_ == TargetOneofCase.FirstWorkflowTask) hash ^= FirstWorkflowTask.GetHashCode();
if (targetCase_ == TargetOneofCase.LastWorkflowTask) hash ^= LastWorkflowTask.GetHashCode();
if (targetCase_ == TargetOneofCase.WorkflowTaskId) hash ^= WorkflowTaskId.GetHashCode();
if (targetCase_ == TargetOneofCase.BuildId) hash ^= BuildId.GetHashCode();
if (HasWorkflowTaskId) hash ^= WorkflowTaskId.GetHashCode();
if (HasBuildId) hash ^= BuildId.GetHashCode();
if (ResetReapplyType != global::Temporalio.Api.Enums.V1.ResetReapplyType.Unspecified) hash ^= ResetReapplyType.GetHashCode();
if (CurrentRunOnly != false) hash ^= CurrentRunOnly.GetHashCode();
hash ^= (int) targetCase_;
Expand Down Expand Up @@ -3209,11 +3237,11 @@ public void WriteTo(pb::CodedOutputStream output) {
output.WriteRawTag(18);
output.WriteMessage(LastWorkflowTask);
}
if (targetCase_ == TargetOneofCase.WorkflowTaskId) {
if (HasWorkflowTaskId) {
output.WriteRawTag(24);
output.WriteInt64(WorkflowTaskId);
}
if (targetCase_ == TargetOneofCase.BuildId) {
if (HasBuildId) {
output.WriteRawTag(34);
output.WriteString(BuildId);
}
Expand Down Expand Up @@ -3243,11 +3271,11 @@ public void WriteTo(pb::CodedOutputStream output) {
output.WriteRawTag(18);
output.WriteMessage(LastWorkflowTask);
}
if (targetCase_ == TargetOneofCase.WorkflowTaskId) {
if (HasWorkflowTaskId) {
output.WriteRawTag(24);
output.WriteInt64(WorkflowTaskId);
}
if (targetCase_ == TargetOneofCase.BuildId) {
if (HasBuildId) {
output.WriteRawTag(34);
output.WriteString(BuildId);
}
Expand Down Expand Up @@ -3275,10 +3303,10 @@ public int CalculateSize() {
if (targetCase_ == TargetOneofCase.LastWorkflowTask) {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(LastWorkflowTask);
}
if (targetCase_ == TargetOneofCase.WorkflowTaskId) {
if (HasWorkflowTaskId) {
size += 1 + pb::CodedOutputStream.ComputeInt64Size(WorkflowTaskId);
}
if (targetCase_ == TargetOneofCase.BuildId) {
if (HasBuildId) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(BuildId);
}
if (ResetReapplyType != global::Temporalio.Api.Enums.V1.ResetReapplyType.Unspecified) {
Expand Down
2 changes: 1 addition & 1 deletion src/Temporalio/Api/Dependencies/Google/Annotations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/api/annotations.proto
// </auto-generated>
#pragma warning disable 1591, 0612, 3021
#pragma warning disable 1591, 0612, 3021, 8981
#region Designer generated code

using pb = global::Google.Protobuf;
Expand Down
Loading

0 comments on commit f1b8dde

Please sign in to comment.