Skip to content

Commit f2d6c7a

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

File tree

3 files changed

+46
-6
lines changed

3 files changed

+46
-6
lines changed

.github/workflows/package.yml

Lines changed: 29 additions & 4 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,14 +76,29 @@ 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' }}
81+
run: |
82+
docker run --rm -v "$(pwd):/workspace" -w /workspace \
83+
${{ matrix.container }} \
84+
sh -c ' \
85+
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y \
86+
&& . $HOME/.cargo/env \
87+
&& curl -LO ${{ matrix.protobuf-url }} \
88+
&& unzip protoc-*.zip -d /usr/local/protobuf \
89+
&& export PATH="$PATH:/usr/local/protobuf/bin" \
90+
&& cargo build --manifest-path src/Temporalio/Bridge/Cargo.toml --release \
91+
'
92+
93+
- name: Build (Docker Alpine)
94+
if: ${{ matrix.container && matrix.os == 'alpine-latest' }}
7395
run: |
7496
docker run --rm -v "$(pwd):/workspace" -w /workspace \
7597
${{ matrix.container }} \
7698
sh -c ' \
7799
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y \
78100
&& . $HOME/.cargo/env \
101+
&& apk add --no-cache build-base \
79102
&& curl -LO ${{ matrix.protobuf-url }} \
80103
&& unzip protoc-*.zip -d /usr/local/protobuf \
81104
&& export PATH="$PATH:/usr/local/protobuf/bin" \
@@ -129,10 +152,12 @@ jobs:
129152
strategy:
130153
fail-fast: false
131154
matrix:
132-
os: [ubuntu-latest, ubuntu-arm, macos-intel, macos-arm, windows-latest]
155+
os: [ubuntu-latest, ubuntu-arm, alpine-latest, macos-intel, macos-arm, windows-latest]
133156
include:
134157
- os: ubuntu-arm
135158
runsOn: buildjet-4vcpu-ubuntu-2204-arm
159+
- os: alpine-latest
160+
container: mcr.microsoft.com/dotnet/sdk:8.0-alpine
136161
- os: macos-intel
137162
runsOn: macos-13
138163
- os: macos-arm

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/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)