From 6245a07310c4f0ece2355de43108bd8c068c229a Mon Sep 17 00:00:00 2001 From: Tim Condon <0xTim@users.noreply.github.com> Date: Fri, 24 Feb 2023 01:29:49 +0000 Subject: [PATCH] Add API Docs (#318) * Update SPI Info * Update API Docs workflow * Update CI * Add DocC bundle * Wrap exports * Fix the imports --- .github/workflows/api-docs.yml | 24 ++++++++------------ .github/workflows/test.yml | 11 +++++++++ .spi.yml | 4 +++- Sources/MySQLKit/ConnectionPool+MySQL.swift | 5 ++++ Sources/MySQLKit/Docs.docc/index.md | 3 +++ Sources/MySQLKit/Exports.swift | 7 ++++++ Sources/MySQLKit/MySQLConfiguration.swift | 6 ++--- Sources/MySQLKit/MySQLConnectionSource.swift | 5 ++++ Sources/MySQLKit/MySQLDataEncoder.swift | 1 + Sources/MySQLKit/MySQLDatabase+SQL.swift | 3 +++ Sources/MySQLKit/MySQLDialect.swift | 2 ++ Sources/MySQLKit/MySQLRow+SQL.swift | 3 +++ Tests/MySQLKitTests/MySQLKitTests.swift | 2 ++ 13 files changed, 58 insertions(+), 18 deletions(-) create mode 100644 Sources/MySQLKit/Docs.docc/index.md diff --git a/.github/workflows/api-docs.yml b/.github/workflows/api-docs.yml index d521498e..9e990048 100644 --- a/.github/workflows/api-docs.yml +++ b/.github/workflows/api-docs.yml @@ -1,18 +1,14 @@ name: deploy-api-docs on: - push: - branches: - - main + push: + branches: + - main jobs: - deploy: - name: api.vapor.codes - runs-on: ubuntu-latest - steps: - - name: Deploy api-docs - uses: appleboy/ssh-action@master - with: - host: vapor.codes - username: vapor - key: ${{ secrets.VAPOR_CODES_SSH_KEY }} - script: ./github-actions/deploy-api-docs.sh + build-and-deploy: + uses: vapor/api-docs/.github/workflows/build-and-deploy-docs-workflow.yml@main + secrets: inherit + with: + package_name: mysql-kit + modules: MySQLKit + pathsToInvalidate: /mysqlkit diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3a041c64..6288c7ef 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -189,3 +189,14 @@ jobs: run: swift test --sanitize=thread env: MYSQL_HOSTNAME: '127.0.0.1' + + test-exports: + name: Test exports + runs-on: ubuntu-latest + steps: + - name: Check out Vapor + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Build + run: swift build -Xswiftc -DBUILDING_DOCC diff --git a/.spi.yml b/.spi.yml index 05c541ce..7c8587cf 100644 --- a/.spi.yml +++ b/.spi.yml @@ -1,3 +1,5 @@ version: 1 metadata: - authors: “Maintained by the Vapor Core Team with hundreds of contributions from the Vapor Community.” + authors: "Maintained by the Vapor Core Team with hundreds of contributions from the Vapor Community." +external_links: + documentation: "https://api.vapor.codes/postgreskit/documentation/postgreskit/" diff --git a/Sources/MySQLKit/ConnectionPool+MySQL.swift b/Sources/MySQLKit/ConnectionPool+MySQL.swift index bf3cc194..c4c23d69 100644 --- a/Sources/MySQLKit/ConnectionPool+MySQL.swift +++ b/Sources/MySQLKit/ConnectionPool+MySQL.swift @@ -1,3 +1,8 @@ +import NIOCore +import AsyncKit +import Logging +import MySQLNIO + extension EventLoopConnectionPool where Source == MySQLConnectionSource { public func database(logger: Logger) -> MySQLDatabase { _EventLoopConnectionPoolMySQLDatabase(pool: self, logger: logger) diff --git a/Sources/MySQLKit/Docs.docc/index.md b/Sources/MySQLKit/Docs.docc/index.md new file mode 100644 index 00000000..7fd16d87 --- /dev/null +++ b/Sources/MySQLKit/Docs.docc/index.md @@ -0,0 +1,3 @@ +# ``MySQLKit`` + +MySQLKit is a library to provide a simple Swift interface to MySQLNIO using SQLKit. diff --git a/Sources/MySQLKit/Exports.swift b/Sources/MySQLKit/Exports.swift index 1182ad11..b49b9019 100644 --- a/Sources/MySQLKit/Exports.swift +++ b/Sources/MySQLKit/Exports.swift @@ -1,3 +1,10 @@ +#if !BUILDING_DOCC + @_exported import MySQLNIO @_exported import AsyncKit @_exported import SQLKit +@_exported import struct Foundation.URL +@_exported import struct Foundation.Data +@_exported import struct NIOSSL.TLSConfiguration + +#endif \ No newline at end of file diff --git a/Sources/MySQLKit/MySQLConfiguration.swift b/Sources/MySQLKit/MySQLConfiguration.swift index 150f747b..12185665 100644 --- a/Sources/MySQLKit/MySQLConfiguration.swift +++ b/Sources/MySQLKit/MySQLConfiguration.swift @@ -1,6 +1,6 @@ -@_exported import struct Foundation.URL -@_exported import struct Foundation.Data -@_exported import struct NIOSSL.TLSConfiguration +import Foundation +import NIOSSL +import NIOCore public struct MySQLConfiguration { public var address: () throws -> SocketAddress diff --git a/Sources/MySQLKit/MySQLConnectionSource.swift b/Sources/MySQLKit/MySQLConnectionSource.swift index b05dcd88..f3618b98 100644 --- a/Sources/MySQLKit/MySQLConnectionSource.swift +++ b/Sources/MySQLKit/MySQLConnectionSource.swift @@ -1,3 +1,8 @@ +import NIOCore +import Logging +import MySQLNIO +import AsyncKit + public struct MySQLConnectionSource: ConnectionPoolSource { public let configuration: MySQLConfiguration diff --git a/Sources/MySQLKit/MySQLDataEncoder.swift b/Sources/MySQLKit/MySQLDataEncoder.swift index 86381b92..c1a5c9dc 100644 --- a/Sources/MySQLKit/MySQLDataEncoder.swift +++ b/Sources/MySQLKit/MySQLDataEncoder.swift @@ -1,4 +1,5 @@ import Foundation +import MySQLNIO public struct MySQLDataEncoder { let json: JSONEncoder diff --git a/Sources/MySQLKit/MySQLDatabase+SQL.swift b/Sources/MySQLKit/MySQLDatabase+SQL.swift index 2bba7c47..ee3d3a96 100644 --- a/Sources/MySQLKit/MySQLDatabase+SQL.swift +++ b/Sources/MySQLKit/MySQLDatabase+SQL.swift @@ -1,3 +1,6 @@ +import MySQLNIO +import SQLKit + extension MySQLDatabase { public func sql( encoder: MySQLDataEncoder = .init(), diff --git a/Sources/MySQLKit/MySQLDialect.swift b/Sources/MySQLKit/MySQLDialect.swift index aa77df3f..1d1ca4f2 100644 --- a/Sources/MySQLKit/MySQLDialect.swift +++ b/Sources/MySQLKit/MySQLDialect.swift @@ -1,4 +1,6 @@ import enum Crypto.Insecure +import SQLKit +import Foundation public struct MySQLDialect: SQLDialect { public init() {} diff --git a/Sources/MySQLKit/MySQLRow+SQL.swift b/Sources/MySQLKit/MySQLRow+SQL.swift index 5e718540..5cea9240 100644 --- a/Sources/MySQLKit/MySQLRow+SQL.swift +++ b/Sources/MySQLKit/MySQLRow+SQL.swift @@ -1,3 +1,6 @@ +import MySQLNIO +import SQLKit + extension MySQLRow { public func sql(decoder: MySQLDataDecoder = .init()) -> SQLRow { _MySQLSQLRow(row: self, decoder: decoder) diff --git a/Tests/MySQLKitTests/MySQLKitTests.swift b/Tests/MySQLKitTests/MySQLKitTests.swift index abd01acb..0dae67b8 100644 --- a/Tests/MySQLKitTests/MySQLKitTests.swift +++ b/Tests/MySQLKitTests/MySQLKitTests.swift @@ -4,6 +4,8 @@ import SQLKitBenchmark import XCTest import NIOSSL import AsyncKit +import SQLKit +import MySQLNIO class MySQLKitTests: XCTestCase { func testSQLBenchmark() throws {