Noncopyable JSON Views #127
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: test | |
| on: | |
| pull_request: | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| test-linux: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| image: | |
| - swift:6.2 | |
| - swiftlang/swift:nightly-6.3-jammy | |
| runs-on: ubuntu-latest | |
| container: ${{ matrix.image }} | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v2 | |
| - name: Run tests | |
| run: swift test -c release | |
| test-macos: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| xcode: | |
| - latest | |
| - latest-stable | |
| runs-on: macos-latest | |
| steps: | |
| - name: Select toolchain | |
| uses: maxim-lobanov/setup-xcode@v1 | |
| with: | |
| xcode-version: ${{ matrix.xcode }} | |
| - name: Check out | |
| uses: actions/checkout@v2 | |
| - name: Run tests | |
| run: swift test -c release | |
| test-embedded: | |
| runs-on: ubuntu-latest | |
| container: swiftlang/swift:nightly-main-jammy | |
| steps: | |
| - name: Check out | |
| uses: actions/checkout@v2 | |
| - name: Build for Embedded Swift | |
| run: swift build -c release --target _JSONCore -Xswiftc -enable-experimental-feature -Xswiftc Embedded -Xswiftc -wmo | |
| # Regression test for https://github.com/orlandos-nl/IkigaJSON/issues/59 | |
| # Verifies that a downstream package can depend on both swift-nio and IkigaJSON | |
| # without module resolution failures (e.g. _AtomicsShims not found) | |
| test-downstream-integration: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| image: | |
| - swift:6.2 | |
| - swiftlang/swift:nightly-6.3-jammy | |
| runs-on: ubuntu-latest | |
| container: ${{ matrix.image }} | |
| steps: | |
| - name: Check out IkigaJSON | |
| uses: actions/checkout@v2 | |
| with: | |
| path: IkigaJSON | |
| - name: Create downstream package (NIO + IkigaJSON) | |
| run: | | |
| mkdir downstream-test | |
| cat > downstream-test/Package.swift << 'PKGEOF' | |
| // swift-tools-version: 6.2 | |
| import PackageDescription | |
| let package = Package( | |
| name: "DownstreamTest", | |
| dependencies: [ | |
| .package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0"), | |
| .package(path: "../IkigaJSON"), | |
| ], | |
| targets: [ | |
| .executableTarget( | |
| name: "DownstreamTest", | |
| dependencies: [ | |
| .product(name: "NIOCore", package: "swift-nio"), | |
| .product(name: "IkigaJSON", package: "IkigaJSON"), | |
| ] | |
| ) | |
| ] | |
| ) | |
| PKGEOF | |
| mkdir -p downstream-test/Sources/DownstreamTest | |
| cat > downstream-test/Sources/DownstreamTest/main.swift << 'SRCEOF' | |
| import NIOCore | |
| import IkigaJSON | |
| struct Point: Decodable { let x: Int; let y: Int } | |
| let decoder = IkigaJSONDecoder() | |
| let buffer = ByteBuffer(string: #"{"x":1,"y":2}"#) | |
| let point = try decoder.decode(Point.self, from: buffer) | |
| assert(point.x == 1 && point.y == 2) | |
| print("OK") | |
| SRCEOF | |
| - name: Build downstream package (ByteBufferSupport enabled, default) | |
| run: cd downstream-test && swift build -c release | |
| - name: Create downstream package (no ByteBufferSupport) | |
| run: | | |
| mkdir downstream-test-no-nio | |
| cat > downstream-test-no-nio/Package.swift << 'PKGEOF' | |
| // swift-tools-version: 6.2 | |
| import PackageDescription | |
| let package = Package( | |
| name: "DownstreamTestNoNIO", | |
| dependencies: [ | |
| .package(path: "../IkigaJSON"), | |
| ], | |
| targets: [ | |
| .executableTarget( | |
| name: "DownstreamTestNoNIO", | |
| dependencies: [ | |
| .product(name: "IkigaJSON", package: "IkigaJSON"), | |
| ] | |
| ) | |
| ] | |
| ) | |
| PKGEOF | |
| mkdir -p downstream-test-no-nio/Sources/DownstreamTestNoNIO | |
| cat > downstream-test-no-nio/Sources/DownstreamTestNoNIO/main.swift << 'SRCEOF' | |
| import Foundation | |
| import IkigaJSON | |
| struct Point: Decodable { let x: Int; let y: Int } | |
| let decoder = IkigaJSONDecoder() | |
| let data = Data(#"{"x":1,"y":2}"#.utf8) | |
| let point = try decoder.decode(Point.self, from: data) | |
| assert(point.x == 1 && point.y == 2) | |
| print("OK") | |
| SRCEOF | |
| - name: Build downstream package (ByteBufferSupport disabled) | |
| run: cd downstream-test-no-nio && swift build -c release |