Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .api-breakage/allowlist-branch-update-for-new-pnio.txt

This file was deleted.

10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
groups:
dependencies:
patterns:
- "*"
96 changes: 58 additions & 38 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,41 @@ env:
jobs:
# Check for API breakage versus main
api-breakage:
if: ${{ !(github.event.pull_request.draft || false) }}
if: ${{ github.event_name == 'pull_request' && !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:jammy
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
with: { 'fetch-depth': 0 }
- name: Run API breakage check action
uses: vapor/ci/.github/actions/ci-swift-check-api-breakage@main
- name: API breaking changes
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
swift package diagnose-api-breaking-changes origin/main

dependency-graph:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
container: swift:jammy
permissions:
contents: write
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Fix Git configuration
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
apt-get update && apt-get install -y curl
- name: Submit dependency graph
uses: vapor-community/[email protected]

code-coverage:
if: ${{ !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:jammy
services:
psql-a:
image: postgres:15
image: postgres:16
env:
POSTGRES_USER: test_username
POSTGRES_DB: test_database
Expand All @@ -50,58 +68,60 @@ jobs:
POSTGRES_INITDB_ARGS: --auth-host=scram-sha-256
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run unit tests for coverage data
run: swift test --enable-code-coverage
- name: Upload coverage data
uses: vapor/[email protected]

gh-codeql:
if: ${{ !(github.event.pull_request.draft || false) }}
strategy:
fail-fast: false
matrix:
runner_os:
- ubuntu-latest
- macos-13
runs-on: ${{ matrix.runner_os }}
permissions:
security-events: write
runs-on: ubuntu-latest
container:
image: swift:5.9-jammy
permissions: { actions: write, contents: read, security-events: write }
timeout-minutes: 60
steps:
- name: Select appropriate Xcode version
if: ${{ startsWith(matrix.runner_os, 'macos') }}
uses: maxim-lobanov/setup-xcode@v1
with: { xcode-version: '~14.3' }
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Mark repo safe in non-fake global config
run: |
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
- name: Check Swift compatibility
id: swift-check
uses: vapor/ci/.github/actions/check-compatible-swift@main
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
uses: github/codeql-action/init@v3
with: { languages: swift }
- name: Perform build
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
run: swift build
- name: Run CodeQL analyze
uses: github/codeql-action/analyze@v2
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
uses: github/codeql-action/analyze@v3

linux-unit:
if: ${{ !(github.event.pull_request.draft || false) }}
strategy:
fail-fast: false
matrix:
postgres-image:
- postgres:15
- postgres:13
- postgres:11
- postgres:16
- postgres:14
- postgres:12
swift-image:
- swift:5.7-jammy
- swift:5.8-jammy
- swiftlang/swift:nightly-5.9-jammy
- swift:5.9-jammy
- swiftlang/swift:nightly-5.10-jammy
- swiftlang/swift:nightly-main-jammy
include:
- postgres-image: postgres:15
- postgres-image: postgres:16
postgres-auth: scram-sha-256
- postgres-image: postgres:13
- postgres-image: postgres:14
postgres-auth: md5
- postgres-image: postgres:11
- postgres-image: postgres:12
postgres-auth: trust
runs-on: ubuntu-latest
container: ${{ matrix.swift-image }}
Expand All @@ -116,17 +136,17 @@ jobs:
POSTGRES_INITDB_ARGS: --auth-host=${{ matrix.postgres-auth }}
steps:
- name: Check out package
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run local tests
run: swift test

linux-integration:
if: ${{ !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:5.8-jammy
container: swift:5.9-jammy
services:
psql-a:
image: postgres:15
image: postgres:16
env:
POSTGRES_USER: test_username
POSTGRES_DB: test_database
Expand All @@ -143,10 +163,10 @@ jobs:
POSTGRES_INITDB_ARGS: --auth-host=scram-sha-256
steps:
- name: Check out package
uses: actions/checkout@v3
uses: actions/checkout@v4
with: { path: 'postgres-kit' }
- name: Check out fluent-postgres-driver dependent
uses: actions/checkout@v3
uses: actions/checkout@v4
with: { repository: 'vapor/fluent-postgres-driver', path: 'fluent-postgres-driver' }
- name: Use local package
run: swift package --package-path fluent-postgres-driver edit postgres-kit --path postgres-kit
Expand All @@ -160,7 +180,7 @@ jobs:
matrix:
xcode-version:
- '~14.3'
- '15.0-beta'
- 'latest'
runs-on: macos-13
env:
POSTGRES_HOSTNAME: 127.0.0.1
Expand All @@ -173,11 +193,11 @@ jobs:
- name: Install Postgres, setup DB and auth, and wait for server start
run: |
export PATH="$(brew --prefix)/opt/postgresql@14/bin:$PATH" PGDATA=/tmp/vapor-postgres-test
(brew unlink postgresql || true) && brew install "postgresql@14" && brew link --force "postgresql@14"
(brew unlink postgresql || true) && brew install "postgresql@15" && brew link --force "postgresql@15"
initdb --locale=C --auth-host "scram-sha-256" -U "${POSTGRES_USER}" --pwfile=<(echo "${POSTGRES_PASSWORD}")
pg_ctl start --wait
timeout-minutes: 2
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Run local tests
run: swift test
49 changes: 49 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// swift-tools-version:5.9
import PackageDescription

let swiftSettings: [SwiftSetting] = [
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("ConciseMagicFile"),
.enableUpcomingFeature("ForwardTrailingClosures"),
.enableUpcomingFeature("DisableOutwardActorInference"),
.enableExperimentalFeature("StrictConcurrency=complete"),
]

let package = Package(
name: "postgres-kit",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.watchOS(.v6),
.tvOS(.v13),
],
products: [
.library(name: "PostgresKit", targets: ["PostgresKit"]),
],
dependencies: [
.package(url: "https://github.com/vapor/postgres-nio.git", from: "1.20.0"),
.package(url: "https://github.com/vapor/sql-kit.git", from: "3.28.0"),
.package(url: "https://github.com/vapor/async-kit.git", from: "1.19.0"),
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.2.0")
],
targets: [
.target(
name: "PostgresKit",
dependencies: [
.product(name: "AsyncKit", package: "async-kit"),
.product(name: "PostgresNIO", package: "postgres-nio"),
.product(name: "SQLKit", package: "sql-kit"),
.product(name: "Atomics", package: "swift-atomics"),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "PostgresKitTests",
dependencies: [
.target(name: "PostgresKit"),
.product(name: "SQLKitBenchmark", package: "sql-kit"),
],
swiftSettings: swiftSettings
),
]
)
32 changes: 15 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
<img src="https://user-images.githubusercontent.com/1342803/59063319-d190f500-8875-11e9-8fe6-16197dd56d0f.png" height="64" alt="PostgresKit">
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/vapor/postgres-kit/assets/1130717/02ca33b1-d788-4846-8280-7cd89f09c397">
<source media="(prefers-color-scheme: light)" srcset="https://github.com/vapor/postgres-kit/assets/1130717/91de055b-0e4f-42f3-8257-946ac40d731c">
<img src="https://github.com/vapor/postgres-kit/assets/1130717/91de055b-0e4f-42f3-8257-946ac40d731c" height="96" alt="PostgresKit">
</picture>
<br>
<a href="https://docs.vapor.codes/4.0/">
<img src="http://img.shields.io/badge/read_the-docs-2196f3.svg" alt="Documentation">
</a>
<a href="https://discord.gg/vapor">
<img src="https://img.shields.io/discord/431917998102675485.svg" alt="Team Chat">
</a>
<a href="LICENSE">
<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License">
</a>
<a href="https://github.com/vapor/postgres-kit/actions">
<img src="https://github.com/vapor/postgres-kit/workflows/test/badge.svg" alt="Continuous Integration">
</a>
<a href="https://swift.org">
<img src="http://img.shields.io/badge/swift-5.2-brightgreen.svg" alt="Swift 5.2">
</a>
<br>
<a href="https://docs.vapor.codes/4.0/"><img src="https://design.vapor.codes/images/readthedocs.svg" alt="Documentation"></a>
<a href="https://discord.gg/vapor"><img src="https://design.vapor.codes/images/discordchat.svg" alt="Team Chat"></a>
<a href="LICENSE"><img src="https://design.vapor.codes/images/mitlicense.svg" alt="MIT License"></a>
<a href="https://github.com/vapor/postgres-kit/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/vapor/postgres-kit/test.yml?event=push&style=plastic&logo=github&label=tests&logoColor=%23ccc" alt="Continuous Integration"></a>
<a href="https://codecov.io/github/vapor/postgres-kit"><img src="https://img.shields.io/codecov/c/github/vapor/postgres-kit?style=plastic&logo=codecov&label=codecov"></a>
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift57up.svg" alt="Swift 5.7+"></a>
</p>

<br>

🐘 Non-blocking, event-driven Swift client for PostgreSQL.
Expand All @@ -39,7 +37,7 @@ Use the SPM string to easily include the dependendency in your `Package.swift` f

PostgresKit supports the following platforms:

- Ubuntu 16.04+
- Ubuntu 20.04+
- macOS 10.15+

## Overview
Expand Down
2 changes: 1 addition & 1 deletion Sources/PostgresKit/ConnectionPool+Postgres.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import NIOCore
import PostgresNIO
import AsyncKit
@preconcurrency import AsyncKit
import Logging

extension EventLoopGroupConnectionPool where Source == PostgresConnectionSource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extension PostgresConnectionSource {
}

@available(*, deprecated, message: "Use `sqlConfiguration` instead.")
public var sslContext: Result<NIOSSLContext?, Error> { .success(self.sqlConfiguration.coreConfiguration.tls.sslContext) }
public var sslContext: Result<NIOSSLContext?, any Error> { .success(self.sqlConfiguration.coreConfiguration.tls.sslContext) }

@available(*, deprecated, message: "Use `init(sqlConfiguration:)` instead.")
public init(configuration: PostgresConfiguration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public final class PostgresDataEncoder {
self.json = json
}

public func encode(_ value: Encodable) throws -> PostgresData {
public func encode(_ value: any Encodable) throws -> PostgresData {
if let custom = value as? any PostgresDataConvertible, let data = custom.postgresData {
return data
} else {
Expand Down
22 changes: 22 additions & 0 deletions Sources/PostgresKit/Docs.docc/images/vapor-postgreskit-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions Sources/PostgresKit/Docs.docc/theme-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"theme": {
"aside": { "border-radius": "6px", "border-style": "double", "border-width": "3px" },
"border-radius": "0",
"button": { "border-radius": "16px", "border-width": "1px", "border-style": "solid" },
"code": { "border-radius": "16px", "border-width": "1px", "border-style": "solid" },
"color": {
"psqlkit": "#336791",
"documentation-intro-fill": "radial-gradient(circle at top, var(--color-psqlkit) 30%, #000 100%)",
"documentation-intro-accent": "var(--color-psqlkit)",
"logo-base": { "dark": "#fff", "light": "#000" },
"logo-shape": { "dark": "#000", "light": "#fff" },
"fill": { "dark": "#000", "light": "#fff" }
},
"icons": { "technology": "/postgreskit/images/vapor-postgreskit-logo.svg" }
},
"features": {
"quickNavigation": { "enable": true },
"i18n": { "enable": true }
}
}
Loading