Skip to content

Commit

Permalink
Merge remote-tracking branch 'public_origin/main' into ensemble_auto_…
Browse files Browse the repository at this point in the history
…update_905887811fd911f60b36873a960d88c2bc435517
  • Loading branch information
stash-iossdk-svc committed Oct 27, 2023
2 parents 898284b + 9058878 commit e451701
Show file tree
Hide file tree
Showing 15 changed files with 126 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.2.1
6.4.0rc2
2 changes: 1 addition & 1 deletion .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
Linux:
strategy:
matrix:
tag: ['5.4', '5.5', '5.6', '5.7', '5.8']
tag: ['5.4', '5.5', '5.6', '5.7', '5.8', '5.9']
runs-on: ubuntu-latest
container:
image: swift:${{ matrix.tag }}-focal
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
CMake:
strategy:
matrix:
xcode_version: ['14.2', '14.3']
xcode_version: ['14.2', '14.3', '15.0']
runs-on: macos-13
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app
Expand All @@ -42,7 +42,7 @@ jobs:
CMake_Linux:
strategy:
matrix:
tag: ['5.6', '5.7', '5.8']
tag: ['5.6', '5.7', '5.8', '5.9']
runs-on: ubuntu-latest
container:
image: swift:${{ matrix.tag }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/jazzy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ on:

jobs:
Jazzy:
runs-on: macos-12
runs-on: macos-13
env:
DEVELOPER_DIR: /Applications/Xcode_14.2.app
DEVELOPER_DIR: /Applications/Xcode_15.0.app
steps:
- uses: actions/checkout@v3
- name: Install SourceKitten
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
SwiftLint:
runs-on: ubuntu-latest
container:
image: ghcr.io/realm/swiftlint:0.51.0
image: ghcr.io/realm/swiftlint:0.53.0
steps:
- uses: actions/checkout@v3
- name: SwiftLint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/swiftlint_analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
Analyze:
runs-on: macos-13
env:
DEVELOPER_DIR: /Applications/Xcode_14.3.app
DEVELOPER_DIR: /Applications/Xcode_15.0.app
steps:
- uses: actions/checkout@v3
- name: Generate xcodebuild.log
Expand Down
17 changes: 15 additions & 2 deletions .github/workflows/swiftpm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,21 @@ jobs:
- run: swift -version
- run: YAMS_DEFAULT_ENCODING=UTF16 swift test --parallel
- run: YAMS_DEFAULT_ENCODING=UTF8 swift test --parallel

Xcode_Ventura:
strategy:
matrix:
xcode_version: ['14.3', '15.0']
runs-on: macos-13
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app
steps:
- uses: actions/checkout@v3
- run: swift -version
- run: YAMS_DEFAULT_ENCODING=UTF16 swift test --parallel
- run: YAMS_DEFAULT_ENCODING=UTF8 swift test --parallel
- name: Code Coverage
if: matrix.xcode_version == '14.2'
if: matrix.xcode_version == '15.0'
run: |
swift test --enable-code-coverage
xcrun llvm-cov export -format="lcov" .build/debug/YamsPackageTests.xctest/Contents/MacOS/YamsPackageTests -instr-profile .build/debug/codecov/default.profdata > coverage.lcov
Expand All @@ -62,7 +75,7 @@ jobs:
Linux:
strategy:
matrix:
tag: ['5.4', '5.5', '5.6', '5.7']
tag: ['5.4', '5.5', '5.6', '5.7', '5.8', '5.9']
runs-on: ubuntu-latest
container:
image: swift:${{ matrix.tag }}
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/xcodebuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,37 @@ jobs:
if: always()
run: xcodebuild ${{ matrix.xcode_flags }} build -sdk watchsimulator | xcpretty
shell: bash

xcodebuild_Ventura:
strategy:
matrix:
xcode:
- version: '14.3'
- version: '15.0'
xcode_flags: ['-scheme Yams -project Yams.xcodeproj']
runs-on: macos-13
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode.version }}.app
steps:
- uses: actions/checkout@v3
- run: xcodebuild -version
- name: macOS with UTF16
if: always()
run: YAMS_DEFAULT_ENCODING=UTF16 xcodebuild ${{ matrix.xcode_flags }} test | xcpretty
shell: bash
- name: macOS with UTF8
if: always()
run: YAMS_DEFAULT_ENCODING=UTF8 xcodebuild ${{ matrix.xcode_flags }} test | xcpretty
shell: bash
- name: iPhone Simulator
if: always()
run: xcodebuild ${{ matrix.xcode_flags }} test -sdk iphonesimulator -destination "name=iPhone 8" | xcpretty
shell: bash
- name: Apple TV Simulator
if: always()
run: xcodebuild ${{ matrix.xcode_flags }} test -sdk appletvsimulator -destination "name=Apple TV 4K (2nd generation)" | xcpretty
shell: bash
- name: watchOS Simulator
if: always()
run: xcodebuild ${{ matrix.xcode_flags }} build -sdk watchsimulator | xcpretty
shell: bash
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

