Skip to content

Commit 475bf6f

Browse files
gwynneMahdiBM
andauthored
Fix mishandling of URL (#257)
* The usual round of various package cleanup * Fix mishandling of Foundation.URL by PostgresDataTranslation, including support for the broken encoding we were previously generating. * Apply suggestions from code review * Disable CodeQL for now --------- Co-authored-by: Mahdi Bahrami <[email protected]>
1 parent c7c2496 commit 475bf6f

15 files changed

+250
-89
lines changed

.api-breakage/allowlist-branch-update-for-new-pnio.txt

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
groups:
8+
dependencies:
9+
patterns:
10+
- "*"

.github/workflows/test.yml

Lines changed: 64 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,41 @@ env:
2525
jobs:
2626
# Check for API breakage versus main
2727
api-breakage:
28-
if: ${{ !(github.event.pull_request.draft || false) }}
28+
if: ${{ github.event_name == 'pull_request' && !(github.event.pull_request.draft || false) }}
2929
runs-on: ubuntu-latest
3030
container: swift:jammy
3131
steps:
32-
- name: Check out code
33-
uses: actions/checkout@v3
32+
- name: Checkout
33+
uses: actions/checkout@v4
3434
with: { 'fetch-depth': 0 }
35-
- name: Run API breakage check action
36-
uses: vapor/ci/.github/actions/ci-swift-check-api-breakage@main
35+
- name: API breaking changes
36+
run: |
37+
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
38+
swift package diagnose-api-breaking-changes origin/main
39+
40+
dependency-graph:
41+
if: ${{ github.event_name == 'push' }}
42+
runs-on: ubuntu-latest
43+
container: swift:jammy
44+
permissions:
45+
contents: write
46+
steps:
47+
- name: Check out code
48+
uses: actions/checkout@v4
49+
- name: Fix Git configuration
50+
run: |
51+
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
52+
apt-get update && apt-get install -y curl
53+
- name: Submit dependency graph
54+
uses: vapor-community/[email protected]
3755

3856
code-coverage:
3957
if: ${{ !(github.event.pull_request.draft || false) }}
4058
runs-on: ubuntu-latest
4159
container: swift:jammy
4260
services:
4361
psql-a:
44-
image: postgres:15
62+
image: postgres:16
4563
env:
4664
POSTGRES_USER: test_username
4765
POSTGRES_DB: test_database
@@ -50,58 +68,60 @@ jobs:
5068
POSTGRES_INITDB_ARGS: --auth-host=scram-sha-256
5169
steps:
5270
- name: Check out code
53-
uses: actions/checkout@v3
71+
uses: actions/checkout@v4
5472
- name: Run unit tests for coverage data
5573
run: swift test --enable-code-coverage
5674
- name: Upload coverage data
5775
uses: vapor/[email protected]
5876

5977
gh-codeql:
60-
if: ${{ !(github.event.pull_request.draft || false) }}
61-
strategy:
62-
fail-fast: false
63-
matrix:
64-
runner_os:
65-
- ubuntu-latest
66-
- macos-13
67-
runs-on: ${{ matrix.runner_os }}
68-
permissions:
69-
security-events: write
78+
if: ${{ false && !(github.event.pull_request.draft || false) }}
79+
runs-on: ubuntu-latest
80+
container:
81+
image: swift:5.9-jammy
82+
permissions: { actions: write, contents: read, security-events: write }
83+
timeout-minutes: 60
7084
steps:
71-
- name: Select appropriate Xcode version
72-
if: ${{ startsWith(matrix.runner_os, 'macos') }}
73-
uses: maxim-lobanov/setup-xcode@v1
74-
with: { xcode-version: '~14.3' }
7585
- name: Check out code
76-
uses: actions/checkout@v3
86+
uses: actions/checkout@v4
87+
- name: Mark repo safe in non-fake global config
88+
run: |
89+
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
90+
- name: Check Swift compatibility
91+
id: swift-check
92+
uses: vapor/ci/.github/actions/check-compatible-swift@main
7793
- name: Initialize CodeQL
78-
uses: github/codeql-action/init@v2
94+
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
95+
uses: github/codeql-action/init@v3
7996
with: { languages: swift }
8097
- name: Perform build
98+
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
8199
run: swift build
82100
- name: Run CodeQL analyze
83-
uses: github/codeql-action/analyze@v2
101+
if: ${{ steps.swift-check.outputs.swift-compatible == 'true' }}
102+
uses: github/codeql-action/analyze@v3
84103

85104
linux-unit:
86105
if: ${{ !(github.event.pull_request.draft || false) }}
87106
strategy:
88107
fail-fast: false
89108
matrix:
90109
postgres-image:
91-
- postgres:15
92-
- postgres:13
93-
- postgres:11
110+
- postgres:16
111+
- postgres:14
112+
- postgres:12
94113
swift-image:
95114
- swift:5.7-jammy
96115
- swift:5.8-jammy
97-
- swiftlang/swift:nightly-5.9-jammy
116+
- swift:5.9-jammy
117+
- swiftlang/swift:nightly-5.10-jammy
98118
- swiftlang/swift:nightly-main-jammy
99119
include:
100-
- postgres-image: postgres:15
120+
- postgres-image: postgres:16
101121
postgres-auth: scram-sha-256
102-
- postgres-image: postgres:13
122+
- postgres-image: postgres:14
103123
postgres-auth: md5
104-
- postgres-image: postgres:11
124+
- postgres-image: postgres:12
105125
postgres-auth: trust
106126
runs-on: ubuntu-latest
107127
container: ${{ matrix.swift-image }}
@@ -116,17 +136,17 @@ jobs:
116136
POSTGRES_INITDB_ARGS: --auth-host=${{ matrix.postgres-auth }}
117137
steps:
118138
- name: Check out package
119-
uses: actions/checkout@v3
139+
uses: actions/checkout@v4
120140
- name: Run local tests
121141
run: swift test
122142

123143
linux-integration:
124144
if: ${{ !(github.event.pull_request.draft || false) }}
125145
runs-on: ubuntu-latest
126-
container: swift:5.8-jammy
146+
container: swift:5.9-jammy
127147
services:
128148
psql-a:
129-
image: postgres:15
149+
image: postgres:16
130150
env:
131151
POSTGRES_USER: test_username
132152
POSTGRES_DB: test_database
@@ -143,10 +163,10 @@ jobs:
143163
POSTGRES_INITDB_ARGS: --auth-host=scram-sha-256
144164
steps:
145165
- name: Check out package
146-
uses: actions/checkout@v3
166+
uses: actions/checkout@v4
147167
with: { path: 'postgres-kit' }
148168
- name: Check out fluent-postgres-driver dependent
149-
uses: actions/checkout@v3
169+
uses: actions/checkout@v4
150170
with: { repository: 'vapor/fluent-postgres-driver', path: 'fluent-postgres-driver' }
151171
- name: Use local package
152172
run: swift package --package-path fluent-postgres-driver edit postgres-kit --path postgres-kit
@@ -158,10 +178,12 @@ jobs:
158178
strategy:
159179
fail-fast: false
160180
matrix:
161-
xcode-version:
162-
- '~14.3'
163-
- '15.0-beta'
164-
runs-on: macos-13
181+
include:
182+
- macos-version: macos-13
183+
xcode-version: '~14.3'
184+
- macos-version: macos-14
185+
xcode-version: latest
186+
runs-on: ${{ matrix.macos-version }}
165187
env:
166188
POSTGRES_HOSTNAME: 127.0.0.1
167189
POSTGRES_DB: postgres
@@ -173,11 +195,11 @@ jobs:
173195
- name: Install Postgres, setup DB and auth, and wait for server start
174196
run: |
175197
export PATH="$(brew --prefix)/opt/postgresql@14/bin:$PATH" PGDATA=/tmp/vapor-postgres-test
176-
(brew unlink postgresql || true) && brew install "postgresql@14" && brew link --force "postgresql@14"
198+
(brew unlink postgresql || true) && brew install "postgresql@15" && brew link --force "postgresql@15"
177199
initdb --locale=C --auth-host "scram-sha-256" -U "${POSTGRES_USER}" --pwfile=<(echo "${POSTGRES_PASSWORD}")
178200
pg_ctl start --wait
179201
timeout-minutes: 2
180202
- name: Checkout code
181-
uses: actions/checkout@v3
203+
uses: actions/checkout@v4
182204
- name: Run local tests
183205
run: swift test

[email protected]

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// swift-tools-version:5.9
2+
import PackageDescription
3+
4+
let swiftSettings: [SwiftSetting] = [
5+
.enableUpcomingFeature("ExistentialAny"),
6+
.enableUpcomingFeature("ConciseMagicFile"),
7+
.enableUpcomingFeature("ForwardTrailingClosures"),
8+
.enableUpcomingFeature("DisableOutwardActorInference"),
9+
.enableExperimentalFeature("StrictConcurrency=complete"),
10+
]
11+
12+
let package = Package(
13+
name: "postgres-kit",
14+
platforms: [
15+
.macOS(.v10_15),
16+
.iOS(.v13),
17+
.watchOS(.v6),
18+
.tvOS(.v13),
19+
],
20+
products: [
21+
.library(name: "PostgresKit", targets: ["PostgresKit"]),
22+
],
23+
dependencies: [
24+
.package(url: "https://github.com/vapor/postgres-nio.git", from: "1.20.0"),
25+
.package(url: "https://github.com/vapor/sql-kit.git", from: "3.28.0"),
26+
.package(url: "https://github.com/vapor/async-kit.git", from: "1.19.0"),
27+
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.2.0")
28+
],
29+
targets: [
30+
.target(
31+
name: "PostgresKit",
32+
dependencies: [
33+
.product(name: "AsyncKit", package: "async-kit"),
34+
.product(name: "PostgresNIO", package: "postgres-nio"),
35+
.product(name: "SQLKit", package: "sql-kit"),
36+
.product(name: "Atomics", package: "swift-atomics"),
37+
],
38+
swiftSettings: swiftSettings
39+
),
40+
.testTarget(
41+
name: "PostgresKitTests",
42+
dependencies: [
43+
.target(name: "PostgresKit"),
44+
.product(name: "SQLKitBenchmark", package: "sql-kit"),
45+
],
46+
swiftSettings: swiftSettings
47+
),
48+
]
49+
)

README.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
1-
<img src="https://user-images.githubusercontent.com/1342803/59063319-d190f500-8875-11e9-8fe6-16197dd56d0f.png" height="64" alt="PostgresKit">
1+
<p align="center">
2+
<picture>
3+
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/vapor/postgres-kit/assets/1130717/02ca33b1-d788-4846-8280-7cd89f09c397">
4+
<source media="(prefers-color-scheme: light)" srcset="https://github.com/vapor/postgres-kit/assets/1130717/91de055b-0e4f-42f3-8257-946ac40d731c">
5+
<img src="https://github.com/vapor/postgres-kit/assets/1130717/91de055b-0e4f-42f3-8257-946ac40d731c" height="96" alt="PostgresKit">
6+
</picture>
27
<br>
3-
<a href="https://docs.vapor.codes/4.0/">
4-
<img src="http://img.shields.io/badge/read_the-docs-2196f3.svg" alt="Documentation">
5-
</a>
6-
<a href="https://discord.gg/vapor">
7-
<img src="https://img.shields.io/discord/431917998102675485.svg" alt="Team Chat">
8-
</a>
9-
<a href="LICENSE">
10-
<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License">
11-
</a>
12-
<a href="https://github.com/vapor/postgres-kit/actions">
13-
<img src="https://github.com/vapor/postgres-kit/workflows/test/badge.svg" alt="Continuous Integration">
14-
</a>
15-
<a href="https://swift.org">
16-
<img src="http://img.shields.io/badge/swift-5.2-brightgreen.svg" alt="Swift 5.2">
17-
</a>
188
<br>
9+
<a href="https://docs.vapor.codes/4.0/"><img src="https://design.vapor.codes/images/readthedocs.svg" alt="Documentation"></a>
10+
<a href="https://discord.gg/vapor"><img src="https://design.vapor.codes/images/discordchat.svg" alt="Team Chat"></a>
11+
<a href="LICENSE"><img src="https://design.vapor.codes/images/mitlicense.svg" alt="MIT License"></a>
12+
<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>
13+
<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>
14+
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift57up.svg" alt="Swift 5.7+"></a>
15+
</p>
16+
1917
<br>
2018

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

4038
PostgresKit supports the following platforms:
4139

42-
- Ubuntu 16.04+
40+
- Ubuntu 20.04+
4341
- macOS 10.15+
4442

4543
## Overview

Sources/PostgresKit/ConnectionPool+Postgres.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import NIOCore
22
import PostgresNIO
3-
import AsyncKit
3+
@preconcurrency import AsyncKit
44
import Logging
55

66
extension EventLoopGroupConnectionPool where Source == PostgresConnectionSource {

Sources/PostgresKit/Deprecations/PostgresConnectionSource+PostgresConfiguration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extension PostgresConnectionSource {
3434
}
3535

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

3939
@available(*, deprecated, message: "Use `init(sqlConfiguration:)` instead.")
4040
public init(configuration: PostgresConfiguration) {

Sources/PostgresKit/Deprecations/PostgresDataEncoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public final class PostgresDataEncoder {
99
self.json = json
1010
}
1111

12-
public func encode(_ value: Encodable) throws -> PostgresData {
12+
public func encode(_ value: any Encodable) throws -> PostgresData {
1313
if let custom = value as? any PostgresDataConvertible, let data = custom.postgresData {
1414
return data
1515
} else {
Lines changed: 22 additions & 0 deletions
Loading
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"theme": {
3+
"aside": { "border-radius": "6px", "border-style": "double", "border-width": "3px" },
4+
"border-radius": "0",
5+
"button": { "border-radius": "16px", "border-width": "1px", "border-style": "solid" },
6+
"code": { "border-radius": "16px", "border-width": "1px", "border-style": "solid" },
7+
"color": {
8+
"psqlkit": "#336791",
9+
"documentation-intro-fill": "radial-gradient(circle at top, var(--color-psqlkit) 30%, #000 100%)",
10+
"documentation-intro-accent": "var(--color-psqlkit)",
11+
"logo-base": { "dark": "#fff", "light": "#000" },
12+
"logo-shape": { "dark": "#000", "light": "#fff" },
13+
"fill": { "dark": "#000", "light": "#fff" }
14+
},
15+
"icons": { "technology": "/postgreskit/images/vapor-postgreskit-logo.svg" }
16+
},
17+
"features": {
18+
"quickNavigation": { "enable": true },
19+
"i18n": { "enable": true }
20+
}
21+
}

0 commit comments

Comments
 (0)