diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 3184663..c6b8675 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -15,7 +15,7 @@ concurrency: jobs: analyze: name: Analyze - runs-on: macos-15 + runs-on: macos-26 permissions: security-events: write @@ -35,7 +35,6 @@ jobs: - name: Build run: swift build - + - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v4 - diff --git a/.github/workflows/docc.yml b/.github/workflows/docc.yml index 00d05c5..d44cd48 100644 --- a/.github/workflows/docc.yml +++ b/.github/workflows/docc.yml @@ -18,7 +18,7 @@ jobs: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - runs-on: macos-15 + runs-on: macos-26 steps: - name: Checkout 🛎️ diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 74a7701..66256e1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -17,7 +17,7 @@ jobs: - name: Select Xcode uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: "16.3.0" + xcode-version: latest-stable - name: Install SwiftLint run: brew install swiftlint @@ -26,4 +26,4 @@ jobs: run: swiftlint version - name: Run SwiftLint - run: swiftlint --strict --config .swiftlint.yml + run: swiftlint --config .swiftlint.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ab9e5a9..19a4650 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,7 +26,7 @@ jobs: - name: Select Xcode uses: maxim-lobanov/setup-xcode@v1 with: - xcode-version: "16.3.0" + xcode-version: latest-stable - name: Cache SwiftPM uses: actions/cache@v4 with: @@ -38,14 +38,22 @@ jobs: ${{ runner.os }}-spm- - name: Build run: swift build -v - - name: Test (parallel) - run: swift test -v --parallel + - name: Run tests + run: swift test -v --enable-code-coverage + - name: Fetch Coverage + id: coverage-files + uses: sersoft-gmbh/swift-coverage-action@v4 + - name: Publish Coverage to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ${{ steps.coverage-files.outputs.files }} # ========================= # Linux # ========================= linux: runs-on: ubuntu-latest - container: swift:6.0-jammy + container: swift:6.2-jammy steps: - name: Checkout uses: actions/checkout@v4 @@ -58,5 +66,5 @@ jobs: linux-spm- - name: Build run: swift build -v - - name: Test (parallel) - run: swift test -v --parallel + - name: Run tests + run: swift test diff --git a/Package.swift b/Package.swift index b527729..7c96e0e 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version: 6.0 +// swift-tools-version: 6.2 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription @@ -6,7 +6,7 @@ import PackageDescription let package = Package( name: "fs-error-middleware", platforms: [ - .macOS(.v13) + .macOS(.v15) ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. @@ -17,7 +17,7 @@ let package = Package( ], dependencies: [ // 💧 A server-side Swift web framework. - .package(url: "https://github.com/vapor/vapor.git", from: "4.115.0"), + .package(url: "https://github.com/vapor/vapor.git", from: "4.120.0"), // 📄 Swift-DocC plugin for generating documentation. .package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.0.0"), ], diff --git a/Sources/ErrorMiddleware/ErrorMiddleware.swift b/Sources/ErrorMiddleware/ErrorMiddleware.swift index 6ab1e9c..e453825 100644 --- a/Sources/ErrorMiddleware/ErrorMiddleware.swift +++ b/Sources/ErrorMiddleware/ErrorMiddleware.swift @@ -28,11 +28,7 @@ import Foundation /// Extension for ErrorMiddleware. public extension ErrorMiddleware { /// Creates a custom `ErrorMiddleware` for handling errors in a Vapor application. - /// - /// This function provides a tailored error handling mechanism based on the application's environment - /// and an additional numeric identifier. It categorizes errors into specific cases, assigns appropriate - /// HTTP status codes, and generates error responses in JSON format. - /// + /// /// - Parameters: /// - environment: The current `Environment` of the application, used to determine error visibility and debugging details. /// - number: An additional numeric identifier to uniquely identify error codes. diff --git a/Tests/ErrorMiddlewareTests/ErrorMiddlewareTests.swift b/Tests/ErrorMiddlewareTests/ErrorMiddlewareTests.swift index 764e47d..1c83aeb 100644 --- a/Tests/ErrorMiddlewareTests/ErrorMiddlewareTests.swift +++ b/Tests/ErrorMiddlewareTests/ErrorMiddlewareTests.swift @@ -33,6 +33,17 @@ struct ErrorMiddlewareTests { } try await app.asyncShutdown() } + + @Test("Error middleware success") + func errorMiddlewareSuccess() async throws { + try await withApp { app in + app.middleware.use(ErrorMiddleware.custom(environment: app.environment, for: 1)) + + try await app.test(.POST, "order") { res throws in + #expect(res.status == .ok) + } + } + } @Test("Error middleware snake case") func errorMiddlewareSnakeCase() async throws {