Skip to content

Commit

Permalink
Merge pull request #18 from brightdigit/v1.0.0-beta.3
Browse files Browse the repository at this point in the history
1.0.0 beta.3
  • Loading branch information
leogdion authored Oct 18, 2024
2 parents 54c727e + a52d63a commit 9c0d6f1
Show file tree
Hide file tree
Showing 18 changed files with 356 additions and 226 deletions.
92 changes: 61 additions & 31 deletions .github/workflows/FelinePine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
strategy:
matrix:
runs-on: [ubuntu-20.04, ubuntu-22.04]
swift-version: [5.8.1, 5.9, "5.10"]
swift-version: [5.8.1, 5.9, "5.10", "6.0.1"]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Cache swift package modules
id: cache-spm-linux
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: SPM
with:
Expand All @@ -37,7 +37,7 @@ jobs:
run: echo "RELEASE_NAME=$(lsb_release -sc)" >> $GITHUB_ENV
- name: Cache swift
id: cache-swift-linux
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: swift
with:
Expand All @@ -55,17 +55,23 @@ jobs:
run: swift build
- name: Run tests
run: swift test --enable-test-discovery --enable-code-coverage
- name: Prepare Code Coverage
run: llvm-cov export -format="lcov" .build/x86_64-unknown-linux-gnu/debug/${{ env.PACKAGE_NAME }}PackageTests.xctest -instr-profile .build/debug/codecov/default.profdata > info.lcov
- name: Upload to CodeCov.io
run: bash <(curl https://codecov.io/bash) -F spm -F ${RELEASE_NAME} -F ${SWIFT_VER}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- uses: sersoft-gmbh/swift-coverage-action@v4
id: coverage-files
with:
fail-on-empty-output: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
flags: swift-${{ matrix.swift-version }},ubuntu
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ join(fromJSON(steps.coverage-files.outputs.files), ',') }}
build-macos:
name: Build on macOS
env:
PACKAGE_NAME: FelinePine
runs-on: macos-13
runs-on: ${{ matrix.runs-on }}
if: "!contains(github.event.head_commit.message, 'ci skip')"
strategy:
matrix:
Expand Down Expand Up @@ -94,11 +100,17 @@ jobs:
watchOSVersion: "10.2"
watchName: "Apple Watch Series 9 (45mm)"
iPhoneName: "iPhone 15 Pro"
- runs-on: macos-15
xcode: "/Applications/Xcode_16.1.app"
iOSVersion: "18.0"
watchOSVersion: "11.0"
watchName: "Apple Watch Series 10 (42mm)"
iPhoneName: "iPhone 16"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Cache swift package modules
id: cache-spm-macos
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-spm
with:
Expand All @@ -109,9 +121,9 @@ jobs:
${{ runner.os }}-build-
${{ runner.os }}-
- name: Cache mint
if: ${{ github.event_name == 'pull_request' && ( github.base_ref == 'main' || endsWith( github.ref_name , 'Prep') ) && matrix.xcode == '/Applications/Xcode_15.0.1.app' }}
if: ${{ github.event_name == 'pull_request' && ( github.base_ref == 'main' || endsWith( github.ref_name , 'Prep') ) && matrix.xcode == '/Applications/Xcode_16.1.app' }}
id: cache-mint
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cache-mint
with:
Expand All @@ -126,24 +138,29 @@ jobs:
- name: Setup Xcode
run: sudo xcode-select -s ${{ matrix.xcode }}/Contents/Developer
- name: Install mint
if: ${{ github.event_name == 'pull_request' && ( github.base_ref == 'main' || endsWith( github.ref_name , 'Prep') ) && matrix.xcode == '/Applications/Xcode_15.0.1.app' }}
if: ${{ github.event_name == 'pull_request' && ( github.base_ref == 'main' || endsWith( github.ref_name , 'Prep') ) && matrix.xcode == '/Applications/Xcode_16.1.app' }}
run: |
brew update
brew install mint
- name: Build
run: swift build
- name: Run Swift Package tests
run: swift test -v --enable-code-coverage
run: swift test -v --enable-code-coverage
- uses: sersoft-gmbh/swift-coverage-action@v4
- name: Upload SPM to CodeCov.io
run: bash <(curl https://codecov.io/bash) -F spm -F macOS -F ${XCODE_NAME}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
id: coverage-files-spm
with:
fail-on-empty-output: true
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
files: ${{ join(fromJSON(steps.coverage-files-spm.outputs.files), ',') }}
token: ${{ secrets.CODECOV_TOKEN }}
flags: macOS,${{ env.XCODE_NAME }},${{ matrix.runs-on }}
- name: Clean up spm build directory
run: rm -rf .build
- name: Lint
run: ./scripts/lint.sh
if: ${{ github.event_name == 'pull_request' && ( github.base_ref == 'main' || endsWith( github.ref_name , 'Prep') ) && matrix.xcode == '/Applications/Xcode_15.0.1.app' }}
if: ${{ github.event_name == 'pull_request' && ( github.base_ref == 'main' || endsWith( github.ref_name , 'Prep') ) && matrix.xcode == '/Applications/Xcode_16.1.app' }}
- name: Dump PIF
if: startsWith(matrix.xcode,'/Applications/Xcode_14')
run: |
Expand All @@ -157,15 +174,28 @@ jobs:
- name: Run iOS target tests
run: xcodebuild test -scheme FelinePine -sdk iphonesimulator -destination 'platform=iOS Simulator,name=${{ matrix.iPhoneName }},OS=${{ matrix.iOSVersion }}' -enableCodeCoverage YES build test
- uses: sersoft-gmbh/swift-coverage-action@v4
- name: Upload iOS Coverage to CodeCov.io
run: bash <(curl https://codecov.io/bash) -F iOS -F iOS${{ matrix.iOSVersion }} -F macOS -F ${XCODE_NAME}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
id: coverage-files-iOS
with:
fail-on-empty-output: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ join(fromJSON(steps.coverage-files-iOS.outputs.files), ',') }}
flags: iOS,iOS${{ matrix.iOSVersion }},macOS,${{ env.XCODE_NAME }}
- name: Run watchOS target tests
run: xcodebuild test -scheme FelinePine -sdk watchsimulator -destination 'platform=watchOS Simulator,name=${{ matrix.watchName }},OS=${{ matrix.watchOSVersion }}' -enableCodeCoverage YES build test
- uses: sersoft-gmbh/swift-coverage-action@v4
- name: Upload watchOS Coverage to CodeCov.io
run: bash <(curl https://codecov.io/bash) -F watchOS -F watchOS${{ matrix.watchOSVersion }} -F macOS -F ${XCODE_NAME}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
token: ${{ secrets.CODECOV_TOKEN }}
id: coverage-files-watchOS
with:
fail-on-empty-output: true
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ join(fromJSON(steps.coverage-files-watchOS.outputs.files), ',') }}
flags: watchOS,watchOS${{ matrix.watchOSVersion }},macOS,${{ env.XCODE_NAME }}
14 changes: 0 additions & 14 deletions Package.resolved

