From f029081b6105203828da9276ec42cd36bc22b095 Mon Sep 17 00:00:00 2001 From: Adam Fowler Date: Fri, 8 Mar 2024 12:04:49 +0000 Subject: [PATCH] Project template updates (#25) * Project template updates * More changes * run swiftformat --- .github/dependabot.yml | 21 +++++++++++ .github/workflows/api-breakage.yml | 7 ++-- .github/workflows/ci.yml | 35 +++---------------- .github/workflows/nightly.yml | 14 ++------ .github/workflows/validate.yml | 6 ++-- .gitignore | 1 + .swiftformat | 6 ++-- CONTRIBUTING.md | 4 +-- Dockerfile | 2 +- Sources/HummingbirdMustache/Context.swift | 16 ++++----- .../HummingbirdMustache/Template+Render.swift | 2 +- .../HummingbirdMustacheTests/SpecTests.swift | 2 +- scripts/validate.sh | 2 +- 13 files changed, 50 insertions(+), 68 deletions(-) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..998fd4c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,21 @@ +version: 2 +updates: + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + groups: + dependencies: + patterns: + - "*" + - package-ecosystem: "swift" + directory: "/" + schedule: + interval: "daily" + open-pull-requests-limit: 6 + allow: + - dependency-type: all + groups: + all-dependencies: + patterns: + - "*" diff --git a/.github/workflows/api-breakage.yml b/.github/workflows/api-breakage.yml index e9e9ae5..dd4bcb4 100644 --- a/.github/workflows/api-breakage.yml +++ b/.github/workflows/api-breakage.yml @@ -3,17 +3,16 @@ name: API breaking changes on: pull_request: - branches: - - main jobs: linux: runs-on: ubuntu-latest + timeout-minutes: 15 container: - image: swift:5.8 + image: swift:5.9 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 # https://github.com/actions/checkout/issues/766 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b1e6290..acf9d06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,48 +8,21 @@ on: - '**.swift' - '**.yml' pull_request: - branches: - - main - - 2.x.x - paths: - - '**.swift' - - '**.yml' workflow_dispatch: jobs: - macOS: - runs-on: macOS-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: SPM tests - run: swift test --enable-code-coverage - - name: Convert coverage files - run: | - xcrun llvm-cov export -format "lcov" \ - .build/debug/hummingbird-mustachePackageTests.xctest/Contents/MacOs/hummingbird-mustachePackageTests \ - -ignore-filename-regex="\/Tests\/" \ - -ignore-filename-regex="\/Benchmarks\/" \ - -instr-profile=.build/debug/codecov/default.profdata > info.lcov - - name: Upload to codecov.io - uses: codecov/codecov-action@v3 - with: - file: info.lcov linux: runs-on: ubuntu-latest + timeout-minutes: 15 strategy: matrix: - image: - - 'swift:5.7' - - 'swift:5.8' - - 'swift:5.9' - - 'swiftlang/swift:nightly-5.10-jammy' + image: ["swift:5.9", "swift:5.10", "swiftlang/swift:nightly-jammy"] container: image: ${{ matrix.image }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Test run: | swift test --enable-code-coverage @@ -61,6 +34,6 @@ jobs: -ignore-filename-regex="\/Benchmarks\/" \ -instr-profile .build/debug/codecov/default.profdata > info.lcov - name: Upload to codecov.io - uses: codecov/codecov-action@v3 + uses: codecov/codecov-action@v4 with: file: info.lcov diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index c4037be..1009911 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,20 +1,12 @@ name: Swift nightly build on: - schedule: - - cron: '0 1 * * 1' workflow_dispatch: jobs: - macOS: - runs-on: macOS-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: SPM tests - run: swift test linux: runs-on: ubuntu-latest + timeout-minutes: 15 strategy: matrix: image: ['nightly-focal', 'nightly-jammy', 'nightly-amazonlinux2'] @@ -23,7 +15,7 @@ jobs: image: swiftlang/swift:${{ matrix.image }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Test run: | - swift test --enable-test-discovery + swift test diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index e504a64..172da88 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -2,16 +2,14 @@ name: Validity Check on: pull_request: - branches: - - main - - 2.x.x jobs: validate: runs-on: macOS-latest + timeout-minutes: 15 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 1 - name: Install Dependencies diff --git a/.gitignore b/.gitignore index 2541032..45ca84c 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ xcuserdata/ Package.resolved /public /docs +.benchmarkBaselines \ No newline at end of file diff --git a/.swiftformat b/.swiftformat index 3a7c14d..d800f8a 100644 --- a/.swiftformat +++ b/.swiftformat @@ -1,14 +1,14 @@ # Minimum swiftformat version ---minversion 0.47.4 +--minversion 0.51.0 # Swift version ---swiftversion 5.3 +--swiftversion 5.9 # file options --exclude .build # rules ---disable redundantReturn, extensionAccessControl +--disable redundantReturn, extensionAccessControl, typeSugar # format options --ifdef no-indent diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 12d20a0..bd21b4f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,7 +2,7 @@ ## Legal By submitting a pull request, you represent that you have the right to license your contribution to the community, and agree by submitting the patch -that your contributions are licensed under the Apache 2.0 license (see [LICENSE](LICENSE.txt)). +that your contributions are licensed under the Apache 2.0 license (see [LICENSE](LICENSE)). ## Contributor Conduct All contributors are expected to adhere to the project's [Code of Conduct](CODE_OF_CONDUCT.md). @@ -30,4 +30,4 @@ The main development branch of the repository is `main`. ### Formatting -We use Nick Lockwood's SwiftFormat for formatting code. PRs will not be accepted if they haven't be formatted. The current version of SwiftFormat we are using is v0.48.17. \ No newline at end of file +We use Nick Lockwood's SwiftFormat for formatting code. PRs will not be accepted if they haven't be formatted. The current version of SwiftFormat we are using is v0.51.15. \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 01fa447..102200f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ # ================================ # Build image # ================================ -FROM swift:5.7 as build +FROM swift:5.9 as build WORKDIR /build diff --git a/Sources/HummingbirdMustache/Context.swift b/Sources/HummingbirdMustache/Context.swift index 83e1f63..2eaa0d3 100644 --- a/Sources/HummingbirdMustache/Context.swift +++ b/Sources/HummingbirdMustache/Context.swift @@ -63,21 +63,19 @@ struct HBMustacheContext { /// return context with indent and parameter information for invoking a partial func withPartial(indented: String?, inheriting: [String: HBMustacheTemplate]?) -> HBMustacheContext { - let indentation: String? - if let indented = indented { - indentation = (self.indentation ?? "") + indented + let indentation: String? = if let indented { + (self.indentation ?? "") + indented } else { - indentation = self.indentation + self.indentation } - let inherits: [String: HBMustacheTemplate]? - if let inheriting = inheriting { + let inherits: [String: HBMustacheTemplate]? = if let inheriting { if let originalInherits = self.inherited { - inherits = originalInherits.merging(inheriting) { value, _ in value } + originalInherits.merging(inheriting) { value, _ in value } } else { - inherits = inheriting + inheriting } } else { - inherits = self.inherited + self.inherited } return .init( stack: self.stack, diff --git a/Sources/HummingbirdMustache/Template+Render.swift b/Sources/HummingbirdMustache/Template+Render.swift index dca1acf..12fa40b 100644 --- a/Sources/HummingbirdMustache/Template+Render.swift +++ b/Sources/HummingbirdMustache/Template+Render.swift @@ -182,7 +182,7 @@ extension HBMustacheTemplate { } // if we want to run a transform and the current child can have transforms applied to it then // run transform on the current child - if let transform = transform { + if let transform { if let runnable = child as? HBMustacheTransformable { return runnable.transform(transform) } diff --git a/Tests/HummingbirdMustacheTests/SpecTests.swift b/Tests/HummingbirdMustacheTests/SpecTests.swift index e92f691..593d1df 100644 --- a/Tests/HummingbirdMustacheTests/SpecTests.swift +++ b/Tests/HummingbirdMustacheTests/SpecTests.swift @@ -22,7 +22,7 @@ import XCTest public struct AnyDecodable: Decodable { public let value: Any - public init(_ value: T) { + public init(_ value: some Any) { self.value = value } } diff --git a/scripts/validate.sh b/scripts/validate.sh index e201bd3..f621e66 100755 --- a/scripts/validate.sh +++ b/scripts/validate.sh @@ -13,7 +13,7 @@ ## ##===----------------------------------------------------------------------===## -SWIFT_FORMAT_VERSION=0.48.17 +SWIFT_FORMAT_VERSION=0.51.15 set -eu here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"