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 d6638e1..dd4bcb4 100644 --- a/.github/workflows/api-breakage.yml +++ b/.github/workflows/api-breakage.yml @@ -7,16 +7,17 @@ on: jobs: linux: runs-on: ubuntu-latest + timeout-minutes: 15 container: image: swift:5.9 steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - # https://github.com/actions/checkout/issues/766 - - name: Mark the workspace as safe - run: git config --global --add safe.directory ${GITHUB_WORKSPACE} - - name: API breaking changes - run: | - swift package diagnose-api-breaking-changes origin/${GITHUB_BASE_REF} + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + # https://github.com/actions/checkout/issues/766 + - name: Mark the workspace as safe + run: git config --global --add safe.directory ${GITHUB_WORKSPACE} + - name: API breaking changes + run: | + swift package diagnose-api-breaking-changes origin/${GITHUB_BASE_REF} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c6b6ad7..48fe7fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,63 +3,37 @@ name: CI on: push: branches: - - main - - 2.x.x + - main paths: - - "**.swift" - - "**.yml" + - '**.swift' + - '**.yml' pull_request: - branches: - - main - - 2.x.x - paths: - - "**.swift" - - "**.yml" workflow_dispatch: jobs: - # Disabled until 5.9 becomes available - # 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-lambdaPackageTests.xctest/Contents/MacOs/hummingbird-lambdaPackageTests \ - # -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.9" - + image: ["swift:5.9", "swift:5.10", "swiftlang/swift:nightly-jammy"] + container: image: ${{ matrix.image }} steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Test - run: | - swift test --enable-code-coverage - - name: Convert coverage files - run: | - llvm-cov export -format="lcov" \ - .build/debug/hummingbird-lambdaPackageTests.xctest \ - -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 + - name: Checkout + uses: actions/checkout@v4 + - name: Test + run: | + swift test --enable-code-coverage + - name: Convert coverage files + run: | + llvm-cov export -format="lcov" \ + .build/debug/hummingbird-lambdaPackageTests.xctest \ + -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@v4 + with: + file: info.lcov diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 21ef4c5..1009911 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,29 +1,21 @@ 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"] - + image: ['nightly-focal', 'nightly-jammy', 'nightly-amazonlinux2'] + container: image: swiftlang/swift:${{ matrix.image }} steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Test - run: | - swift test --enable-test-discovery + - name: Checkout + uses: actions/checkout@v4 + - name: Test + run: | + swift test diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 51627bd..172da88 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -2,21 +2,19 @@ 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 - with: - fetch-depth: 1 - - name: Install Dependencies - run: | - brew install mint - mint install NickLockwood/SwiftFormat@0.48.17 --no-link - - name: run script - run: ./scripts/validate.sh + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: Install Dependencies + run: | + brew install mint + mint install NickLockwood/SwiftFormat@0.51.15 --no-link + - name: run script + run: ./scripts/validate.sh 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 9f36908..d800f8a 100644 --- a/.swiftformat +++ b/.swiftformat @@ -1,5 +1,5 @@ # Minimum swiftformat version ---minversion 0.47.4 +--minversion 0.51.0 # Swift version --swiftversion 5.9 @@ -8,7 +8,7 @@ --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/Sources/HBLambdaTest/maths.swift b/Sources/HBLambdaTest/maths.swift index 92ca515..88971ab 100644 --- a/Sources/HBLambdaTest/maths.swift +++ b/Sources/HBLambdaTest/maths.swift @@ -20,7 +20,6 @@ import Logging struct DebugMiddleware: HBMiddlewareProtocol { typealias Context = MathsHandler.Context - func handle( _ request: HBRequest, context: Context, @@ -35,6 +34,8 @@ struct DebugMiddleware: HBMiddlewareProtocol { @main struct MathsHandler: HBAPIGatewayLambda { + typealias Context = HBBasicLambdaRequestContext + struct Operands: Decodable { let lhs: Double let rhs: Double diff --git a/Tests/HummingbirdLambdaTests/LambdaTests.swift b/Tests/HummingbirdLambdaTests/LambdaTests.swift index 2aa1d00..2f548af 100644 --- a/Tests/HummingbirdLambdaTests/LambdaTests.swift +++ b/Tests/HummingbirdLambdaTests/LambdaTests.swift @@ -24,6 +24,8 @@ import XCTest final class LambdaTests: XCTestCase { func testSimpleRoute() async throws { struct HelloLambda: HBAPIGatewayLambda { + typealias Context = HBBasicLambdaRequestContext + init(context: LambdaInitializationContext) {} func buildResponder() -> some HBResponder { @@ -47,6 +49,7 @@ final class LambdaTests: XCTestCase { func testBase64Encoding() async throws { struct HelloLambda: HBAPIGatewayLambda { + typealias Context = HBBasicLambdaRequestContext init(context: LambdaInitializationContext) {} func buildResponder() -> some HBResponder { let router = HBRouter(context: Context.self) @@ -69,6 +72,7 @@ final class LambdaTests: XCTestCase { func testHeaderValues() async throws { struct HelloLambda: HBAPIGatewayLambda { + typealias Context = HBBasicLambdaRequestContext init(context: LambdaInitializationContext) {} func buildResponder() -> some HBResponder { @@ -101,6 +105,7 @@ final class LambdaTests: XCTestCase { func testQueryValues() async throws { struct HelloLambda: HBAPIGatewayLambda { + typealias Context = HBBasicLambdaRequestContext init(context: LambdaInitializationContext) {} func buildResponder() -> some HBResponder { @@ -129,6 +134,8 @@ final class LambdaTests: XCTestCase { func testErrorEncoding() async throws { struct HelloLambda: HBAPIGatewayLambda { + typealias Context = HBBasicLambdaRequestContext + static let body = "BadRequest" init(context: LambdaInitializationContext) {} @@ -152,10 +159,7 @@ final class LambdaTests: XCTestCase { func testSimpleRouteV2() async throws { struct HelloLambda: HBAPIGatewayV2Lambda { - // define input and output - typealias Event = APIGatewayV2Request - typealias Output = APIGatewayV2Response - typealias Context = HBBasicLambdaRequestContext + typealias Context = HBBasicLambdaRequestContext init(context: LambdaInitializationContext) {} @@ -180,6 +184,7 @@ final class LambdaTests: XCTestCase { func testBase64EncodingV2() async throws { struct HelloLambda: HBAPIGatewayV2Lambda { + typealias Context = HBBasicLambdaRequestContext init(context: LambdaInitializationContext) {} func buildResponder() -> some HBResponder { let router = HBRouter(context: Context.self) @@ -202,6 +207,7 @@ final class LambdaTests: XCTestCase { func testHeaderValuesV2() async throws { struct HelloLambda: HBAPIGatewayV2Lambda { + typealias Context = HBBasicLambdaRequestContext init(context: LambdaInitializationContext) {} func buildResponder() -> some HBResponder { @@ -234,6 +240,7 @@ final class LambdaTests: XCTestCase { func testQueryValuesV2() async throws { struct HelloLambda: HBAPIGatewayV2Lambda { + typealias Context = HBBasicLambdaRequestContext init(context: LambdaInitializationContext) {} func buildResponder() -> some HBResponder { 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 )"