Skip to content

Commit 5a63cdd

Browse files
committed
Provide MUSL-based build
Fixes #408
1 parent bac42d3 commit 5a63cdd

File tree

5 files changed

+65
-11
lines changed

5 files changed

+65
-11
lines changed

.github/workflows/package.yml

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
name: Build Package
22
on:
3+
pull_request:
34
push:
45
branches:
56
- main
@@ -10,7 +11,7 @@ jobs:
1011
strategy:
1112
fail-fast: false
1213
matrix:
13-
os: [ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest]
14+
os: [ubuntu-latest, ubuntu-arm, alpine-latest, macos-intel, macos-arm, windows-latest]
1415
include:
1516
- os: ubuntu-latest
1617
out-file: libtemporal_sdk_bridge.so
@@ -25,6 +26,13 @@ jobs:
2526
# We use the Python manylinux image for glibc compatibility
2627
container: quay.io/pypa/manylinux2014_aarch64
2728
protobuf-url: https://github.com/protocolbuffers/protobuf/releases/download/v22.3/protoc-22.3-linux-aarch_64.zip
29+
- os: alpine-latest
30+
out-file: libtemporal_sdk_bridge.so
31+
out-prefix: linux-musl-x64
32+
# Need Alpine container since GH runner doesn't have one
33+
container: mcr.microsoft.com/dotnet/sdk:8.0-alpine
34+
protobuf-url: https://github.com/protocolbuffers/protobuf/releases/download/v22.3/protoc-22.3-linux-x86_64.zip
35+
runsOn: ubuntu-latest
2836
- os: macos-intel
2937
out-file: libtemporal_sdk_bridge.dylib
3038
out-prefix: osx-x64
@@ -68,8 +76,8 @@ jobs:
6876
if: ${{ !matrix.container }}
6977
run: cargo build --manifest-path src/Temporalio/Bridge/Cargo.toml --release
7078

71-
- name: Build (Docker)
72-
if: ${{ matrix.container }}
79+
- name: Build (Docker non-Alpine)
80+
if: ${{ matrix.container && matrix.os != 'alpine-latest' }}
7381
run: |
7482
docker run --rm -v "$(pwd):/workspace" -w /workspace \
7583
${{ matrix.container }} \
@@ -82,11 +90,27 @@ jobs:
8290
&& cargo build --manifest-path src/Temporalio/Bridge/Cargo.toml --release \
8391
'
8492
93+
- name: Build (Docker Alpine)
94+
if: ${{ matrix.container && matrix.os == 'alpine-latest' }}
95+
run: |
96+
docker run --rm -v "$(pwd):/workspace" -w /workspace \
97+
${{ matrix.container }} \
98+
sh -c ' \
99+
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y \
100+
&& . $HOME/.cargo/env \
101+
&& apk add --no-cache build-base \
102+
&& curl -LO ${{ matrix.protobuf-url }} \
103+
&& unzip protoc-*.zip -d /usr/local/protobuf \
104+
&& export PATH="$PATH:/usr/local/protobuf/bin" \
105+
&& RUSTFLAGS="-C target-feature=-crt-static" cargo build --manifest-path src/Temporalio/Bridge/Cargo.toml --release \
106+
'
107+
85108
- name: Upload bridge library
86109
uses: actions/upload-artifact@v4
87110
with:
88111
name: ${{ matrix.out-prefix }}-bridge
89112
path: src/Temporalio/Bridge/target/release/${{ matrix.out-file }}
113+
if-no-files-found: error
90114

91115
build-nuget-package:
92116
needs:
@@ -129,15 +153,19 @@ jobs:
129153
strategy:
130154
fail-fast: false
131155
matrix:
132-
os: [ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest]
156+
os: [ubuntu-latest, ubuntu-arm, alpine-latest, macos-intel, macos-arm, windows-latest]
133157
include:
134158
- os: ubuntu-arm
135159
runsOn: buildjet-4vcpu-ubuntu-2204-arm
160+
- os: alpine-latest
161+
container: mcr.microsoft.com/dotnet/sdk:8.0-alpine
162+
runsOn: ubuntu-latest
136163
- os: macos-intel
137164
runsOn: macos-13
138165
- os: macos-arm
139166
runsOn: macos-14
140167
runs-on: ${{ matrix.runsOn || matrix.os }}
168+
container: ${{ matrix.container }}
141169
steps:
142170
- name: Checkout repository
143171
uses: actions/checkout@v4
@@ -148,18 +176,26 @@ jobs:
148176
uses: actions/download-artifact@v4
149177
with:
150178
name: nuget-package
151-
path: nuget-package
179+
path: ${{ github.workspace }}/nuget-package
152180

153181
- name: Setup .NET
182+
if: ${{ !matrix.container }}
154183
uses: actions/setup-dotnet@v4
155184
with:
156185
# Specific .NET version required because GitHub macos ARM image has
157186
# bad pre-installed .NET version
158187
dotnet-version: 6.x
159188

