Skip to content

Commit 79da5f9

Browse files
authored
Merge pull request #1 from ayersdecker/copilot/setup-native-compute-framework
Fix failing GitHub Actions jobs in maui-build workflow
2 parents b099853 + 7bd658f commit 79da5f9

39 files changed

Lines changed: 3150 additions & 2 deletions
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Codegen Tool Tests
2+
3+
# Builds the codegen tool and runs the unit-test suite (xUnit).
4+
# Runs on Linux (fast, cheap) and can be extended to macOS/Windows.
5+
6+
on:
7+
push:
8+
paths:
9+
- 'tools/codegen/**'
10+
- 'src/Framework/**'
11+
- 'src/Framework.Tests/**'
12+
- '.github/workflows/codegen-tests.yml'
13+
- 'Directory.Build.props'
14+
pull_request:
15+
paths:
16+
- 'tools/codegen/**'
17+
- 'src/Framework/**'
18+
- 'src/Framework.Tests/**'
19+
- '.github/workflows/codegen-tests.yml'
20+
- 'Directory.Build.props'
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
test:
27+
name: Test (.NET ${{ matrix.dotnet }})
28+
runs-on: ubuntu-24.04
29+
strategy:
30+
matrix:
31+
dotnet: ['9.0.x']
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Setup .NET
37+
uses: actions/setup-dotnet@v4
38+
with:
39+
dotnet-version: ${{ matrix.dotnet }}
40+
41+
- name: Restore
42+
run: |
43+
FerrumSkipMobile=true dotnet restore tools/codegen/Ferrum.Codegen.csproj
44+
FerrumSkipMobile=true dotnet restore src/Framework/Ferrum.Framework.csproj
45+
FerrumSkipMobile=true dotnet restore src/Framework.Tests/Ferrum.Framework.Tests.csproj
46+
47+
- name: Build
48+
run: |
49+
FerrumSkipMobile=true dotnet build tools/codegen/Ferrum.Codegen.csproj --no-restore -c Release
50+
FerrumSkipMobile=true dotnet build src/Framework/Ferrum.Framework.csproj --no-restore -c Release
51+
FerrumSkipMobile=true dotnet build src/Framework.Tests/Ferrum.Framework.Tests.csproj --no-restore -c Release
52+
53+
- name: Test
54+
run: |
55+
FerrumSkipMobile=true dotnet test src/Framework.Tests/Ferrum.Framework.Tests.csproj \
56+
--no-build -c Release \
57+
--logger "trx;LogFileName=test-results.trx" \
58+
--logger "console;verbosity=normal"
59+
60+
- name: Upload test results
61+
if: always()
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: test-results-${{ matrix.dotnet }}
65+
path: '**/*.trx'
66+
67+
# Smoke-test the CLI: parse the in-tree add.h and verify zero exit code
68+
codegen-smoke:
69+
name: Codegen smoke test
70+
runs-on: ubuntu-24.04
71+
needs: test
72+
73+
steps:
74+
- uses: actions/checkout@v4
75+
76+
- name: Setup .NET
77+
uses: actions/setup-dotnet@v4
78+
with:
79+
dotnet-version: '9.0.x'
80+
81+
- name: Build codegen
82+
run: FerrumSkipMobile=true dotnet build tools/codegen/Ferrum.Codegen.csproj -c Release
83+
84+
- name: Run codegen on test stub header
85+
run: |
86+
FerrumSkipMobile=true dotnet run --project tools/codegen/Ferrum.Codegen.csproj \
87+
--configuration Release \
88+
-- \
89+
--input native/test_stub/include/add.h \
90+
--output /tmp/AddBindings.cs \
91+
--ns Ferrum.Generated \
92+
--class AddBindings \
93+
--lib __Internal
94+
95+
- name: Verify output
96+
run: |
97+
echo "=== Generated bindings ==="
98+
cat /tmp/AddBindings.cs
99+
# Ensure [LibraryImport] and the function name are present
100+
grep -q "\[LibraryImport" /tmp/AddBindings.cs
101+
grep -q "ferrum_add" /tmp/AddBindings.cs
102+
echo "==> Smoke test passed"

