Skip to content

Commit

Permalink
Init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Dec 20, 2024
0 parents commit f4347db
Show file tree
Hide file tree
Showing 16 changed files with 1,077 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/compatibility_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Compatibility tests

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
compatibility_tests_macos:
name: Execute compatibility tests for macOS
strategy:
matrix:
os: [macos-15]
xcode-version: ["16.0"]
runs-on: ${{ matrix.os }}
env:
UNSAFEHETEROGENEOUSBUFFER_SWIFTUI_COMPATIBILITY_TEST: 1
steps:
- uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.xcode-version }}
- name: Run compatibility tests
run: |
./Scripts/patch_sdk.sh macosx SwiftUICore ./SDKPatches/patch.swiftinterface
swift test
./Scripts/unpatch_sdk.sh macosx SwiftUICore ./SDKPatches/patch.swiftinterface
compatibility_tests_ios:
name: Execute compatibility tests for iOS
strategy:
fail-fast: false
matrix:
os: [macos-15]
xcode-version: ["16.0"]
ios-version: ["18.0"]
ios-simulator-name: ["iPhone 16 Pro"]
runs-on: ${{ matrix.os }}
env:
UNSAFEHETEROGENEOUSBUFFER_SWIFTUI_COMPATIBILITY_TEST: 1
steps:
- uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.xcode-version }}
- name: Run compatibility tests
run: |
./Scripts/patch_sdk.sh iphonesimulator SwiftUICore ./SDKPatches/patch.swiftinterface
xcodebuild test \
-scheme UnsafeHeterogeneousBuffer \
-configuration Debug \
-destination "platform=iOS Simulator,OS=${{ matrix.ios-version }},name=${{ matrix.ios-simulator-name }}"
./Scripts/unpatch_sdk.sh iphonesimulator SwiftUICore ./SDKPatches/patch.swiftinterface
34 changes: 34 additions & 0 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: iOS

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
ios_test:
name: Execute tests on iOS
strategy:
matrix:
os: [macos-15]
xcode-version: [16.0]
ios-version: ["18.0"]
ios-simulator-name: ["iPhone 16 Pro"]
runs-on: ${{ matrix.os }}
env:
UNSAFEHETEROGENEOUSBUFFER_SWIFTUI_COMPATIBILITY_TEST: 0
steps:
- uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.xcode-version }}
- name: Swift version
run: swift --version
- name: Run test target in debug mode
run: |
xcodebuild test \
-scheme UnsafeHeterogeneousBuffer \
-configuration Debug \
-destination "platform=iOS Simulator,OS=${{ matrix.ios-version }},name=${{ matrix.ios-simulator-name }}"
54 changes: 54 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: macOS

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
name: Build XCFramework
runs-on: macos-15
env:
PRODUCT_NAME: UnsafeHeterogeneousBuffer
steps:
- uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: 16.0
- name: Build XCFramework
run: ./Scripts/build_xcframework.sh
macos_test:
name: Execute tests on macOS
strategy:
matrix:
os: [macos-15]
xcode-version: [16.0]
runs-on: ${{ matrix.os }}
env:
UNSAFEHETEROGENEOUSBUFFER_SWIFTUI_COMPATIBILITY_TEST: 0
steps:
- uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.xcode-version }}
- name: Build and run tests in debug mode with coverage
run: |
swift test \
-c debug \
--enable-code-coverage \
--build-path .build-test-debug
xcrun llvm-cov show \
-instr-profile=.build-test-debug/debug/codecov/default.profdata \
.build-test-debug/debug/UnsafeHeterogeneousBufferPackageTests.xctest/Contents/MacOS/UnsafeHeterogeneousBufferPackageTests \
> coverage.txt
- uses: codecov/codecov-action@v4
with:
file: ./coverage.txt
flags: unittests
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Ubuntu

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
ubuntu_test:
name: Execute tests on Ubuntu
strategy:
matrix:
swift_version: ["6.0.1"]
runs-on: ubuntu-22.04
env:
UNSAFEHETEROGENEOUSBUFFER_SWIFTUI_COMPATIBILITY_TEST: 0
container: swift:${{ matrix.swift_version }}-jammy
steps:
- uses: actions/checkout@v4
- name: Test
run: |
swift test
7 changes: 7 additions & 0 deletions .swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Kyle-Ye

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
56 changes: 56 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// swift-tools-version: 6.0

import PackageDescription

func envEnable(_ key: String, default defaultValue: Bool = false) -> Bool {
guard let value = Context.environment[key] else {
return defaultValue
}
if value == "1" {
return true
} else if value == "0" {
return false
} else {
return defaultValue
}
}

let testTarget = Target.testTarget(name: "UnsafeHeterogeneousBufferTests")
var platforms: [SupportedPlatform]?

let compatibilityTestCondition = envEnable("UNSAFEHETEROGENEOUSBUFFER_SWIFTUI_COMPATIBILITY_TEST")
if compatibilityTestCondition {
var swiftSettings: [SwiftSetting] = (testTarget.swiftSettings ?? [])
swiftSettings.append(.define("UNSAFEHETEROGENEOUSBUFFER_SWIFTUI_COMPATIBILITY_TEST"))
testTarget.swiftSettings = swiftSettings
platforms = [.iOS(.v18), .macOS(.v15), .tvOS(.v18), .watchOS(.v11), .visionOS(.v2)]
} else {
testTarget.dependencies.append("UnsafeHeterogeneousBuffer")
}

let libraryType: Product.Library.LibraryType?
switch Context.environment["UNSAFEHETEROGENEOUSBUFFER_LIBRARY_TYPE"] {
case "dynamic":
libraryType = .dynamic
case "static":
libraryType = .static
default:
libraryType = nil
}

let package = Package(
name: "UnsafeHeterogeneousBuffer",
platforms: platforms,
products: [
.library(name: "UnsafeHeterogeneousBuffer", type: libraryType, targets: ["UnsafeHeterogeneousBuffer"]),
],
targets: [
.target(
name: "UnsafeHeterogeneousBuffer",
swiftSettings: [
.enableUpcomingFeature("InternalImportsByDefault"),
]
),
testTarget,
]
)
Loading

0 comments on commit f4347db

Please sign in to comment.