From 8eeca20b0cca720b941a373809f4203f7da2fe5e Mon Sep 17 00:00:00 2001 From: Chenfeng Yao <282696845@qq.com> Date: Sat, 24 Aug 2024 21:34:25 +0800 Subject: [PATCH] add github action (#2) --- .github/workflows/swift.yml | 24 ++++++++++++++++++++++++ Sources/DFService/utils/Runtime.swift | 6 +++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/swift.yml diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml new file mode 100644 index 0000000..42e39ba --- /dev/null +++ b/.github/workflows/swift.yml @@ -0,0 +1,24 @@ +# This workflow will build a Swift project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift + +name: Swift + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + name: Swift ${{ matrix.swift }} on ${{ matrix.os }} + strategy: + matrix: + os: [macos-12,macos-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Build + run: swift build + - name: Run tests + run: swift test diff --git a/Sources/DFService/utils/Runtime.swift b/Sources/DFService/utils/Runtime.swift index 9b2890e..079d0b8 100644 --- a/Sources/DFService/utils/Runtime.swift +++ b/Sources/DFService/utils/Runtime.swift @@ -11,7 +11,11 @@ public extension DF.Runtime { return ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" } var isRunningInTests: Bool { - return ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] != nil + #if canImport(XCTest) + return true + #else + return false + #endif } }