This file was deleted.

10 changes: 0 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,9 @@ let package = Package(
targets: ["FelinePine"]
)
],
dependencies: [
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0")
],
targets: [
.target(
name: "FelinePine",
dependencies: [
.product(
name: "Logging",
package: "swift-log",
condition: .when(platforms: [.linux, .android, .wasi, .windows])
)
],
swiftSettings: [
SwiftSetting.enableUpcomingFeature("BareSlashRegexLiterals"),
SwiftSetting.enableUpcomingFeature("ConciseMagicFile"),
Expand Down
51 changes: 51 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// swift-tools-version: 6.0
// swiftlint:disable explicit_acl explicit_top_level_acl

import PackageDescription

let swiftSettings: [SwiftSetting] = [
SwiftSetting.enableExperimentalFeature("AccessLevelOnImport"),
SwiftSetting.enableExperimentalFeature("BitwiseCopyable"),
SwiftSetting.enableExperimentalFeature("GlobalActorIsolatedTypesUsability"),
SwiftSetting.enableExperimentalFeature("IsolatedAny"),
SwiftSetting.enableExperimentalFeature("MoveOnlyPartialConsumption"),
SwiftSetting.enableExperimentalFeature("NestedProtocols"),
SwiftSetting.enableExperimentalFeature("NoncopyableGenerics"),
SwiftSetting.enableExperimentalFeature("RegionBasedIsolation"),
SwiftSetting.enableExperimentalFeature("TransferringArgsAndResults"),
SwiftSetting.enableExperimentalFeature("VariadicGenerics"),

SwiftSetting.enableUpcomingFeature("FullTypedThrows"),
SwiftSetting.enableUpcomingFeature("InternalImportsByDefault")

// SwiftSetting.unsafeFlags([
// "-Xfrontend",
// "-warn-long-function-bodies=100"
// ]),
// SwiftSetting.unsafeFlags([
// "-Xfrontend",
// "-warn-long-expression-type-checking=100"
// ])
]

let package = Package(
name: "FelinePine",
platforms: [.iOS(.v14), .watchOS(.v7), .macOS(.v11)],
products: [
.library(
name: "FelinePine",
targets: ["FelinePine"]
)
],
targets: [
.target(
name: "FelinePine",
swiftSettings: swiftSettings
),
.testTarget(
name: "FelinePineTests",
dependencies: ["FelinePine"]
)
]
)
// swiftlint:enable explicit_acl explicit_top_level_acl
Binary file modified Sources/FelinePine/Documentation.docc/Resources/FelinePine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Sources/FelinePine/Documentation.docc/Resources/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Sources/FelinePine/Documentation.docc/Resources/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 19 additions & 8 deletions Sources/FelinePine/Feline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,19 @@
//

import Foundation
#if canImport(os)
import os

#if swift(<6.0)
#if canImport(os)
import os
#elseif canImport(Logging)
import Logging
#endif
#else
import Logging
#if canImport(os)
public import os
#elseif canImport(Logging)
public import Logging
#endif
#endif

/// Defines the ``LoggingSystem`` to use as well as the category.
Expand All @@ -45,9 +54,11 @@ public protocol Feline {
}
}

extension Feline where Self: Pine {
/// Use the ``loggingCategory`` to define the shared logger for type.
public static var logger: Logger {
LoggingSystemType.logger(forCategory: loggingCategory)
#if canImport(os) || canImport(Logging)
extension Feline where Self: Pine {
/// Use the ``loggingCategory`` to define the shared logger for type.
public static var logger: Logger {
LoggingSystemType.logger(forCategory: loggingCategory)
}
}
}
#endif
8 changes: 7 additions & 1 deletion Sources/FelinePine/Loggable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@

import Foundation

#if canImport(os) || canImport(Logging)
public typealias FelinePineProtocol = Feline & Pine
#else
public typealias FelinePineProtocol = Feline
#endif

/// Loggable type for a ``LoggingSystem``.
public protocol Loggable<LoggingSystemType>: Feline, Pine
public protocol Loggable<LoggingSystemType>: FelinePineProtocol
where LoggingSystemType: LoggingSystem {}
41 changes: 25 additions & 16 deletions Sources/FelinePine/Logger+LoggerCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,32 @@
// OTHER DEALINGS IN THE SOFTWARE.
//

import Foundation
#if canImport(os)
import os
#if swift(<6.0)
#if canImport(os)
import os
#elseif canImport(Logging)
import Logging
#endif
#else
import Logging
#if canImport(os)
public import os
#elseif canImport(Logging)
public import Logging
#endif
#endif

extension Logger {
internal init<Category: RawRepresentable>(
subsystem: String,
category: Category
) where Category.RawValue == String {
#if canImport(os)
self.init(subsystem: subsystem, category: category.rawValue)
#else
self.init(label: subsystem)
self[metadataKey: "category"] = "\(category)"
#endif
#if canImport(os) || canImport(Logging)
extension Logger {
internal init<Category: RawRepresentable>(
subsystem: String,
category: Category
) where Category.RawValue == String {
#if canImport(os)
self.init(subsystem: subsystem, category: category.rawValue)
#else
self.init(label: subsystem)
self[metadataKey: "category"] = "\(category)"
#endif
}
}
}
#endif
19 changes: 15 additions & 4 deletions Sources/FelinePine/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,24 @@
//

// swiftlint:disable file_types_order
#if swift(<6.0)
#if canImport(os)
import os
#elseif canImport(Logging)
import Logging
#endif
#else
#if canImport(os)
public import os
#elseif canImport(Logging)
public import Logging
#endif
#endif

#if canImport(os)
import os.log
/// Standard os.log Logger
/// os.Logger
public typealias Logger = os.Logger
#else
import Logging
#elseif canImport(Logging)
/// swift-log Logging.Logger
public typealias Logger = Logging.Logger
#endif
Expand Down
Loading

0 comments on commit 9c0d6f1

Please sign in to comment.