Skip to content

Commit

Permalink
Merge pull request #1 from treastrain/feature/async-sequence-subscrib…
Browse files Browse the repository at this point in the history
…ers-sink

Create `AsyncSequenceSubscribers.Sink`
  • Loading branch information
treastrain authored Jun 2, 2024
2 parents 12cf225 + 425bcfa commit 12b361b
Show file tree
Hide file tree
Showing 22 changed files with 2,393 additions and 0 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Swift - Build and Test

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

env:
XCODE_SELECT_PATH: '/Applications/Xcode_15.4.app/Contents/Developer'

jobs:
show_software_information:
name: Show software information
strategy:
fail-fast: false
matrix:
os: [macos-14, ubuntu-20.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
- name: Set Xcode version
if: ${{ matrix.os == 'macos-14' }}
run: sudo xcode-select -s '${{ env.XCODE_SELECT_PATH }}'
- name: Show Swift version
run: swift --version
- name: Show Swift Package Manager version
run: swift package --version

build_test:
name: Swift Build & Test
strategy:
fail-fast: false
matrix:
os: [macos-14, ubuntu-20.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
- name: Set Xcode version
if: ${{ matrix.os == 'macos-14' }}
run: sudo xcode-select -s '${{ env.XCODE_SELECT_PATH }}'
- uses: actions/checkout@v4
- name: Build
run: swift build -v | tee swift-build_${{ matrix.os }}.log && exit ${PIPESTATUS[0]}
- name: Upload build log
if: always()
uses: actions/upload-artifact@v4
with:
name: swift build log (${{ matrix.os }})
path: |
swift-build_${{ matrix.os }}.log
- name: Run tests
run: swift test -v | tee swift-test_${{ matrix.os }}.log && exit ${PIPESTATUS[0]}
- name: Upload test log
if: always()
uses: actions/upload-artifact@v4
with:
name: swift test log (${{ matrix.os }})
path: |
swift-test_${{ matrix.os }}.log
93 changes: 93 additions & 0 deletions .github/workflows/xcodebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Xcode - Build, Analyze and Test

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

env:
SCHEME_NAME: AsyncSequenceSubscription
IOS_SIMULATOR_NAME: iPhone 15 Pro
TVOS_SIMULATOR_NAME: Apple TV 4K (3rd generation)
WATCHOS_SIMULATOR_NAME: Apple Watch Ultra 2 (49mm)
VISIONOS_SIMULATOR_NAME: Apple Vision Pro
XCODE_SELECT_PATH: '/Applications/Xcode_15.4.app/Contents/Developer'

jobs:
show_software_information:
name: Show software information
strategy:
fail-fast: false
matrix:
os: [macos-14]
runs-on: ${{ matrix.os }}
steps:
- name: Show Xcode list
run: ls -n /Applications | grep 'Xcode'
- name: Show the default version of Xcode
run: xcodebuild -version
- name: Set Xcode version
run: sudo xcode-select -s '${{ env.XCODE_SELECT_PATH }}'
- uses: actions/checkout@v4
- name: Show lists the targets and configurations in a project, or the schemes in a workspace
run: xcodebuild -list
- name: Show a list of destinations
run: xcodebuild -scheme ${{ env.SCHEME_NAME }} -showdestinations

build:
name: Build and analyze
strategy:
fail-fast: false
matrix:
os: [macos-14]
platform: ['iOS', 'macOS-x86_64', 'macOS-arm64', 'macCatalyst-x86_64', 'macCatalyst-arm64', 'tvOS', 'watchOS', 'visionOS']
runs-on: ${{ matrix.os }}
steps:
- name: Set Xcode version
run: sudo xcode-select -s '${{ env.XCODE_SELECT_PATH }}'
- uses: actions/checkout@v4
- name: Build the scheme
run: |
case ${{ matrix.platform }} in
'iOS' ) xcodebuild clean build analyze -scheme ${{ env.SCHEME_NAME }} -destination 'name=${{ env.IOS_SIMULATOR_NAME }}' | tee xcodebuild-${{ matrix.os }}-${{ matrix.platform }}.log && exit ${PIPESTATUS[0]} ;;
'macOS-x86_64' ) xcodebuild clean build analyze -scheme ${{ env.SCHEME_NAME }} -destination 'platform=macOS,arch=x86_64' | tee xcodebuild-${{ matrix.os }}-${{ matrix.platform }}.log && exit ${PIPESTATUS[0]} ;;
'macCatalyst-x86_64' ) xcodebuild clean build analyze -scheme ${{ env.SCHEME_NAME }} -destination 'platform=macOS,arch=x86_64,variant=Mac Catalyst' | tee xcodebuild-${{ matrix.os }}-${{ matrix.platform }}.log && exit ${PIPESTATUS[0]} ;;
'macOS-arm64' ) xcodebuild clean build analyze -scheme ${{ env.SCHEME_NAME }} -destination 'platform=macOS,arch=arm64' | tee xcodebuild-${{ matrix.os }}-${{ matrix.platform }}.log && exit ${PIPESTATUS[0]} ;;
'macCatalyst-arm64' ) xcodebuild clean build analyze -scheme ${{ env.SCHEME_NAME }} -destination 'platform=macOS,arch=arm64,variant=Mac Catalyst' | tee xcodebuild-${{ matrix.os }}-${{ matrix.platform }}.log && exit ${PIPESTATUS[0]} ;;
'tvOS' ) xcodebuild clean build analyze -scheme ${{ env.SCHEME_NAME }} -destination 'name=${{ env.TVOS_SIMULATOR_NAME }}' | tee xcodebuild-${{ matrix.os }}-${{ matrix.platform }}.log && exit ${PIPESTATUS[0]} ;;
'watchOS' ) xcodebuild clean build analyze -scheme ${{ env.SCHEME_NAME }} -destination 'name=${{ env.WATCHOS_SIMULATOR_NAME }}' | tee xcodebuild-${{ matrix.os }}-${{ matrix.platform }}.log && exit ${PIPESTATUS[0]} ;;
'visionOS' ) xcodebuild clean build analyze -scheme ${{ env.SCHEME_NAME }} -destination 'name=${{ env.VISIONOS_SIMULATOR_NAME }}' | tee xcodebuild-${{ matrix.os }}-${{ matrix.platform }}.log && exit ${PIPESTATUS[0]} ;;
esac
- name: Upload Xcode Build log
if: always()
uses: actions/upload-artifact@v4
with:
name: xcodebuild log (${{ matrix.os }}, ${{ matrix.platform }})
path: |
xcodebuild-${{ matrix.os }}-${{ matrix.platform }}.log
- name: Test the scheme
run: |
case ${{ matrix.platform }} in
'iOS' ) xcodebuild test -scheme ${{ env.SCHEME_NAME }} -destination 'name=${{ env.IOS_SIMULATOR_NAME }}' -resultBundlePath TestResults-${{ matrix.os }}-${{ matrix.platform }} ;;
'macOS-x86_64' ) xcodebuild test -scheme ${{ env.SCHEME_NAME }} -destination 'platform=macOS,arch=x86_64' -resultBundlePath TestResults-${{ matrix.os }}-${{ matrix.platform }} ;;
'macCatalyst-x86_64' ) xcodebuild test -scheme ${{ env.SCHEME_NAME }} -destination 'platform=macOS,arch=x86_64,variant=Mac Catalyst' -resultBundlePath TestResults-${{ matrix.os }}-${{ matrix.platform }} ;;
'macOS-arm64' ) xcodebuild test -scheme ${{ env.SCHEME_NAME }} -destination 'platform=macOS,arch=arm64' -resultBundlePath TestResults-${{ matrix.os }}-${{ matrix.platform }} ;;
'macCatalyst-arm64' ) xcodebuild test -scheme ${{ env.SCHEME_NAME }} -destination 'platform=macOS,arch=arm64,variant=Mac Catalyst' -resultBundlePath TestResults-${{ matrix.os }}-${{ matrix.platform }} ;;
'tvOS' ) xcodebuild test -scheme ${{ env.SCHEME_NAME }} -destination 'name=${{ env.TVOS_SIMULATOR_NAME }}' -resultBundlePath TestResults-${{ matrix.os }}-${{ matrix.platform }} ;;
'watchOS' ) xcodebuild test -scheme ${{ env.SCHEME_NAME }} -destination 'name=${{ env.WATCHOS_SIMULATOR_NAME }}' -resultBundlePath TestResults-${{ matrix.os }}-${{ matrix.platform }} ;;
'visionOS' ) xcodebuild test -scheme ${{ env.SCHEME_NAME }} -destination 'name=${{ env.VISIONOS_SIMULATOR_NAME }}' -resultBundlePath TestResults-${{ matrix.os }}-${{ matrix.platform }} ;;
esac
- uses: kishikawakatsumi/xcresulttool@v1
with:
path: TestResults-${{ matrix.os }}-${{ matrix.platform }}.xcresult
title: Xcode test results (${{ matrix.os }}, ${{ matrix.platform }})
if: success() || failure()
- name: Upload Xcode DerivedData
if: always()
uses: actions/upload-artifact@v4
with:
name: Xcode DerivedData (${{ matrix.os }}, ${{ matrix.platform }})
path: |
/Users/runner/Library/Developer/Xcode/DerivedData
15 changes: 15 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"originHash" : "14ec2d40e6d0b14b593fb65cb4e9561ca4cf11bfcef82ef293579f93dc627628",
"pins" : [
{
"identity" : "taskcancellerstore",
"kind" : "remoteSourceControl",
"location" : "https://github.com/treastrain/TaskCancellerStore",
"state" : {
"revision" : "23a79d8127f68b3478a1ff21fb7219b2142e261f",
"version" : "0.1.0"
}
}
],
"version" : 3
}
63 changes: 63 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// swift-tools-version: 5.10

