diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 0000000..431d872 --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,37 @@ +name: Android CI + +on: [push] + +jobs: + build: + + runs-on: macOS-latest + + steps: + - uses: actions/checkout@v1 + - name: Install Swift toolchain 5.0.3 + run: wget https://swift.org/builds/swift-5.0.3-release/xcode/swift-5.0.3-RELEASE/swift-5.0.3-RELEASE-osx.pkg; + sudo installer -pkg swift-5.0.3-RELEASE-osx.pkg -target / + - name: Install NDK + run: wget https://dl.google.com/android/repository/android-ndk-r17c-darwin-x86_64.zip; + unzip android-ndk-r17c-darwin-x86_64.zip + - name: Install Swift Android Toolchain + run: SWIFT_ANDROID=$(curl -fsSL https://api.bintray.com/packages/readdle/swift-android-toolchain/swift-android-toolchain/versions/_latest | python -c 'import json,sys;print(json.load(sys.stdin))["name"]'); + wget https://dl.bintray.com/readdle/swift-android-toolchain/swift-android-$SWIFT_ANDROID.zip; + unzip swift-android-$SWIFT_ANDROID.zip; + swift-android-$SWIFT_ANDROID/bin/swift-android tools --update; + ln -sfn swift-android-$SWIFT_ANDROID swift-android-current + - name: Download Android Emulator + run: $ANDROID_HOME/tools/bin/sdkmanager "system-images;android-29;google_apis;x86_64" + - name: Create Android Emulator + run: $ANDROID_HOME/tools/bin/avdmanager create avd -n ci-test -k "system-images;android-29;google_apis;x86_64" -d "pixel" + - name: Start Android Emulator + run: $ANDROID_HOME/emulator/emulator-headless -avd ci-test -noaudio > /dev/null & + - name: Run swift build for Android + run: export TOOLCHAINS=org.swift.50320190830a; + export ANDROID_NDK_HOME=$(pwd)/android-ndk-r17c; + export SWIFT_ANDROID_HOME=$(pwd)/swift-android-current; + export PATH=$ANDROID_NDK_HOME:$PATH; + export PATH=$SWIFT_ANDROID_HOME/bin:$SWIFT_ANDROID_HOME/build-tools/current:$PATH; + adb wait-for-device; + SWIFT_ANDROID_ARCH=x86_64 swift-test diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..640deff --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,17 @@ +name: Public interface and LinuxMain checks + +on: [push] + +jobs: + build: + + runs-on: macOS-latest + + steps: + - uses: actions/checkout@v1 + - name: Generate new public interface + run: swift build -Xswiftc -emit-parseable-module-interface-path -Xswiftc AnyCodable.swiftinterface + - name: Generate LinuxMain + run: brew install sourcery; sourcery + - name: Check unstaged changes in git repo + run: git diff --exit-code \ No newline at end of file diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml new file mode 100644 index 0000000..486e5c2 --- /dev/null +++ b/.github/workflows/linux.yml @@ -0,0 +1,12 @@ +name: Linux CI + +on: [push] + +jobs: + test: + runs-on: ubuntu-18.04 + container: swift:latest + steps: + - uses: actions/checkout@v1 + - name: Test + run: swift test \ No newline at end of file diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 0000000..4540cfa --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,13 @@ +name: macOS CI + +on: [push] + +jobs: + build: + + runs-on: macOS-latest + + steps: + - uses: actions/checkout@v1 + - name: test AnyCodable package + run: swift test diff --git a/.gitignore b/.gitignore index 1c1373a..24e5b0a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ .build -LinuxMain.swift diff --git a/AnyCodable.swiftinterface b/AnyCodable.swiftinterface new file mode 100644 index 0000000..4615657 --- /dev/null +++ b/AnyCodable.swiftinterface @@ -0,0 +1,21 @@ +// swift-interface-format-version: 1.0 +// swift-tools-version: Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5) +// swift-module-flags: -target x86_64-apple-macosx10.10 -enable-objc-interop -swift-version 5 -Onone -module-name AnyCodable +import Foundation +public struct AnyCodable : Codable { + @_hasInitialValue public static var ArrayTypeName: Swift.String + @_hasInitialValue public static var SetTypeName: Swift.String + @_hasInitialValue public static var DictionaryTypeName: Swift.String + public static func RegisterType(_ type: T.Type) where T : Decodable, T : Encodable + public let typeName: Swift.String + public let value: Any + @available(*, deprecated, renamed: "init(optionalValue:)", message: "Use explicit init(optionalValue:)") + public init?(value: Codable?) throws + public init?(optionalValue: Codable?) throws + public init(value: Codable) throws + public init(value: Swift.Array) throws + public init(value: Swift.Dictionary) throws + public init(value: Swift.Set) throws + public init(from decoder: Decoder) throws + public func encode(to encoder: Encoder) throws +} diff --git a/LinuxMain.swift b/LinuxMain.swift new file mode 100644 index 0000000..64be5cd --- /dev/null +++ b/LinuxMain.swift @@ -0,0 +1,21 @@ +// Generated using Sourcery 0.17.0 — https://github.com/krzysztofzablocki/Sourcery +// DO NOT EDIT + + +import XCTest +@testable import AnyCodableTests + +extension AnyCodableTests { + static var allTests = [ + ("testDictionary", testDictionary), + ("testArray", testArray), + ("testSet", testSet), + ("testTwoDimensionalArray", testTwoDimensionalArray), + ("testUnregistredEncodingDecoding", testUnregistredEncodingDecoding), + ] +} + + +XCTMain([ + testCase(AnyCodableTests.allTests), +])