##### Breaking

* None.
* Change how empty strings are decoded into nullable properties.
`key: ""` previously decoded into
`struct Value: Codable { let key: String? }` as `Value(key: nil)`
whereas after this change it decodes as `Value(key: "")`.
This could be a breaking change if you were relying on the previous
semantics.
[Liam Nichols](https://github.com/liamnichols)
[#301](https://github.com/jpsim/Yams/issues/301)

##### Enhancements

Expand Down
6 changes: 3 additions & 3 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module(
compatibility_level = 1,
)

bazel_dep(name = "rules_swift", version = "1.8.0", repo_name = "build_bazel_rules_swift")
bazel_dep(name = "rules_swift", version = "1.12.0", repo_name = "build_bazel_rules_swift")

bazel_dep(name = "platforms", version = "0.0.6", dev_dependency = True)
bazel_dep(name = "rules_apple", version = "2.3.0", dev_dependency = True)
bazel_dep(name = "platforms", version = "0.0.7", dev_dependency = True)
bazel_dep(name = "rules_apple", version = "3.0.0", dev_dependency = True)
4 changes: 4 additions & 0 deletions Sources/Yams/Constructor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,10 @@ extension NSNull/*: ScalarConstructible*/ {
///
/// - returns: An instance of `NSNull`, if one was successfully extracted from the scalar.
public static func construct(from scalar: Node.Scalar) -> NSNull? {
// When constructing from a Scalar, only plain style scalars should be recognized.
// For example #"key: 'null'"# or #"key: ''"# should not be considered as null.
guard case .plain = scalar.style else { return nil }

switch scalar.string {
case "", "~", "null", "Null", "NULL":
return NSNull()
Expand Down
10 changes: 7 additions & 3 deletions Tests/YamsTests/ConstructorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,16 @@ class ConstructorTests: XCTestCase { // swiftlint:disable:this type_body_length
english: null
~: null key
---
# This sequence has five
# entries, two have values.
# This sequence has seven
# entries, four have values.
sparse:
- ~
- 2nd entry
-
- 4th entry
- Null
- 'null'
- ''
"""
let objects = Array(try Yams.load_all(yaml: example))
Expand All @@ -235,7 +237,9 @@ class ConstructorTests: XCTestCase { // swiftlint:disable:this type_body_length
"2nd entry",
NSNull(),
"4th entry",
NSNull()
NSNull(),
"null",
""
] as [Any]
]
]
Expand Down
13 changes: 0 additions & 13 deletions Tests/YamsTests/EncoderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -590,14 +590,6 @@ private struct Address: Codable, Equatable {
let zipCode: Int
let country: String

init(street: String, city: String, state: String, zipCode: Int, country: String) {
self.street = street
self.city = city
self.state = state
self.zipCode = zipCode
self.country = country
}

static func == (_ lhs: Address, _ rhs: Address) -> Bool {
return lhs.street == rhs.street &&
lhs.city == rhs.city &&
Expand Down Expand Up @@ -685,11 +677,6 @@ private struct Company: Codable, Equatable {
let address: Address
var employees: [Employee]

init(address: Address, employees: [Employee]) {
self.address = address
self.employees = employees
}

static func == (_ lhs: Company, _ rhs: Company) -> Bool {
return lhs.address == rhs.address && lhs.employees == rhs.employees
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/YamsTests/NodeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class NodeTests: XCTestCase {
let scalarFloat: Node = "1.0"
XCTAssertEqual(scalarFloat.float, 1.0)

let scalarNull: Node = "null"
let scalarNull = Node("null", .implicit, .plain)
XCTAssertEqual(scalarNull.null, NSNull())

let scalarInt: Node = "1"
Expand Down
46 changes: 46 additions & 0 deletions Tests/YamsTests/TopLevelDecoderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,51 @@ class TopLevelDecoderTests: XCTestCase {
)
XCTAssertEqual(foo?.name, "Bird")
}

func testDecodeOptionalTypes() throws {
let yaml = """
AAA: ''
BBB:
CCC: null
DDD: ~
EEE: ""
json: {
"FFF": "",
"GGG": "null"
}
array:
- one
- ''
- null
- 'null'
- '~'
"""

struct Container: Codable, Equatable {
struct JSON: Codable, Equatable {
var FFF: String?
var GGG: String?
}

var AAA: String?
var BBB: String?
var CCC: Int?
var DDD: String?
var EEE: String?
var json: JSON
var array: [String?]
}

let container = try YAMLDecoder().decode(Container.self, from: yaml)

XCTAssertEqual(container.AAA, "")
XCTAssertEqual(container.BBB, nil)
XCTAssertEqual(container.CCC, nil)
XCTAssertEqual(container.DDD, nil)
XCTAssertEqual(container.EEE, "")
XCTAssertEqual(container.json.FFF, "")
XCTAssertEqual(container.json.GGG, "null")
XCTAssertEqual(container.array, ["one", "", nil, "null", "~"])
}
}
#endif

0 comments on commit e451701

Please sign in to comment.