import PackageDescription

let package = Package(
name: "AsyncSequenceSubscription",
platforms: [
.iOS(.v13),
.macOS(.v10_15),
.macCatalyst(.v13),
.tvOS(.v13),
.watchOS(.v6),
.visionOS(.v1),
],
products: [
.library(
name: "AsyncSequenceSubscription",
targets: ["AsyncSequenceSubscription"]),
],
dependencies: [
.package(url: "https://github.com/treastrain/TaskCancellerStore", exact: "0.1.0"),
],
targets: [
.target(
name: "AsyncSequenceSubscription",
dependencies: ["TaskCancellerStore"]),
.testTarget(
name: "AsyncSequenceSubscriptionTests",
dependencies: ["AsyncSequenceSubscription"]),
]
)

// Source: https://github.com/treastrain/swift-upcomingfeatureflags-cheatsheet
extension SwiftSetting {
static let forwardTrailingClosures: Self = .enableUpcomingFeature("ForwardTrailingClosures") // SE-0286, Swift 5.3, SwiftPM 5.8+
static let existentialAny: Self = .enableUpcomingFeature("ExistentialAny") // SE-0335, Swift 5.6, SwiftPM 5.8+
static let bareSlashRegexLiterals: Self = .enableUpcomingFeature("BareSlashRegexLiterals") // SE-0354, Swift 5.7, SwiftPM 5.8+
static let conciseMagicFile: Self = .enableUpcomingFeature("ConciseMagicFile") // SE-0274, Swift 5.8, SwiftPM 5.8+
static let importObjcForwardDeclarations: Self = .enableUpcomingFeature("ImportObjcForwardDeclarations") // SE-0384, Swift 5.9, SwiftPM 5.9+
static let disableOutwardActorInference: Self = .enableUpcomingFeature("DisableOutwardActorInference") // SE-0401, Swift 5.9, SwiftPM 5.9+
static let deprecateApplicationMain: Self = .enableUpcomingFeature("DeprecateApplicationMain") // SE-0383, Swift 5.10, SwiftPM 5.10+
static let isolatedDefaultValues: Self = .enableUpcomingFeature("IsolatedDefaultValues") // SE-0411, Swift 5.10, SwiftPM 5.10+
static let globalConcurrency: Self = .enableUpcomingFeature("GlobalConcurrency") // SE-0412, Swift 5.10, SwiftPM 5.10+
static let strictConcurrency: Self = .enableExperimentalFeature("StrictConcurrency")
}

extension SwiftSetting: CaseIterable {
public static var allCases: [Self] { [
.forwardTrailingClosures,
.existentialAny,
.bareSlashRegexLiterals,
.conciseMagicFile,
.importObjcForwardDeclarations,
.disableOutwardActorInference,
.deprecateApplicationMain,
.isolatedDefaultValues,
.globalConcurrency,
.strictConcurrency,
] }
}

package.targets
.forEach { $0.swiftSettings = SwiftSetting.allCases }
Loading

0 comments on commit 12b361b

Please sign in to comment.