Skip to content

Commit

Permalink
Improved Swift 6 handling (#11)
Browse files Browse the repository at this point in the history
* update timestamp handling

* resolve warning

* update devcontainer for swift 6

* add swift 6 mode compat

* test swift 5.9 and 6

* remove gha verbose logging
  • Loading branch information
jagreenwood authored Dec 4, 2024
1 parent a1e27ec commit 9ac85e0
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 10 deletions.
6 changes: 3 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "Swift",
"image": "swift:5.9.1",
"image": "swift:6.0",
"features": {
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": "false",
"username": "vscode",
"userUid": "1000",
"userGid": "1000",
"userUid": "1001",
"userGid": "1001",
"upgradePackages": "false"
},
"ghcr.io/devcontainers/features/git:1": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Unit Test
name: Test Swift 5.9

on:
push:
Expand All @@ -8,11 +8,11 @@ on:

jobs:
build:

container: swift:5.9
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: swift build -v
run: swift build
- name: Run tests
run: swift test -v
run: swift test
18 changes: 18 additions & 0 deletions .github/workflows/swift-6.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test Swift 6.0

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
container: swift:6.0
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: swift build
- name: Run tests
run: swift test
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ let package = Package(
.testTarget(
name: "DataDogLogTests",
dependencies: ["DataDogLog"]),
]
],
swiftLanguageVersions: [.version("6"), .v5]
)

#if os(Linux)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ extension String {
static var timestamp: String {
var buffer = [Int8](repeating: 0, count: 255)
var timestamp = time(nil)
let localTime = localtime(&timestamp)
guard let localTime = localtime(&timestamp) else {
return "<unknown>"
}
strftime(&buffer, buffer.count, "%Y-%m-%dT%H:%M:%S%z", localTime)

return buffer.withUnsafeBufferPointer {
$0.withMemoryRebound(to: CChar.self) {
String(cString: $0.baseAddress!)
Expand Down
2 changes: 1 addition & 1 deletion Sources/DataDogLog/Internal/NetworkClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class NetworkClient: Sendable {

deinit {
#if os(Linux)
client.shutdown()
client.shutdown { _ in }
#endif
}

Expand Down

0 comments on commit 9ac85e0

Please sign in to comment.