From 586136ed0e4b0efdeda0ced3b7be5d6170f1eff6 Mon Sep 17 00:00:00 2001 From: Wojciech Chojnacki Date: Tue, 1 Jun 2021 22:24:23 +0100 Subject: [PATCH] Makefile, swiftlint, github ci, license --- .github/workflows/ci-linux.yaml | 22 +++++++++ .github/workflows/ci-mac.yaml | 29 +++++++++++ .swiftlint.yml | 32 +++++++++++++ LICENSE | 19 ++++++++ Makefile | 48 +++++++++++++++++++ Sources/NotionSwift/AccessKeyProvider.swift | 1 - Sources/NotionSwift/Models/Page.swift | 3 -- Sources/NotionSwift/Models/User.swift | 1 - Sources/NotionSwift/NotionClient+Pages.swift | 12 ++--- Sources/NotionSwift/NotionClient+Search.swift | 4 +- Sources/NotionSwift/NotionClient.swift | 1 - .../NotionSwift/Request/Filter+types.swift | 2 - 12 files changed, 158 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/ci-linux.yaml create mode 100644 .github/workflows/ci-mac.yaml create mode 100644 .swiftlint.yml create mode 100644 LICENSE create mode 100644 Makefile diff --git a/.github/workflows/ci-linux.yaml b/.github/workflows/ci-linux.yaml new file mode 100644 index 0000000..6f57ee2 --- /dev/null +++ b/.github/workflows/ci-linux.yaml @@ -0,0 +1,22 @@ +name: "ci-linux" +on: + push: + branches: + - main + paths: + - "Sources/**" + - "Tests/**" + pull_request: + branches: + - '*' + +jobs: + ubuntu: + name: Linux Tests + runs-on: ubuntu-latest + container: swift:5.3 + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Tests Linux + run: make test-swift \ No newline at end of file diff --git a/.github/workflows/ci-mac.yaml b/.github/workflows/ci-mac.yaml new file mode 100644 index 0000000..3e80d19 --- /dev/null +++ b/.github/workflows/ci-mac.yaml @@ -0,0 +1,29 @@ +name: "ci-mac" +on: + push: + branches: + - main + paths: + - "Sources/**" + - "Tests/**" + pull_request: + branches: + - '*' + +jobs: + build: + name: MacOS Tests + runs-on: macos-latest + env: + DEVELOPER_DIR: /Applications/Xcode_12.4.app/Contents/Developer + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Tests iOS + run: make test-ios + - name: Upload artifacts + if: failure() + uses: actions/upload-artifact@v2 + with: + name: test_results + path: .build/DerivedData/Logs/Test/ \ No newline at end of file diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000..0538892 --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,32 @@ +included: + - Sources + - Tests +excluded: +disabled_rules: + - trailing_whitespace + - trailing_comma + - nesting + - cyclomatic_complexity + - file_length + - todo + - function_parameter_count + - opening_brace + - function_body_length + - large_tuple +line_length: + ignores_interpolated_strings: true + ignores_comments: true + warning: 120 + error: 170 +identifier_name: + min_length: + error: 1 + warning: 1 +inclusive_language: + override_allowed_terms: + - masterKey +type_name: + min_length: + error: 1 + warning: 1 + allowed_symbols: ["_"] \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8a56006 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2021 Wojciech Chojnacki + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..0fd471a --- /dev/null +++ b/Makefile @@ -0,0 +1,48 @@ +ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +IOS_SIMULATOR = "iOS Simulator,name=iPhone 12 Pro,OS=14.4" +DERIVED_DATA_DIR=$(ROOT_DIR)/.build/DerivedData + +.PHONY: pre_checks_macos default + +default: + +pre_checks_macos: +# ifeq (, $(shell which xcpretty)) +# $(error "No xcpretty in PATH, consider doing gem install xcpretty") +# endif + +build: + swift build + +test: + swift test + +test-swift: + swift test --enable-test-discovery + +test-ios: pre_checks_macos + set -o pipefail && \ + xcodebuild test \ + -derivedDataPath $(DERIVED_DATA_DIR) \ + -scheme NotionSwift \ + -destination platform=$(IOS_SIMULATOR) | xcpretty + +test-macos: pre_checks_macos + set -o pipefail && \ + xcodebuild test \ + -derivedDataPath $(DERIVED_DATA_DIR) \ + -scheme NotionSwift \ + -destination platform="macOS" | xcpretty + +test-linux: + docker run \ + --rm \ + -v "$(PWD):$(PWD)" \ + -w "$(PWD)" \ + swift:5.3 \ + bash -c 'make test-swift' + +test-all: test-macos test-ios + +clean: + swift package clean \ No newline at end of file diff --git a/Sources/NotionSwift/AccessKeyProvider.swift b/Sources/NotionSwift/AccessKeyProvider.swift index 5e46405..b8a6f72 100644 --- a/Sources/NotionSwift/AccessKeyProvider.swift +++ b/Sources/NotionSwift/AccessKeyProvider.swift @@ -8,7 +8,6 @@ public protocol AccessKeyProvider { var accessKey: String? { get } } - public struct StringAccessKeyProvider: AccessKeyProvider, ExpressibleByStringLiteral { public let accessKey: String? diff --git a/Sources/NotionSwift/Models/Page.swift b/Sources/NotionSwift/Models/Page.swift index 8b4ac36..6ddb218 100644 --- a/Sources/NotionSwift/Models/Page.swift +++ b/Sources/NotionSwift/Models/Page.swift @@ -25,6 +25,3 @@ extension Page: Decodable { case properties } } - - - diff --git a/Sources/NotionSwift/Models/User.swift b/Sources/NotionSwift/Models/User.swift index c1235a3..52bec67 100644 --- a/Sources/NotionSwift/Models/User.swift +++ b/Sources/NotionSwift/Models/User.swift @@ -58,5 +58,4 @@ extension User: Decodable { } } - } diff --git a/Sources/NotionSwift/NotionClient+Pages.swift b/Sources/NotionSwift/NotionClient+Pages.swift index 5d96665..4db3e0c 100644 --- a/Sources/NotionSwift/NotionClient+Pages.swift +++ b/Sources/NotionSwift/NotionClient+Pages.swift @@ -7,7 +7,7 @@ import Foundation // MARK: - Pages // WIP -//extension NotionClient { +// extension NotionClient { // // public func page(pageId: Page.Identifier, completed: @escaping (Result) -> Void) { // networkClient.get( @@ -34,10 +34,10 @@ import Foundation // completed: completed // ) // } -//} +// } // -//#warning("TODO: PageCreateRequest") -//public struct PageCreateRequest: Encodable {} +// #warning("TODO: PageCreateRequest") +// public struct PageCreateRequest: Encodable {} // -//#warning("TODO: PageUpdateParams") -//public struct PageUpdateParams: Encodable {} +// #warning("TODO: PageUpdateParams") +// public struct PageUpdateParams: Encodable {} diff --git a/Sources/NotionSwift/NotionClient+Search.swift b/Sources/NotionSwift/NotionClient+Search.swift index 7ee3d51..3581348 100644 --- a/Sources/NotionSwift/NotionClient+Search.swift +++ b/Sources/NotionSwift/NotionClient+Search.swift @@ -7,8 +7,8 @@ import Foundation // MARK: - Search // WIP -//extension NotionClient { +// extension NotionClient { // public func search(params: Any, completed: @escaping (Result<[Any], Error>) -> Void) { // // } -//} +// } diff --git a/Sources/NotionSwift/NotionClient.swift b/Sources/NotionSwift/NotionClient.swift index d6f5c86..2f0a0e0 100644 --- a/Sources/NotionSwift/NotionClient.swift +++ b/Sources/NotionSwift/NotionClient.swift @@ -30,4 +30,3 @@ public final class NotionClient { return headers } } - diff --git a/Sources/NotionSwift/Request/Filter+types.swift b/Sources/NotionSwift/Request/Filter+types.swift index 97f9c50..0cc8f28 100644 --- a/Sources/NotionSwift/Request/Filter+types.swift +++ b/Sources/NotionSwift/Request/Filter+types.swift @@ -80,7 +80,6 @@ extension DatabasePropertyFilter { } } - extension DatabasePropertyFilter { public enum NumberCondition { case equals(Int) @@ -106,4 +105,3 @@ extension DatabasePropertyFilter { case isNotEmpty } } -