Skip to content

Commit

Permalink
Merge pull request #16 from PromiseKit/ci-pod-lib-lint
Browse files Browse the repository at this point in the history
Do `pod lib lint` for each Xcode
  • Loading branch information
mxcl authored Oct 7, 2018
2 parents c7989bb + 2a5941a commit c74a46d
Show file tree
Hide file tree
Showing 7 changed files with 178 additions and 96 deletions.
5 changes: 1 addition & 4 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,4 @@ parsers:
method: no
macro: no

comment:
layout: "reach, diff, flags, files, footer"
behavior: default
require_changes: no
comment: off
211 changes: 121 additions & 90 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,94 +1,125 @@
matrix:
branches:
only:
- master
stages:
- lint
- compile
- test
jobs:
include:
- {osx_image: xcode8.3, env: 'SWFT=3.1 PLAT=iOS DST="OS=10.3.1,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode8.3, env: 'SWFT=3.1 PLAT=tvOS DST="OS=10.2,name=Apple TV 1080p"', os: osx, language: objective-c}
- {osx_image: xcode8.3, env: 'SWFT=3.1 PLAT=macOS DST="arch=x86_64"', os: osx, language: objective-c}
- {osx_image: xcode8.3, env: 'SWFT=3.1 PLAT=watchOS DST="OS=3.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}
- &pod
stage: lint
osx_image: xcode8.3
env: SWIFT=3.1
name: pod lib lint --swift-version=3.1
os: osx
language: objective-c
before_install:
gem install cocoapods --prerelease --version 1.6.0.beta.1
install:
carthage bootstrap --no-build PromiseKit
script: |
cd Carthage/Checkouts/PromiseKit
mv .github/PromiseKit.podspec .
rm -rf Extensions/Foundation/Sources
cp -R ../../../Sources Extensions/Foundation
pod lib lint --subspec=PromiseKit/Foundation --fail-fast --swift-version=$SWIFT
- <<: *pod
osx_image: xcode9.2
env: SWIFT=3.2
name: pod lib lint --swift-version=3.2
- <<: *pod
osx_image: xcode9.4
env: SWIFT=3.3
name: pod lib lint --swift-version=3.3
- <<: *pod
osx_image: xcode10
env: SWIFT=3.4
name: pod lib lint --swift-version=3.4
- <<: *pod
osx_image: xcode9.2
env: SWIFT=4.0
name: pod lib lint --swift-version=4.0
- <<: *pod
osx_image: xcode9.4
env: SWIFT=4.1
name: pod lib lint --swift-version=4.1
- <<: *pod
osx_image: xcode10
env: SWIFT=4.2
name: pod lib lint --swift-version=4.2

- {osx_image: xcode9.2, env: 'SWFT=3.2 PLAT=iOS DST="OS=11.2,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=3.2 PLAT=tvOS DST="OS=11.2,name=Apple TV"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=3.2 PLAT=macOS DST="arch=x86_64"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=3.2 PLAT=watchOS DST="OS=4.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}
- &linux
stage: compile
env: SWIFT_BUILD_VERSION=3 SWIFT_VERSION=4.0
# ^^ we have some source-conditionals for this version
name: Linux / Swift 3.2.0
os: linux
dist: trusty
sudo: required
language: generic
before_install:
eval "$(curl -sL https://swiftenv.fuller.li/install.sh)"
script:
swift build -Xswiftc -swift-version -Xswiftc $SWIFT_BUILD_VERSION
- <<: *linux
env: SWIFT_BUILD_VERSION=3 SWIFT_VERSION=4.0.3
name: Linux / Swift 3.2.3
- <<: *linux
env: SWIFT_BUILD_VERSION=3 SWIFT_VERSION=4.1.2
name: Linux / Swift 3.3
- <<: *linux
env: SWIFT_BUILD_VERSION=3 SWIFT_VERSION=4.2
name: Linux / Swift 3.4
- <<: *linux
env: SWIFT_BUILD_VERSION=4 SWIFT_VERSION=4.0
name: Linux / Swift 4.0.0
# ^^ we have some source-conditionals for this version
- <<: *linux
env: SWIFT_BUILD_VERSION=4 SWIFT_VERSION=4.0.3
name: Linux / Swift 4.0.3
- <<: *linux
env: SWIFT_BUILD_VERSION=4 SWIFT_VERSION=4.1.2
name: Linux / Swift 4.1
- <<: *linux
env: SWIFT_BUILD_VERSION=4 SWIFT_VERSION=4.2
name: Linux / Swift 4.2

- {osx_image: xcode9.4, env: 'SWFT=3.3 PLAT=iOS DST="OS=11.4,name=iPhone 5s"', os: osx, language: objective-c}
- {osx_image: xcode9.4, env: 'SWFT=3.3 PLAT=tvOS DST="OS=11.4,name=Apple TV"', os: osx, language: objective-c}
- {osx_image: xcode9.3, env: 'SWFT=3.3 PLAT=macOS DST="arch=x86_64"', os: osx, language: objective-c}
- {osx_image: xcode9.3, env: 'SWFT=3.3 PLAT=watchOS DST="OS=4.3,name=Apple Watch - 38mm"', os: osx, language: objective-c}
- &swiftpm
stage: compile
name: Xcode 8.3 / SwiftPM
os: osx
osx_image: xcode8.3
language: objective-c
script: swift build
- <<: *swiftpm
name: Xcode 9.4 / SwiftPM
osx_image: xcode9.4
- <<: *swiftpm
name: Xcode 10.0 / SwiftPM
osx_image: xcode10

- {osx_image: xcode10, env: 'SWFT=3.4 PLAT=iOS DST="OS=12.0,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode10, env: 'SWFT=3.4 PLAT=tvOS DST="OS=12.0,name=Apple TV"', os: osx, language: objective-c}
- {osx_image: xcode10, env: 'SWFT=3.4 PLAT=macOS DST="arch=x86_64"', os: osx, language: objective-c}
- {osx_image: xcode10, env: 'SWFT=3.4 PLAT=watchOS DST="OS=5.0,name=Apple Watch Series 3 - 42mm"', os: osx, language: objective-c}

- {osx_image: xcode9.2, env: 'SWFT=4.0 PLAT=iOS DST="OS=11.2,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=4.0 PLAT=tvOS DST="OS=11.2,name=Apple TV"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=4.0 PLAT=macOS DST="arch=x86_64"', os: osx, language: objective-c}
- {osx_image: xcode9.2, env: 'SWFT=4.0 PLAT=watchOS DST="OS=4.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}

- {osx_image: xcode9.4, env: 'SWFT=4.1 PLAT=macOS DST="arch=x86_64" TEST=1', os: osx, language: objective-c}
- {osx_image: xcode9.4, env: 'SWFT=4.1 PLAT=iOS DST="OS=8.4,name=iPhone 4s"', os: osx, language: objective-c}
- {osx_image: xcode9.4, env: 'SWFT=4.1 PLAT=iOS DST="OS=9.3,name=iPhone 5s"', os: osx, language: objective-c}
- {osx_image: xcode9.4, env: 'SWFT=4.1 PLAT=iOS DST="OS=10.3.1,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode9.4, env: 'SWFT=4.1 PLAT=iOS DST="OS=11.4,name=iPhone 5s" TEST=1', os: osx, language: objective-c}
- {osx_image: xcode9.3, env: 'SWFT=4.1 PLAT=tvOS DST="OS=9.2,name=Apple TV 1080p"', os: osx, language: objective-c}
- {osx_image: xcode9.3, env: 'SWFT=4.1 PLAT=tvOS DST="OS=10.2,name=Apple TV 1080p"', os: osx, language: objective-c}
- {osx_image: xcode9.4, env: 'SWFT=4.1 PLAT=tvOS DST="OS=11.4,name=Apple TV" TEST=1', os: osx, language: objective-c}
- {osx_image: xcode9.3, env: 'SWFT=4.1 PLAT=watchOS DST="OS=2.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}
- {osx_image: xcode9.3, env: 'SWFT=4.1 PLAT=watchOS DST="OS=3.2,name=Apple Watch - 38mm"', os: osx, language: objective-c}
- {osx_image: xcode9.4, env: 'SWFT=4.1 PLAT=watchOS DST="OS=4.3,name=Apple Watch - 38mm"', os: osx, language: objective-c}

- {osx_image: xcode10, env: 'SWFT=4.3 PLAT=iOS DST="OS=12.0,name=iPhone SE"', os: osx, language: objective-c}
- {osx_image: xcode10, env: 'SWFT=4.3 PLAT=tvOS DST="OS=12.0,name=Apple TV"', os: osx, language: objective-c}
- {osx_image: xcode10, env: 'SWFT=4.3 PLAT=macOS DST="arch=x86_64"', os: osx, language: objective-c}
- {osx_image: xcode10, env: 'SWFT=4.3 PLAT=watchOS DST="OS=5.0,name=Apple Watch Series 3 - 42mm"', os: osx, language: objective-c}

# Swift 3.2.0 (we have some source-conditionals for this version)
- {os: linux, dist: trusty, sudo: required, language: generic, env: 'SWIFT_BUILD_VERSION=3 SWIFT_VERSION=4.0'}
# Swift 3.2.3
- {os: linux, dist: trusty, sudo: required, language: generic, env: 'SWIFT_BUILD_VERSION=3 SWIFT_VERSION=4.0.3'}
# Swift 3.3
- {os: linux, dist: trusty, sudo: required, language: generic, env: 'SWIFT_BUILD_VERSION=3 SWIFT_VERSION=4.1.2 TEST=1'}
# Swift 3.4
- {os: linux, dist: trusty, sudo: required, language: generic, env: 'SWIFT_BUILD_VERSION=3 SWIFT_VERSION=DEVELOPMENT-SNAPSHOT-2018-06-20-a TEST=1'}
# Swift 4.0.0 (we have some source-conditionals for this version)
- {os: linux, dist: trusty, sudo: required, language: generic, env: 'SWIFT_BUILD_VERSION=4 SWIFT_VERSION=4.0'}
# Swift 4.0.3
- {os: linux, dist: trusty, sudo: required, language: generic, env: 'SWIFT_BUILD_VERSION=4 SWIFT_VERSION=4.0.3'}
# Swift 4.1
- {os: linux, dist: trusty, sudo: required, language: generic, env: 'SWIFT_BUILD_VERSION=4 SWIFT_VERSION=4.1.2 TEST=1'}
# Swift 4.2
- {os: linux, dist: trusty, sudo: required, language: generic, env: 'SWIFT_BUILD_VERSION=4 SWIFT_VERSION=DEVELOPMENT-SNAPSHOT-2018-06-20-a TEST=1'}

cache:
directories:
- Carthage
before_install:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
carthage bootstrap --cache-builds --no-use-binaries --platform $PLAT --verbose;
else
eval "$(curl -sL https://swiftenv.fuller.li/install.sh)";
swift --version;
fi
install:
- case $PLAT in
macOS|tvOS|iOS|watchOS)
xcodebuild -scheme PMKFoundation -target PMKFoundation -quiet -destination "$DST" SWIFT_VERSION=$SWFT SWIFT_TREAT_WARNINGS_AS_ERRORS=YES build;
if [[ $TEST == "1" ]]; then
xcodebuild -scheme PMKFoundation -target PMKNSTests -quiet -destination "$DST" SWIFT_TREAT_WARNINGS_AS_ERRORS=YES build;
fi;;
*)
swift build -Xswiftc -swift-version -Xswiftc $SWIFT_BUILD_VERSION;;
esac
script:
- case $PLAT in
macOS|tvOS|iOS)
if [[ $TEST == "1" ]]; then
xcodebuild -scheme PMKFoundation -destination "$DST" test -enableCodeCoverage YES;
fi;;
*)
;;
esac
after_success:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
bash <(curl -s https://codecov.io/bash);
fi
- &test
stage: test
osx_image: xcode10
name: macOS Tests
env: DST='arch=x86_64' PLAT=macOS
os: osx
language: objective-c
cache:
directories:
- Carthage
before_install:
carthage bootstrap --cache-builds --no-use-binaries --platform $PLAT
install:
xcodebuild -scheme PMKFoundation -target PMKFoundation -quiet -destination "$DST" SWIFT_TREAT_WARNINGS_AS_ERRORS=YES build
script:
xcodebuild -scheme PMKFoundation -quiet -destination "$DST" test
after_success:
bash <(curl -s https://codecov.io/bash);
- <<: *test
env: DST='OS=12.0,name=iPhone SE' PLAT=iOS
name: iOS Tests
- <<: *test
env: DST='OS=12.0,name=Apple TV' PLAT=tvOS
name: tvOS Tests
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "AliSoftware/OHHTTPStubs" "6.1.0"
github "mxcl/PromiseKit" "6.3.4"
github "mxcl/PromiseKit" "6.5.0"
16 changes: 16 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"object": {
"pins": [
{
"package": "PromiseKit",
"repositoryURL": "https://github.com/mxcl/PromiseKit.git",
"state": {
"branch": null,
"revision": "9e5bc43281cae89ab0b6e47df3ea25a2c44af7f0",
"version": "6.5.0"
}
}
]
},
"version": 1
}
32 changes: 32 additions & 0 deletions Package@swift-4.2.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// swift-tools-version:4.2

import PackageDescription

let pkg = Package(name: "PMKFoundation")
pkg.products = [
.library(name: "PMKFoundation", targets: ["PMKFoundation"]),
]
pkg.dependencies = [
.package(url: "https://github.com/mxcl/PromiseKit.git", .upToNextMajor(from: "6.0.0"))
]
pkg.swiftLanguageVersions = [.v3, .v4, .v4_2]

let target: Target = .target(name: "PMKFoundation")
target.path = "Sources"
target.exclude = ["NSNotificationCenter", "NSTask", "NSURLSession"].flatMap {
["\($0)+AnyPromise.m", "\($0)+AnyPromise.h"]
}
target.exclude.append("PMKFoundation.h")

target.dependencies = [
"PromiseKit"
]

#if os(Linux)
target.exclude += [
"afterlife.swift",
"NSObject+Promise.swift"
]
#endif

pkg.targets = [target]
6 changes: 5 additions & 1 deletion Sources/NSTask+AnyPromise.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ - (AnyPromise *)promise {
resolve([NSError errorWithDomain:PMKErrorDomain code:PMKTaskError userInfo:info]);
}
};


#if __clang_major__ >= 9
if (@available(macOS 10.13, *)) {
NSError *error = nil;

Expand All @@ -47,6 +48,9 @@ - (AnyPromise *)promise {
} else {
[self launch];
}
#else
[self launch]; // might @throw
#endif
}];
}

Expand Down
2 changes: 2 additions & 0 deletions Sources/NSURLSession+Promise.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,14 @@ public enum PMKHTTPError: Error, LocalizedError, CustomStringConvertible {
}
}

#if swift(>=4.0)
public func decodeResponse<T: Decodable>(_ t: T.Type, decoder: JSONDecoder = JSONDecoder()) -> T? {
switch self {
case .badStatusCode(_, let data, _):
return try? decoder.decode(t, from: data)
}
}
#endif

//TODO rename responseJSON
public var jsonDictionary: Any? {
Expand Down

0 comments on commit c74a46d

Please sign in to comment.