Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Swift

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
macos:
name: macOS
runs-on: macos-26
steps:
- uses: actions/checkout@v4
# The runners' stable Xcode has an older Swift. Xcode gives the SDKs;
# the toolchain is swift.org's, as `.swift-version` pins it.
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- uses: SwiftyLab/setup-swift@latest
with:
swift-version: "6.4.2"
- name: Swift version
run: swift --version
- name: Build
run: swift build --build-tests
- name: Test
run: swift test --skip-build
- name: Test the WasmKit engine
working-directory: Packages/RuntimeWasm
run: swift test
- name: Test the scripts
run: python3 -m unittest discover -s Scripts -p 'test_*.py'

linux:
name: Linux (${{ matrix.arch }})
strategy:
fail-fast: false
matrix:
include:
- arch: x86_64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
container: swift:6.4.2-trixie
steps:
- uses: actions/checkout@v4
- name: Build
run: swift build --build-tests
- name: Test
run: swift test --skip-build
4 changes: 2 additions & 2 deletions Packages/RuntimeWasm/Sources/RuntimeWasm/GuestMemory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ struct GuestMemory {
let count = Int(count)
guard count > 0 else { return [] }
try check(offset, count)
return memory.withUnsafeBufferPointer(offset: UInt(offset), count: count) { Array($0) }
return try memory.withUnsafeBufferPointer(offset: UInt(offset), count: count) { Array($0) }
}

func write(_ bytes: [UInt8], at offset: UInt32) throws {
guard !bytes.isEmpty else { return }
try check(offset, bytes.count)
memory.withUnsafeMutableBufferPointer(offset: UInt(offset), count: bytes.count) { buffer in
try memory.withUnsafeMutableBufferPointer(offset: UInt(offset), count: bytes.count) { buffer in
buffer.copyBytes(from: bytes)
}
}
Expand Down
2 changes: 1 addition & 1 deletion Packages/RuntimeWasm/Sources/RuntimeWasm/WasmGL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public final class WasmGL {
}
// GL doesn't call back into the guest, so its memory can't move
// while the pointer is held.
let result = memory.withUnsafeMutableBufferPointer(offset: 0, count: memory.byteCount) { buffer in
let result = try memory.withUnsafeMutableBufferPointer(offset: 0, count: memory.byteCount) { buffer in
context.base = buffer.baseAddress?.assumingMemoryBound(to: UInt8.self)
context.size = UInt64(buffer.count)
return rt_gl_call(&context, index, slots)
Expand Down
Loading