Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test w/ Xcode 11.4 on macOS, Swift 5.2.1 on Linux #166

Merged
merged 9 commits into from
Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 74 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,94 @@

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
pull_request:
branches: [ master ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
xcode-11_0:
# The type of runner that the job will run on
runs-on: ubuntu-latest
runs-on: macOS-10.15

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

- name: Build with Xcode 11.0
run: ./test_xcodebuild.sh Xcode_11
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=13.0,name=iPhone 8'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=13.0,name=Apple TV 4K'

xcode-11_1:
runs-on: macOS-10.15

steps:
- uses: actions/checkout@v2

- name: Build with Xcode 11.1
run: ./test_xcodebuild.sh Xcode_11.1
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=13.1,name=iPhone 8'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=13.0,name=Apple TV 4K'

xcode-11_2:
runs-on: macOS-10.15

steps:
- uses: actions/checkout@v2

- name: Build with Xcode 11.2
run: ./test_xcodebuild.sh Xcode_11.2
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=13.2,name=iPhone 8'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=13.2,name=Apple TV 4K'

xcode-11_3:
runs-on: macOS-10.15

steps:
- uses: actions/checkout@v2

- name: Build with Xcode 11.3
run: ./test_xcodebuild.sh Xcode_11.3
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=13.3,name=iPhone 8'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=13.3,name=Apple TV 4K'

xcode-11_4:
runs-on: macOS-10.15

steps:
- uses: actions/checkout@v2

- name: Build with Xcode 11.4
run: ./test_xcodebuild.sh Xcode_11.4
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=13.4,name=iPhone 8'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=13.4,name=Apple TV 4K'
CODECOV_JOB: 'true'
CODECOV_TOKEN: ${{ secrets.codecovToken }}

pod-lib-lint:
runs-on: macOS-10.15

steps:
- uses: actions/checkout@v2

- name: Run CocoaPods linter
run: ./pod.sh

danger-lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Danger Swift
uses: maxdesiatov/danger-swift@swiftlint-docker
env:
Expand Down
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: '^Pods'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- id: detect-private-key
- id: check-merge-conflict
- repo: https://github.com/hodovani/pre-commit-swift
rev: master
hooks:
- id: swift-lint
- id: swift-format
3 changes: 3 additions & 0 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
brew "pre-commit"
brew "swiftformat"
brew "swiftlint"
42 changes: 25 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Sometimes you need to handle an XML namespace prefix, like in the XML below:
</h:table>
```

Stripping the prefix from element names is enabled with
Stripping the prefix from element names is enabled with
`shouldProcessNamespaces` property:

```swift
Expand Down Expand Up @@ -110,7 +110,7 @@ enum NodeDecoding {

// the default, attempts to decode as an element first,
// otherwise reads from an attribute
case elementOrAttribute
case elementOrAttribute
}

enum NodeEncoding {
Expand Down Expand Up @@ -160,7 +160,7 @@ works for this XML:
</book>
```

Please refer to PR [\#70](https://github.com/MaxDesiatov/XMLCoder/pull/70) by
Please refer to PR [\#70](https://github.com/MaxDesiatov/XMLCoder/pull/70) by
[@JoeMatt](https://github.com/JoeMatt) for more details.

### Coding key value intrinsic
Expand All @@ -172,7 +172,7 @@ Suppose that you need to decode an XML that looks similar to this:
<foo id="123">456</foo>
```

By default you'd be able to decode `foo` as an element, but then it's not
By default you'd be able to decode `foo` as an element, but then it's not
possible to decode the `id` attribute. `XMLCoder` handles certain `CodingKey`
values in a special way to allow proper coding for this XML. Just add a coding
key with `stringValue` that equals `"value"` or `""` (empty string). What
Expand All @@ -190,7 +190,7 @@ struct Foo: Codable, DynamicNodeEncoding {
// case value = "" would also work
}

static func nodeEncoding(forKey key: CodingKey)
static func nodeEncoding(forKey key: CodingKey)
-> XMLEncoder.NodeEncoding {
switch key {
case CodingKeys.id:
Expand All @@ -208,14 +208,14 @@ in PR [\#73](https://github.com/MaxDesiatov/XMLCoder/pull/73).
### Preserving whitespaces in element content

By default whitespaces are trimmed in element content during decoding. This
includes string values decoded with [value intrinsic keys](#coding-key-value-intrinsic).
Starting with [version 0.5](https://github.com/MaxDesiatov/XMLCoder/releases/tag/0.5.0)
includes string values decoded with [value intrinsic keys](#coding-key-value-intrinsic).
Starting with [version 0.5](https://github.com/MaxDesiatov/XMLCoder/releases/tag/0.5.0)
you can now set a property `trimValueWhitespaces` to `false` (the default value is `true`) on
`XMLDecoder` instance to preserve all whitespaces in decoded strings.

### Choice element coding

Starting with [version 0.8](https://github.com/MaxDesiatov/XMLCoder/releases/tag/0.8.0),
Starting with [version 0.8](https://github.com/MaxDesiatov/XMLCoder/releases/tag/0.8.0),
you can encode and decode `enum`s with associated values by conforming your
`CodingKey` type additionally to `XMLChoiceCodingKey`. This allows decoding
XML elements similar in structure to this example:
Expand Down Expand Up @@ -265,12 +265,12 @@ extension IntOrString: Codable {
}
```

This is described in more details in PR [\#119](https://github.com/MaxDesiatov/XMLCoder/pull/119)
This is described in more details in PR [\#119](https://github.com/MaxDesiatov/XMLCoder/pull/119)
by [@jsbean](https://github.com/jsbean) and [@bwetherfield](https://github.com/bwetherfield).

### Integrating with [Combine](https://developer.apple.com/documentation/combine)

Starting with XMLCoder [version 0.9](https://github.com/MaxDesiatov/XMLCoder/releases/tag/0.9.0),
Starting with XMLCoder [version 0.9](https://github.com/MaxDesiatov/XMLCoder/releases/tag/0.9.0),
when Apple's Combine framework is available, `XMLDecoder` conforms to the
`TopLevelDecoder` protocol, which allows it to be used with the
`decode(type:decoder:)` operator:
Expand All @@ -288,7 +288,7 @@ func fetchBook(from url: URL) -> AnyPublisher<Book, Error> {
}
```

This was implemented in PR [\#132](https://github.com/MaxDesiatov/XMLCoder/pull/132)
This was implemented in PR [\#132](https://github.com/MaxDesiatov/XMLCoder/pull/132)
by [@sharplet](https://github.com/sharplet).

## Installation
Expand Down Expand Up @@ -323,7 +323,7 @@ dependencies: [

### CocoaPods

[CocoaPods](https://cocoapods.org) is a dependency manager for Swift and Objective-C
[CocoaPods](https://cocoapods.org) is a dependency manager for Swift and Objective-C
Cocoa projects for Apple's platfoms. You can install it with the following command:

```bash
Expand All @@ -343,7 +343,7 @@ Inside of your `Podfile`, specify the `XMLCoder` pod:
# platform :ios, '9.0'

target 'YourApp' do
# Comment the next line if you're not using Swift or don't want
# Comment the next line if you're not using Swift or don't want
# to use dynamic frameworks
use_frameworks!

Expand All @@ -364,7 +364,7 @@ file.

### Carthage

[Carthage](https://github.com/Carthage/Carthage) is a dependency manager for Apple's
[Carthage](https://github.com/Carthage/Carthage) is a dependency manager for Apple's
platfoms that builds your dependencies and provides you with binary frameworks.

Carthage can be installed with [Homebrew](https://brew.sh/) using the following command:
Expand Down Expand Up @@ -412,9 +412,17 @@ extension](https://github.com/nicklockwood/SwiftFormat#xcode-source-editor-exten
[build phase](https://github.com/nicklockwood/SwiftFormat#xcode-build-phase) or
[git pre-commit
hook](https://github.com/nicklockwood/SwiftFormat#git-pre-commit-hook) etc.
Please check [SwiftFormat
documentation](https://github.com/nicklockwood/SwiftFormat#how-do-i-install-it)
for more details.

To guarantee that these tools run before you commit your changes on macOS, you're encouraged
to run this once to set up the pre-commit hook:

```
brew bundle # installs SwiftLint, SwiftFormat and pre-commit
pre-commit install # installs pre-commit hook to run checks before you commit
```

Refer to [the pre-commit documentation page](https://pre-commit.com/) for more details
and installation instructions for other platforms.

SwiftFormat also runs on CI for every PR and thus a CI build can fail
with incosistent formatting. We require CI builds to pass for any PR before
Expand Down
3 changes: 0 additions & 3 deletions Sources/XMLCoder/Decoder/XMLUnkeyedDecodingContainer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ struct XMLUnkeyedDecodingContainer: UnkeyedDecodingContainer {
_ type: T.Type,
decode: (XMLDecoderImplementation, Box) throws -> T?
) throws -> T {
guard let strategy = decoder.nodeDecodings.last else {
preconditionFailure("Attempt to access node decoding strategy from empty stack.")
}
decoder.codingPath.append(XMLKey(index: currentIndex))
let nodeDecodings = decoder.options.nodeDecodingStrategy.nodeDecodings(
forType: T.self,
Expand Down
21 changes: 21 additions & 0 deletions XMLCoder.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@
buildConfigurationList = OBJ_144 /* Build configuration list for PBXNativeTarget "XMLCoder" */;
buildPhases = (
OBJ_147 /* Sources */,
D16972C42438A95A000D0D87 /* ShellScript */,
OBJ_192 /* Frameworks */,
);
buildRules = (
Expand Down Expand Up @@ -637,6 +638,26 @@
};
/* End PBXProject section */

/* Begin PBXShellScriptBuildPhase section */
D16972C42438A95A000D0D87 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi\n";
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
OBJ_147 /* Sources */ = {
isa = PBXSourcesBuildPhase;
Expand Down
56 changes: 12 additions & 44 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ jobs:
vmImage: 'macos-latest'
steps:
- bash: ./lint.sh
- job: pod
pool:
vmImage: 'macOS-10.14'
steps:
- bash: ./pod.sh
- job: test_xcodebuild_10_0
pool:
vmImage: 'macOS-10.14'
Expand Down Expand Up @@ -47,54 +42,27 @@ jobs:
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=12.4,name=iPhone SE'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=12.4,name=Apple TV 4K'
- job: test_xcodebuild_11_0
pool:
vmImage: 'macOS-10.14'
steps:
- bash: ./test_xcodebuild.sh Xcode_11
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=13.0,name=iPhone 8'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=13.0,name=Apple TV 4K'
- job: test_xcodebuild_11_1
pool:
vmImage: 'macOS-10.14'
steps:
- bash: ./test_xcodebuild.sh Xcode_11.1
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=13.1,name=iPhone 8'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=13.0,name=Apple TV 4K'
- job: test_xcodebuild_11_2
pool:
vmImage: 'macOS-10.14'
steps:
- bash: ./test_xcodebuild.sh Xcode_11.2
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=13.2,name=iPhone 8'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=13.2,name=Apple TV 4K'
- job: test_xcodebuild_11_3
pool:
vmImage: 'macOS-10.14'
steps:
- bash: ./test_xcodebuild.sh Xcode_11.3
env:
IOS_DEVICE: 'platform=iOS Simulator,OS=13.3,name=iPhone 8'
TVOS_DEVICE: 'platform=tvOS Simulator,OS=13.3,name=Apple TV 4K'
CODECOV_JOB: 'true'
CODECOV_TOKEN: $(codecovToken)

- job: test_swiftpm
pool:
vmImage: 'macOS-10.14'
vmImage: 'macOS-10.15'
steps:
- script: ./test_swiftpm.sh
- job: test_linux_5_0
pool:
vmImage: 'Ubuntu 16.04'
container: norionomura/swift:503
vmImage: 'Ubuntu 18.04'
container: swift:5.0.3
steps:
- script: ./test_swiftpm.sh
- job: test_linux_5_1
pool:
vmImage: 'Ubuntu 16.04'
container: norionomura/swift:51
vmImage: 'Ubuntu 18.04'
container: swift:5.1.5
steps:
- script: ./test_swiftpm.sh
- job: test_linux_5_2
pool:
vmImage: 'Ubuntu 18.04'
container: swift:5.2.1
steps:
- script: ./test_swiftpm.sh
5 changes: 1 addition & 4 deletions pod.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#!/bin/bash

set -e
set -e
set -o pipefail

sudo gem uninstall cocoapods
sudo gem install cocoapods -v 1.7.5
pod setup
pod lib lint --verbose
Loading