.github/workflows/maui-build.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: MAUI Build
2+
3+
# Builds the Ferrum.Framework library and the MinimalDemo sample app.
4+
# The iOS build requires macOS; Android can be built on ubuntu.
5+
#
6+
# NOTE: The native libraries (XCFramework / .so) must already be available
7+
# as artifacts from the native-build workflow before this workflow can
8+
# produce a fully linkable app binary. In the absence of the native libs,
9+
# this workflow validates that the managed code compiles cleanly.
10+
11+
on:
12+
push:
13+
paths:
14+
- 'src/**'
15+
- 'samples/**'
16+
- '.github/workflows/maui-build.yml'
17+
- 'Directory.Build.props'
18+
pull_request:
19+
paths:
20+
- 'src/**'
21+
- 'samples/**'
22+
- '.github/workflows/maui-build.yml'
23+
- 'Directory.Build.props'
24+
25+
permissions:
26+
contents: read
27+
28+
jobs:
29+
# ── Framework library build ────────────────────────────────────────────────
30+
framework:
31+
name: Framework (${{ matrix.os }})
32+
runs-on: ${{ matrix.os }}
33+
strategy:
34+
matrix:
35+
os: [macos-15]
36+
37+
steps:
38+
- uses: actions/checkout@v4
39+
40+
- name: Setup .NET
41+
uses: actions/setup-dotnet@v4
42+
with:
43+
dotnet-version: '9.0.x'
44+
45+
- name: Install MAUI workload
46+
run: dotnet workload install maui
47+
48+
- name: Build Ferrum.Framework (all TFMs)
49+
run: |
50+
dotnet build src/Framework/Ferrum.Framework.csproj \
51+
-c Release
52+
53+
# ── MAUI iOS build ─────────────────────────────────────────────────────────
54+
ios-maui:
55+
name: MAUI iOS build
56+
runs-on: macos-15
57+
needs: framework
58+
59+
steps:
60+
- uses: actions/checkout@v4
61+
62+
- name: Select Xcode
63+
run: sudo xcode-select --switch /Applications/Xcode_16.2.app
64+
65+
- name: Setup .NET
66+
uses: actions/setup-dotnet@v4
67+
with:
68+
dotnet-version: '9.0.x'
69+
70+
- name: Install MAUI workload
71+
run: dotnet workload install maui
72+
73+
- name: Build MinimalDemo (iOS — no signing)
74+
run: |
75+
dotnet build samples/MinimalDemo/MinimalDemo.csproj \
76+
-f net9.0-ios \
77+
-c Release \
78+
/p:RuntimeIdentifier=ios-arm64 \
79+
/p:CodesignKey="" \
80+
/p:CodesignProvision=""
81+
82+
# ── MAUI Android build ─────────────────────────────────────────────────────
83+
android-maui:
84+
name: MAUI Android build
85+
runs-on: ubuntu-24.04
86+
needs: framework
87+
88+
steps:
89+
- uses: actions/checkout@v4
90+
91+
- name: Setup .NET
92+
uses: actions/setup-dotnet@v4
93+
with:
94+
dotnet-version: '9.0.x'
95+
96+
- name: Install Android workload
97+
run: dotnet workload install android
98+
99+
- name: Setup Android SDK
100+
uses: android-actions/setup-android@v3
101+
102+
- name: Build MinimalDemo (Android)
103+
run: |
104+
dotnet build samples/MinimalDemo/MinimalDemo.csproj \
105+
-f net9.0-android \
106+
-c Release

