From 8dd6986e92f0575db904a14fee7992742f230ea4 Mon Sep 17 00:00:00 2001 From: Mykola Buhaiov Date: Mon, 1 Jun 2026 10:05:30 +0300 Subject: [PATCH 1/5] feat: update to 6.2 swift --- .github/workflows/codeql.yml | 2 +- .github/workflows/docc.yml | 2 +- .github/workflows/test.yml | 12 ++++++------ Package.swift | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 3184663..cadeb2f 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 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/test.yml b/.github/workflows/test.yml index ab9e5a9..9195845 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,7 +19,7 @@ jobs: # macOS # ========================= macos: - runs-on: macos-15 + runs-on: macos-26 steps: - name: Checkout uses: actions/checkout@v4 @@ -38,14 +38,14 @@ jobs: ${{ runner.os }}-spm- - name: Build run: swift build -v - - name: Test (parallel) - run: swift test -v --parallel + - name: Run tests + run: swift test # ========================= # 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 +58,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"), ], From 642e65be7344b1aba985ded764633de8611871ef Mon Sep 17 00:00:00 2001 From: Mykola Buhaiov Date: Mon, 1 Jun 2026 10:17:43 +0300 Subject: [PATCH 2/5] fix: fix ci/cd --- .github/workflows/codeql.yml | 48 +++++++++++++++++++----------------- .github/workflows/lint.yml | 19 +++++++------- .github/workflows/test.yml | 14 ++++++++--- 3 files changed, 46 insertions(+), 35 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index cadeb2f..2665c46 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,41 +1,43 @@ -name: "CodeQL" +name: CodeQL on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] + schedule: + - cron: "0 3 * * 1" # щопонеділка о 3:00 -# Allow one concurrent deployment concurrency: - group: "scanning" - cancel-in-progress: true - + group: "scanning-${{ github.ref }}" + cancel-in-progress: false jobs: analyze: - name: Analyze + name: Analyze Swift runs-on: macos-26 permissions: + actions: read + contents: read security-events: write - strategy: - fail-fast: false - matrix: - language: [ 'swift' ] - steps: - - name: Checkout repository - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 - - name: Initialize CodeQL - uses: github/codeql-action/init@v4 - with: - languages: ${{ matrix.language }} + - name: Select Xcode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: "16.3.0" - - name: Build - run: swift build + - name: Initialize CodeQL + uses: github/codeql-action/init@v4 + with: + languages: swift + queries: security-extended # ширше покриття, ніж дефолт - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v4 + - name: Build + run: swift build + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v4 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 74a7701..5217ada 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,28 +2,29 @@ name: Lint code on: push: + pull_request: concurrency: - group: "linting" + group: "linting-${{ github.ref }}" cancel-in-progress: true jobs: SwiftLint: - runs-on: macOS-15 + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - - name: Select Xcode - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: "16.3.0" - - name: Install SwiftLint - run: brew install swiftlint + run: | + curl -fsSL \ + "https://github.com/realm/SwiftLint/releases/latest/download/swiftlint_linux.zip" \ + -o swiftlint.zip + unzip -q swiftlint.zip swiftlint + sudo mv swiftlint /usr/local/bin/ - name: Verify SwiftLint version 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 9195845..19a4650 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,14 +19,14 @@ jobs: # macOS # ========================= macos: - runs-on: macos-26 + runs-on: macos-15 steps: - name: Checkout uses: actions/checkout@v4 - 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: @@ -39,7 +39,15 @@ jobs: - name: Build run: swift build -v - name: Run tests - run: swift test + 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 # ========================= From 74fb116fc1f412ad287a5c0027e9250cbfb2d4bb Mon Sep 17 00:00:00 2001 From: Mykola Buhaiov Date: Mon, 1 Jun 2026 10:20:37 +0300 Subject: [PATCH 3/5] fix: fix ci/cd --- .github/workflows/codeql.yml | 57 +++++++++++++++++------------------- .github/workflows/lint.yml | 17 +++++------ 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 2665c46..4a25f86 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,43 +1,40 @@ -name: CodeQL +name: "CodeQL" on: push: - branches: ["main"] + branches: [ "main" ] pull_request: - branches: ["main"] - schedule: - - cron: "0 3 * * 1" # щопонеділка о 3:00 + branches: [ "main" ] +# Allow one concurrent deployment concurrency: - group: "scanning-${{ github.ref }}" - cancel-in-progress: false + group: "scanning" + cancel-in-progress: true + jobs: analyze: - name: Analyze Swift - runs-on: macos-26 + name: Analyze + runs-on: macos-15 permissions: - actions: read - contents: read security-events: write - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Select Xcode - uses: maxim-lobanov/setup-xcode@v1 - with: - xcode-version: "16.3.0" + strategy: + fail-fast: false + matrix: + language: [ 'swift' ] - - name: Initialize CodeQL - uses: github/codeql-action/init@v4 - with: - languages: swift - queries: security-extended # ширше покриття, ніж дефолт - - - name: Build - run: swift build - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v4 + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v4 + with: + languages: ${{ matrix.language }} + + - name: Build + run: swift build + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v4 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5217ada..66256e1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -2,26 +2,25 @@ name: Lint code on: push: - pull_request: concurrency: - group: "linting-${{ github.ref }}" + group: "linting" cancel-in-progress: true jobs: SwiftLint: - runs-on: ubuntu-latest + runs-on: macOS-15 steps: - name: Checkout uses: actions/checkout@v4 + - name: Select Xcode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: latest-stable + - name: Install SwiftLint - run: | - curl -fsSL \ - "https://github.com/realm/SwiftLint/releases/latest/download/swiftlint_linux.zip" \ - -o swiftlint.zip - unzip -q swiftlint.zip swiftlint - sudo mv swiftlint /usr/local/bin/ + run: brew install swiftlint - name: Verify SwiftLint version run: swiftlint version From b3025dd9cc8b98c1c7f32615d05bcbde14f3013e Mon Sep 17 00:00:00 2001 From: Mykola Buhaiov Date: Mon, 1 Jun 2026 10:32:31 +0300 Subject: [PATCH 4/5] fix: fix ci/cd --- .github/workflows/codeql.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 4a25f86..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 From 80b55a3329fb7c1b7fa9bc4d8ddadd6e91890f1b Mon Sep 17 00:00:00 2001 From: Mykola Buhaiov Date: Mon, 1 Jun 2026 11:15:19 +0300 Subject: [PATCH 5/5] fix: fix ci/cd --- Sources/ErrorMiddleware/ErrorMiddleware.swift | 6 +----- Tests/ErrorMiddlewareTests/ErrorMiddlewareTests.swift | 11 +++++++++++ 2 files changed, 12 insertions(+), 5 deletions(-) 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 {