160-
- name: Run smoke test
189+
- name: Run smoke test (non-Windows)
190+
if: ${{ matrix.os != 'windows-latest' }}
191+
run: |
192+
dotnet add tests/Temporalio.SmokeTest package Temporalio -s "$GITHUB_WORKSPACE/nuget-package/Temporalio/bin/Release;https://api.nuget.org/v3/index.json" --prerelease
193+
dotnet run --project tests/Temporalio.SmokeTest
194+
195+
- name: Run smoke test (Windows)
196+
if: ${{ matrix.os == 'windows-latest' }}
161197
run: |
162-
dotnet add tests/Temporalio.SmokeTest package Temporalio -s "${{ github.workspace }}/nuget-package/Temporalio/bin/Release;https://api.nuget.org/v3/index.json" --prerelease
198+
dotnet add tests/Temporalio.SmokeTest package Temporalio -s "$env:GITHUB_WORKSPACE/nuget-package/Temporalio/bin/Release;https://api.nuget.org/v3/index.json" --prerelease
163199
dotnet run --project tests/Temporalio.SmokeTest
164200
165201
- name: Setup msbuild (Windows only)
@@ -169,6 +205,6 @@ jobs:
169205
- name: Run .NET framework smoke test (Windows only)
170206
if: ${{ matrix.os == 'windows-latest' }}
171207
run: |
172-
dotnet add tests/Temporalio.SmokeTestDotNetFramework package Temporalio -s "${{ github.workspace }}/nuget-package/Temporalio/bin/Release;https://api.nuget.org/v3/index.json" --prerelease
208+
dotnet add tests/Temporalio.SmokeTestDotNetFramework package Temporalio -s "$env:GITHUB_WORKSPACE/nuget-package/Temporalio/bin/Release;https://api.nuget.org/v3/index.json" --prerelease
173209
msbuild tests/Temporalio.SmokeTestDotNetFramework -t:restore,build -p:Platform=x64
174210
tests/Temporalio.SmokeTestDotNetFramework/bin/x64/Debug/Temporalio.SmokeTestDotNetFramework.exe

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,8 @@ reimplementation of the Temporal server with special time skipping capabilities.
815815
to run when first called. Note, this class is not thread safe nor safe for use with independent tests. It can be reused,
816816
but only for one test at a time because time skipping is locked/unlocked at the environment level.
817817

818+
⚠️ WARNING - at this time, the time-skipping test server does not work on musl-based environments like Alpine.
819+
818820
##### Automatic Time Skipping
819821

820822
Anytime a workflow result is waiting on, the time-skipping server automatically advances to the next event it can. To
@@ -1130,8 +1132,8 @@ included when using modern versions of .NET on a common platform. If you are usi
11301132
explicitly set the platform to `x64` or `arm64` because `AnyCPU` will not choose the proper library.
11311133

11321134
Currently we only support [RIDs](https://learn.microsoft.com/en-us/dotnet/core/rid-catalog) `linux-arm64`,
1133-
`linux-x64`, `osx-arm64`, `osx-x64`, and `win-x64`. Any other platforms needed (e.g. `linux-musl-x64` on Alpine) will
1134-
require a custom build.
1135+
`linux-x64`, `linux-musl-x64`, `osx-arm64`, `osx-x64`, and `win-x64`. Any other platforms needed (e.g. `linux-musl-x64`
1136+
on Alpine) will require a custom build.
11351137

11361138
The native shared library on Windows does require a Visual C++ runtime. Some containers, such as Windows Nano Server, do
11371139
not include this runtime. If not available, users may have to manually copy this runtime (usually just

src/Temporalio/Bridge/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ edition = "2021"
55

66
[lib]
77
name = "temporal_sdk_bridge"
8-
crate-type = ["cdylib", "rlib"]
8+
crate-type = ["cdylib"]
99

1010
[dependencies]
1111
anyhow = "1.0"

src/Temporalio/Temporalio.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@
9090
<Content Include="$(BridgeLibraryRoot)/linux-arm64-bridge/libtemporal_sdk_bridge.so">
9191
<PackagePath>runtimes/linux-arm64/native/libtemporal_sdk_bridge.so</PackagePath>
9292
</Content>
93+
<Content Include="$(BridgeLibraryRoot)/linux-musl-x64-bridge/libtemporal_sdk_bridge.so">
94+
<PackagePath>runtimes/linux-musl-x64/native/libtemporal_sdk_bridge.so</PackagePath>
95+
</Content>
9396
<Content Include="$(BridgeLibraryRoot)/osx-x64-bridge/libtemporal_sdk_bridge.dylib">
9497
<PackagePath>runtimes/osx-x64/native/libtemporal_sdk_bridge.dylib</PackagePath>
9598
</Content>

src/Temporalio/Testing/WorkflowEnvironment.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,19 @@ public static async Task<WorkflowEnvironment> StartTimeSkippingAsync(
8585
WorkflowEnvironmentStartTimeSkippingOptions? options = null)
8686
{
8787
options ??= new();
88+
89+
// If they did not provide a binary to use, eagerly fail on musl since musl
90+
// time-skipping is not supported at this time. We can only do this check in .NET 5+,
91+
// otherwise we assume it is not musl for now since this is just a temporary situation.
92+
// TODO(cretz): Remove when musl-support for time-skipping test server is present.
93+
#if NET5_0_OR_GREATER
94+
if (System.Runtime.InteropServices.RuntimeInformation.Contains("-musl", StringComparison.OrdinalIgnoreCase))
95+
{
96+
throw new InvalidOperationException(
97+
"Time-skipping test server not currently supported in musl-based environments");
98+
}
99+
#endif
100+
88101
var runtime = options.Runtime ?? TemporalRuntime.Default;
89102
var server = await Bridge.EphemeralServer.StartTestServerAsync(
90103
runtime.Runtime,

0 commit comments

Comments
 (0)