From 1c51fcfe8c6d0e245468bfab030c68b97e8ad6f5 Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Thu, 8 Apr 2021 17:30:53 +0100 Subject: [PATCH] Add file header via swift format --- .github/workflows/ci.yml | 17 +++++++++++++++++ .github/workflows/nightly.yml | 7 +++++++ .swiftformat | 3 +++ Sources/HummingbirdMustache/ContentType.swift | 14 ++++++++++++++ Sources/HummingbirdMustache/Context.swift | 14 ++++++++++++++ Sources/HummingbirdMustache/Lambda.swift | 14 ++++++++++++++ .../Library+FileSystem.swift | 14 ++++++++++++++ Sources/HummingbirdMustache/Library.swift | 14 ++++++++++++++ Sources/HummingbirdMustache/Mirror.swift | 14 +++++++++++++- Sources/HummingbirdMustache/Parent.swift | 13 +++++++++++++ Sources/HummingbirdMustache/Parser.swift | 14 ++++++++++++++ Sources/HummingbirdMustache/Sequence.swift | 13 +++++++++++++ .../HummingbirdMustache/SequenceContext.swift | 13 +++++++++++++ Sources/HummingbirdMustache/String.swift | 13 +++++++++++++ .../HummingbirdMustache/Template+Parser.swift | 13 +++++++++++++ .../HummingbirdMustache/Template+Render.swift | 13 +++++++++++++ Sources/HummingbirdMustache/Template.swift | 14 ++++++++++++++ Sources/HummingbirdMustache/Transform.swift | 14 ++++++++++++++ Tests/HummingbirdMustacheTests/ErrorTests.swift | 14 ++++++++++++++ .../HummingbirdMustacheTests/LibraryTests.swift | 14 ++++++++++++++ .../HummingbirdMustacheTests/PartialTests.swift | 14 ++++++++++++++ Tests/HummingbirdMustacheTests/SpecTests.swift | 14 ++++++++++++++ .../TemplateParserTests.swift | 14 ++++++++++++++ .../TemplateRendererTests.swift | 14 ++++++++++++++ .../TransformTests.swift | 16 +++++++++++++++- Tests/LinuxMain.swift | 14 +++++++++++++- 26 files changed, 342 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9475f46..fab131b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,23 @@ on: workflow_dispatch: jobs: + macOS: + runs-on: macOS-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: SPM tests + run: swift test --enable-code-coverage --sanitize=thread + - name: Convert coverage files + run: | + xcrun llvm-cov export -format "lcov" \ + .build/debug/hummingbird-mustachePackageTests.xctest/Contents/MacOs/hummingbird-mustachePackageTests \ + -ignore-filename-regex="\/Tests\/" \ + -instr-profile=.build/debug/codecov/default.profdata > info.lcov + - name: Upload to codecov.io + uses: codecov/codecov-action@v1 + with: + file: info.lcov linux: runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 8e8f4d2..3ab0be8 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -6,6 +6,13 @@ on: workflow_dispatch: jobs: + macOS: + runs-on: macOS-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: SPM tests + run: swift test --sanitize=thread linux: runs-on: ubuntu-latest strategy: diff --git a/.swiftformat b/.swiftformat index 7c0304e..495bbcd 100644 --- a/.swiftformat +++ b/.swiftformat @@ -21,3 +21,6 @@ --wraparguments before-first --wrapparameters before-first --wrapcollections before-first + +#file header +--header "//===----------------------------------------------------------------------===//\n//\n// This source file is part of the Hummingbird server framework project\n//\n// Copyright (c) {created.year}-{year} the Hummingbird authors\n// Licensed under Apache License v2.0\n//\n// See LICENSE.txt for license information\n// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors\n//\n// SPDX-License-Identifier: Apache-2.0\n//\n//===----------------------------------------------------------------------===//" diff --git a/Sources/HummingbirdMustache/ContentType.swift b/Sources/HummingbirdMustache/ContentType.swift index c378786..4625d68 100644 --- a/Sources/HummingbirdMustache/ContentType.swift +++ b/Sources/HummingbirdMustache/ContentType.swift @@ -1,3 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + /// Protocol for content types public protocol HBMustacheContentType { /// escape text for this content type eg for HTML replace "<" with "<" diff --git a/Sources/HummingbirdMustache/Context.swift b/Sources/HummingbirdMustache/Context.swift index dbfe645..1815c0d 100644 --- a/Sources/HummingbirdMustache/Context.swift +++ b/Sources/HummingbirdMustache/Context.swift @@ -1,3 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + /// Context while rendering mustache tokens struct HBMustacheContext { let stack: [Any] diff --git a/Sources/HummingbirdMustache/Lambda.swift b/Sources/HummingbirdMustache/Lambda.swift index cd6db67..2ddc19e 100644 --- a/Sources/HummingbirdMustache/Lambda.swift +++ b/Sources/HummingbirdMustache/Lambda.swift @@ -1,3 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + /// Lambda function. Can add this to object being rendered to filter contents of objects. /// diff --git a/Sources/HummingbirdMustache/Library+FileSystem.swift b/Sources/HummingbirdMustache/Library+FileSystem.swift index 1c8c6de..c878993 100644 --- a/Sources/HummingbirdMustache/Library+FileSystem.swift +++ b/Sources/HummingbirdMustache/Library+FileSystem.swift @@ -1,3 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + import Foundation extension HBMustacheLibrary { diff --git a/Sources/HummingbirdMustache/Library.swift b/Sources/HummingbirdMustache/Library.swift index b5334ea..f016ead 100644 --- a/Sources/HummingbirdMustache/Library.swift +++ b/Sources/HummingbirdMustache/Library.swift @@ -1,3 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + /// Class holding a collection of mustache templates. /// /// Each template can reference the others via a partial using the name the template is registered under diff --git a/Sources/HummingbirdMustache/Mirror.swift b/Sources/HummingbirdMustache/Mirror.swift index 7d9fa41..50811eb 100644 --- a/Sources/HummingbirdMustache/Mirror.swift +++ b/Sources/HummingbirdMustache/Mirror.swift @@ -1,4 +1,16 @@ - +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// extension Mirror { /// Return value from Mirror given name diff --git a/Sources/HummingbirdMustache/Parent.swift b/Sources/HummingbirdMustache/Parent.swift index afd55c4..0a49fb0 100644 --- a/Sources/HummingbirdMustache/Parent.swift +++ b/Sources/HummingbirdMustache/Parent.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// Protocol for object that has a custom method for accessing their children, instead /// of using Mirror diff --git a/Sources/HummingbirdMustache/Parser.swift b/Sources/HummingbirdMustache/Parser.swift index 1ca743d..28c0979 100644 --- a/Sources/HummingbirdMustache/Parser.swift +++ b/Sources/HummingbirdMustache/Parser.swift @@ -1,3 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + import Foundation /// Reader object for parsing String buffers diff --git a/Sources/HummingbirdMustache/Sequence.swift b/Sources/HummingbirdMustache/Sequence.swift index 1e0b78d..2435304 100644 --- a/Sources/HummingbirdMustache/Sequence.swift +++ b/Sources/HummingbirdMustache/Sequence.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// Protocol for objects that can be rendered as a sequence in Mustache protocol HBMustacheSequence { diff --git a/Sources/HummingbirdMustache/SequenceContext.swift b/Sources/HummingbirdMustache/SequenceContext.swift index 50c4b38..c4d5c38 100644 --- a/Sources/HummingbirdMustache/SequenceContext.swift +++ b/Sources/HummingbirdMustache/SequenceContext.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// /// Context that current object inside a sequence is being rendered in. Only relevant when rendering a sequence struct HBMustacheSequenceContext: HBMustacheTransformable { diff --git a/Sources/HummingbirdMustache/String.swift b/Sources/HummingbirdMustache/String.swift index c67d778..b9d7037 100644 --- a/Sources/HummingbirdMustache/String.swift +++ b/Sources/HummingbirdMustache/String.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// extension String { private static let htmlEscapedCharacters: [Character: String] = [ diff --git a/Sources/HummingbirdMustache/Template+Parser.swift b/Sources/HummingbirdMustache/Template+Parser.swift index 4d7e0f9..ec7b782 100644 --- a/Sources/HummingbirdMustache/Template+Parser.swift +++ b/Sources/HummingbirdMustache/Template+Parser.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// extension HBMustacheTemplate { /// Error return by `HBMustacheTemplate.parse`. Includes information about where error occurred diff --git a/Sources/HummingbirdMustache/Template+Render.swift b/Sources/HummingbirdMustache/Template+Render.swift index dd87ffd..3df4c69 100644 --- a/Sources/HummingbirdMustache/Template+Render.swift +++ b/Sources/HummingbirdMustache/Template+Render.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// extension HBMustacheTemplate { /// Render template using object diff --git a/Sources/HummingbirdMustache/Template.swift b/Sources/HummingbirdMustache/Template.swift index 54bcf9f..2400a95 100644 --- a/Sources/HummingbirdMustache/Template.swift +++ b/Sources/HummingbirdMustache/Template.swift @@ -1,3 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + /// Class holding Mustache template public final class HBMustacheTemplate { /// Initialize template diff --git a/Sources/HummingbirdMustache/Transform.swift b/Sources/HummingbirdMustache/Transform.swift index ecc0a45..592f3d9 100644 --- a/Sources/HummingbirdMustache/Transform.swift +++ b/Sources/HummingbirdMustache/Transform.swift @@ -1,3 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + /// Objects that can have a transforms run on them. Mustache transforms are specific to this implementation /// of Mustache. They allow you to process objects before they are rendered. /// diff --git a/Tests/HummingbirdMustacheTests/ErrorTests.swift b/Tests/HummingbirdMustacheTests/ErrorTests.swift index aa7693a..9330c62 100644 --- a/Tests/HummingbirdMustacheTests/ErrorTests.swift +++ b/Tests/HummingbirdMustacheTests/ErrorTests.swift @@ -1,3 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + import HummingbirdMustache import XCTest diff --git a/Tests/HummingbirdMustacheTests/LibraryTests.swift b/Tests/HummingbirdMustacheTests/LibraryTests.swift index 3278ff6..94c3795 100644 --- a/Tests/HummingbirdMustacheTests/LibraryTests.swift +++ b/Tests/HummingbirdMustacheTests/LibraryTests.swift @@ -1,3 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + @testable import HummingbirdMustache import XCTest diff --git a/Tests/HummingbirdMustacheTests/PartialTests.swift b/Tests/HummingbirdMustacheTests/PartialTests.swift index 4190ada..8e8818d 100644 --- a/Tests/HummingbirdMustacheTests/PartialTests.swift +++ b/Tests/HummingbirdMustacheTests/PartialTests.swift @@ -1,3 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + @testable import HummingbirdMustache import XCTest diff --git a/Tests/HummingbirdMustacheTests/SpecTests.swift b/Tests/HummingbirdMustacheTests/SpecTests.swift index 4ca2d3e..9fc5258 100644 --- a/Tests/HummingbirdMustacheTests/SpecTests.swift +++ b/Tests/HummingbirdMustacheTests/SpecTests.swift @@ -1,3 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + import Foundation #if os(Linux) import FoundationNetworking diff --git a/Tests/HummingbirdMustacheTests/TemplateParserTests.swift b/Tests/HummingbirdMustacheTests/TemplateParserTests.swift index f7e7f08..c5deca6 100644 --- a/Tests/HummingbirdMustacheTests/TemplateParserTests.swift +++ b/Tests/HummingbirdMustacheTests/TemplateParserTests.swift @@ -1,3 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + @testable import HummingbirdMustache import XCTest diff --git a/Tests/HummingbirdMustacheTests/TemplateRendererTests.swift b/Tests/HummingbirdMustacheTests/TemplateRendererTests.swift index 26f8a3c..90792fa 100644 --- a/Tests/HummingbirdMustacheTests/TemplateRendererTests.swift +++ b/Tests/HummingbirdMustacheTests/TemplateRendererTests.swift @@ -1,3 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + @testable import HummingbirdMustache import XCTest diff --git a/Tests/HummingbirdMustacheTests/TransformTests.swift b/Tests/HummingbirdMustacheTests/TransformTests.swift index f69355a..1a938c8 100644 --- a/Tests/HummingbirdMustacheTests/TransformTests.swift +++ b/Tests/HummingbirdMustacheTests/TransformTests.swift @@ -1,3 +1,17 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + import HummingbirdMustache import XCTest @@ -132,7 +146,7 @@ final class TransformTests: XCTestCase { let template = try HBMustacheTemplate(string: """ {{#empty(array)}}Array{{/empty(array)}}{{#empty(dictionary)}}Dictionary{{/empty(dictionary)}} """) - let object: [String: Any] = ["array":[], "dictionary":[:]] + let object: [String: Any] = ["array": [], "dictionary": [:]] XCTAssertEqual(template.render(object), "ArrayDictionary") } diff --git a/Tests/LinuxMain.swift b/Tests/LinuxMain.swift index 8b13789..7737b98 100644 --- a/Tests/LinuxMain.swift +++ b/Tests/LinuxMain.swift @@ -1 +1,13 @@ - +//===----------------------------------------------------------------------===// +// +// This source file is part of the Hummingbird server framework project +// +// Copyright (c) 2021-2021 the Hummingbird authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See hummingbird/CONTRIBUTORS.txt for the list of Hummingbird authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===//