Skip to content

Commit cd3d999

Browse files
authored
Use vapor/ci linting (#22)
1 parent 6ce2b23 commit cd3d999

File tree

5 files changed

+11
-92
lines changed

5 files changed

+11
-92
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,9 @@ on:
77
push: { branches: [ main ] }
88

99
jobs:
10-
lint:
11-
runs-on: ubuntu-latest
12-
container: swift:jammy
13-
steps:
14-
- name: Check out SendGridKit
15-
uses: actions/checkout@v4
16-
- name: Run format lint check
17-
run: swift format lint --strict --recursive --parallel .
18-
1910
unit-tests:
2011
uses: vapor/ci/.github/workflows/run-unit-tests.yml@main
12+
with:
13+
with_linting: true
2114
secrets:
2215
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.swift-format

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

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let package = Package(
1010
.library(name: "SendGridKit", targets: ["SendGridKit"])
1111
],
1212
dependencies: [
13-
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.22.0")
13+
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.23.0")
1414
],
1515
targets: [
1616
.target(

Sources/SendGridKit/SendGridClient.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,10 @@ public struct SendGridClient: Sendable {
3030
public init(httpClient: HTTPClient, apiKey: String, forEU: Bool = false) {
3131
self.httpClient = httpClient
3232
self.apiKey = apiKey
33-
self.apiURL =
34-
forEU
35-
? "https://api.eu.sendgrid.com/v3/mail/send" : "https://api.sendgrid.com/v3/mail/send"
33+
self.apiURL = forEU ? "https://api.eu.sendgrid.com/v3/mail/send" : "https://api.sendgrid.com/v3/mail/send"
3634
}
3735

38-
public func send<DynamicTemplateData: Codable & Sendable>(
39-
email: SendGridEmail<DynamicTemplateData>
40-
) async throws {
36+
public func send<DynamicTemplateData: Codable & Sendable>(email: SendGridEmail<DynamicTemplateData>) async throws {
4137
var headers = HTTPHeaders()
4238
headers.add(name: "Authorization", value: "Bearer \(apiKey)")
4339
headers.add(name: "Content-Type", value: "application/json")
@@ -53,7 +49,6 @@ public struct SendGridClient: Sendable {
5349
if (200...299).contains(response.status.code) { return }
5450

5551
// `JSONDecoder` will handle empty body by throwing decoding error
56-
throw try await decoder.decode(
57-
SendGridError.self, from: response.body.collect(upTo: 1024 * 1024))
52+
throw try await decoder.decode(SendGridError.self, from: response.body.collect(upTo: 1024 * 1024))
5853
}
5954
}

Tests/SendGridKitTests/SendGridTestsKit.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,16 +81,17 @@ struct SendGridKitTests {
8181
let integer: Int
8282
let double: Double
8383
}
84-
let dynamicTemplateData = DynamicTemplateData(
85-
text: "Hello, World!", integer: 42, double: 3.14)
84+
let dynamicTemplateData = DynamicTemplateData(text: "Hello, World!", integer: 42, double: 3.14)
8685

8786
// TODO: Replace the addresses with real email addresses
8887
let personalization = Personalization(
8988
to: [EmailAddress("TO-ADDRESS")], subject: "Test Email",
90-
dynamicTemplateData: dynamicTemplateData)
89+
dynamicTemplateData: dynamicTemplateData
90+
)
9191
let email = SendGridEmail(
9292
personalizations: [personalization], from: EmailAddress("FROM-ADDRESS"),
93-
content: [EmailContent("Hello, World!")])
93+
content: [EmailContent("Hello, World!")]
94+
)
9495

9596
try await withKnownIssue {
9697
try await client.send(email: email)

0 commit comments

Comments
 (0)