-
Notifications
You must be signed in to change notification settings - Fork 15
122 lines (112 loc) · 5.15 KB
/
Copy pathnative.yaml
File metadata and controls
122 lines (112 loc) · 5.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Native build
# Cross-compiles the Rust shared-core wrapper (sdk-core/src/main/rust) for every supported
# platform, smoke-tests the produced library, and uploads it as an artifact. The release pipeline
# downloads these artifacts and overlays them into the single (uber) sdk-core jar.
on:
workflow_dispatch:
workflow_call:
jobs:
build:
name: "Build native (${{ matrix.target }})"
runs-on: ${{ matrix.runner }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
# `classifier` is the runtime resource classifier resolved by NativeLibraryLoader and the
# subdirectory the release overlay expects: dev/restate/sdk/core/native/<classifier>/.
- target: x86_64-unknown-linux-gnu
classifier: linux-x86_64
runner: ubuntu-latest
cross: false
rustflags: ""
- target: aarch64-unknown-linux-gnu
classifier: linux-aarch64
runner: ubuntu-latest
cross: true
rustflags: ""
# musl is statically linked by default, which can't produce a cdylib (.so); disabling
# crt-static makes the target dynamically linkable so the shared library can be built.
- target: x86_64-unknown-linux-musl
classifier: linux-x86_64-musl
runner: ubuntu-latest
cross: true
rustflags: "-C target-feature=-crt-static"
- target: aarch64-unknown-linux-musl
classifier: linux-aarch64-musl
runner: ubuntu-latest
cross: true
rustflags: "-C target-feature=-crt-static"
# macOS runners are expensive; comment out the darwin targets to disable them.
# x86_64 darwin disabled for now — re-enable if Intel Mac support is needed.
# - target: x86_64-apple-darwin
# classifier: darwin-x86_64
# runner: macos-13
# cross: false
# rustflags: ""
- target: aarch64-apple-darwin
classifier: darwin-aarch64
runner: macos-14
cross: false
rustflags: ""
steps:
- uses: actions/checkout@v6
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
target: ${{ matrix.target }}
cache-workspaces: sdk-core/src/main/rust
# Segment the cache per target. Otherwise all Linux targets share one cache, and the
# native x86_64 job (host glibc 2.39) populates target/release/build with host-compiled
# build-script/proc-macro binaries that the `cross` jobs then restore and try to run
# inside the older cross container (glibc ~2.31) -> "GLIBC_2.39 not found", build fails.
cache-key: ${{ matrix.target }}
- name: Install cross
if: ${{ matrix.cross }}
run: cargo install cross --git https://github.com/cross-rs/cross --locked
- name: Build cdylib
working-directory: sdk-core/src/main/rust
env:
# `cross` forwards RUSTFLAGS into the build container.
RUSTFLAGS: ${{ matrix.rustflags }}
run: |
if [ "${{ matrix.cross }}" = "true" ]; then
cross build --release --target ${{ matrix.target }}
else
cargo build --release --target ${{ matrix.target }}
fi
- name: Locate library
id: lib
working-directory: sdk-core/src/main/rust
run: |
dir="target/${{ matrix.target }}/release"
file=$(ls "$dir"/librestate_sdk_core.so "$dir"/librestate_sdk_core.dylib 2>/dev/null | head -1)
if [ -z "$file" ]; then echo "no library produced for ${{ matrix.target }}"; exit 1; fi
echo "path=sdk-core/src/main/rust/$file" >> "$GITHUB_OUTPUT"
echo "file=$file" >> "$GITHUB_OUTPUT"
- name: Smoke test (exported C symbols present)
working-directory: sdk-core/src/main/rust
run: |
f="${{ steps.lib.outputs.file }}"
# Linux uses `nm -D` (no symbol prefix); macOS uses `nm -gU` (leading underscore).
if [ "$RUNNER_OS" = "macOS" ]; then list="nm -gU"; pre="_"; else list="nm -D"; pre=""; fi
for sym in init vm_new vm_free free_buffer vm_sys_call vm_take_notification; do
$list "$f" 2>/dev/null | grep -qE "[ ]${pre}${sym}$" || { echo "missing exported symbol: $sym"; exit 1; }
done
echo "All expected symbols present in $f"
# Stage the library into the exact resource layout the sdk-core jar expects, so the release
# pipeline can download every artifact with `merge-multiple: true` and hand the reconstructed
# tree straight to Gradle via `-PnativeLibsDir`.
- name: Stage library into resource layout
working-directory: sdk-core/src/main/rust
run: |
dest="$GITHUB_WORKSPACE/native-staging/dev/restate/sdk/core/native/${{ matrix.classifier }}"
mkdir -p "$dest"
cp "${{ steps.lib.outputs.file }}" "$dest/"
- name: Upload native library
uses: actions/upload-artifact@v7
with:
name: native-${{ matrix.classifier }}
path: native-staging
if-no-files-found: error