.github/workflows/native-build.yml

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: Native Build (iOS & Android)
2+
3+
# Builds the native static/shared libraries for all supported platforms and
4+
# ABIs, then uploads the artifacts for use by the MAUI build workflow.
5+
#
6+
# Triggered on every push and pull request that touches native code or the
7+
# build scripts.
8+
9+
on:
10+
push:
11+
paths:
12+
- 'native/**'
13+
- '.github/workflows/native-build.yml'
14+
pull_request:
15+
paths:
16+
- 'native/**'
17+
- '.github/workflows/native-build.yml'
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
# ── iOS XCFramework ────────────────────────────────────────────────────────
24+
ios:
25+
name: iOS XCFramework (${{ matrix.platform }})
26+
runs-on: macos-15
27+
strategy:
28+
matrix:
29+
include:
30+
- platform: OS64
31+
sysroot: iphoneos
32+
label: device-arm64
33+
- platform: SIMULATORARM64
34+
sysroot: iphonesimulator
35+
label: sim-arm64
36+
- platform: SIMULATOR64
37+
sysroot: iphonesimulator
38+
label: sim-x86_64
39+
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Select Xcode
44+
run: sudo xcode-select --switch /Applications/Xcode_16.2.app
45+
46+
- name: Configure CMake
47+
run: |
48+
cmake -S native \
49+
-B .build/ios/${{ matrix.label }} \
50+
-DCMAKE_TOOLCHAIN_FILE="${{ github.workspace }}/native/cmake/ios.toolchain.cmake" \
51+
-DPLATFORM=${{ matrix.platform }} \
52+
-DDEPLOYMENT_TARGET=15.0 \
53+
-DCMAKE_BUILD_TYPE=Release \
54+
-GXcode
55+
56+
- name: Build
57+
run: |
58+
cmake --build .build/ios/${{ matrix.label }} \
59+
--config Release \
60+
--target ferrum_test_stub
61+
62+
- name: Upload slice artifact
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: ios-${{ matrix.label }}
66+
path: .build/ios/${{ matrix.label }}/Release-${{ matrix.sysroot }}/libferrum_test_stub.a
67+
68+
# Assemble the full XCFramework from the three slices
69+
ios-xcframework:
70+
name: Assemble XCFramework
71+
runs-on: macos-15
72+
needs: ios
73+
steps:
74+
- uses: actions/checkout@v4
75+
76+
- uses: actions/download-artifact@v4
77+
with:
78+
name: ios-device-arm64
79+
path: .slices/device
80+
81+
- uses: actions/download-artifact@v4
82+
with:
83+
name: ios-sim-arm64
84+
path: .slices/sim-arm64
85+
86+
- uses: actions/download-artifact@v4
87+
with:
88+
name: ios-sim-x86_64
89+
path: .slices/sim-x86_64
90+
91+
- name: Create fat simulator library
92+
run: |
93+
lipo -create \
94+
.slices/sim-arm64/libferrum_test_stub.a \
95+
.slices/sim-x86_64/libferrum_test_stub.a \
96+
-output .slices/sim-fat/libferrum_test_stub.a
97+
98+
- name: Create XCFramework
99+
run: |
100+
mkdir -p artifacts/ios
101+
xcodebuild -create-xcframework \
102+
-library .slices/device/libferrum_test_stub.a \
103+
-library .slices/sim-fat/libferrum_test_stub.a \
104+
-output artifacts/ios/libferrum_test_stub.xcframework
105+
106+
- name: Upload XCFramework
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: ios-xcframework
110+
path: artifacts/ios/libferrum_test_stub.xcframework
111+
112+
# ── Android .so per ABI ────────────────────────────────────────────────────
113+
android:
114+
name: Android (${{ matrix.abi }})
115+
runs-on: ubuntu-24.04
116+
strategy:
117+
matrix:
118+
abi: [arm64-v8a, armeabi-v7a, x86_64, x86]
119+
120+
steps:
121+
- uses: actions/checkout@v4
122+
123+
- name: Set up NDK
124+
uses: android-actions/setup-android@v3
125+
126+
- name: Install NDK
127+
run: sdkmanager "ndk;27.2.12479018"
128+
129+
- name: Configure CMake
130+
run: |
131+
NDK_ROOT="${ANDROID_SDK_ROOT}/ndk/27.2.12479018"
132+
cmake -S native \
133+
-B .build/android/${{ matrix.abi }} \
134+
-DCMAKE_TOOLCHAIN_FILE="${NDK_ROOT}/build/cmake/android.toolchain.cmake" \
135+
-DANDROID_ABI=${{ matrix.abi }} \
136+
-DANDROID_PLATFORM=android-24 \
137+
-DCMAKE_BUILD_TYPE=Release
138+
139+
- name: Build
140+
run: |
141+
cmake --build .build/android/${{ matrix.abi }} \
142+
--config Release \
143+
--target ferrum_test_stub
144+
145+
- name: Upload .so artifact
146+
uses: actions/upload-artifact@v4
147+
with:
148+
name: android-${{ matrix.abi }}
149+
path: .build/android/${{ matrix.abi }}/libferrum_test_stub.so

Directory.Build.props

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project>
2+
<!--
3+
Directory.Build.props — common MSBuild properties applied to every
4+
project in this repository. Keep this file minimal; project-specific
5+
settings belong in the .csproj file.
6+
-->
7+
<PropertyGroup>
8+
<Nullable>enable</Nullable>
9+
<LangVersion>latest</LangVersion>
10+
<ImplicitUsings>enable</ImplicitUsings>
11+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
12+
13+
<!-- Reproducible builds -->
14+
<Deterministic>true</Deterministic>
15+
<ContinuousIntegrationBuild Condition="'$(CI)' == 'true'">true</ContinuousIntegrationBuild>
16+
</PropertyGroup>
17+
</Project>

0 commit comments

Comments
 (0)