Skip to content

Commit a418cf9

Browse files
authored
Enable strict concurrency checking in CI (#191)
Enable strict concurrency checking in CI ### Motivation To further avoid concurrency bugs, enable complete concurrency checking in CI. ### Modifications Added the compiler flag to the docker-compose scripts, even though it won't fail the CI when new warnings are introduced, as we can't enable warnings-as-errors yet. Adapted the code to be more concurrency safe. ### Result The project passes the complete concurrency checking. ### Test Plan Locally built without any warnings with the flag enabled. Reviewed by: glbrntt Builds: ✔︎ pull request validation (5.8) - Build finished. ✔︎ pull request validation (5.9) - Build finished. ✔︎ pull request validation (docc test) - Build finished. ✔︎ pull request validation (integration test) - Build finished. ✔︎ pull request validation (nightly) - Build finished. ✔︎ pull request validation (soundness) - Build finished. #191
1 parent 15423b4 commit a418cf9

File tree

7 files changed

+10
-7
lines changed

7 files changed

+10
-7
lines changed

Sources/PetstoreConsumerTestCore/Common.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
import OpenAPIRuntime
1515
import Foundation
1616

17-
public enum TestError: Swift.Error, LocalizedError, CustomStringConvertible {
17+
public enum TestError: Swift.Error, LocalizedError, CustomStringConvertible, Sendable {
1818
case noHandlerFound(method: HTTPMethod, path: [RouterPathComponent])
1919
case invalidURLString(String)
20-
case unexpectedValue(Any)
20+
case unexpectedValue(any Sendable)
2121
case unexpectedMissingRequestBody
2222

2323
public var description: String {

Sources/_OpenAPIGeneratorCore/Diagnostics.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import OpenAPIKit30
1818
public struct Diagnostic: Error, Codable {
1919

2020
/// Describes the severity of a diagnostic.
21-
public enum Severity: String, Codable {
21+
public enum Severity: String, Codable, Sendable {
2222

2323
/// An informative message, does not represent an issue.
2424
case note
@@ -38,7 +38,7 @@ public struct Diagnostic: Error, Codable {
3838
public var message: String
3939

4040
/// Describes the source file that triggered a diagnostic.
41-
public struct Location: Codable {
41+
public struct Location: Codable, Sendable {
4242
/// The absolute path to a specific source file that triggered the diagnostic.
4343
public var filePath: String
4444

@@ -333,7 +333,7 @@ public struct StdErrPrintingDiagnosticCollector: DiagnosticCollector {
333333
public init() {}
334334

335335
public func emit(_ diagnostic: Diagnostic) {
336-
print(diagnostic.description, to: &stdErrHandle)
336+
stdErrHandle.write(diagnostic.description)
337337
}
338338
}
339339

Sources/_OpenAPIGeneratorCore/Extensions/Foundation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extension InMemoryOutputFile {
4747
}
4848

4949
/// File handle to stderr.
50-
var stdErrHandle = FileHandle.standardError
50+
let stdErrHandle = FileHandle.standardError
5151

5252
extension FileHandle: TextOutputStream {
5353
public func write(_ string: String) {

docker/docker-compose.2204.58.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ services:
2020
#
2121
# - WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors
2222
- IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error
23+
- STRICT_CONCURRENCY_ARG=-Xswiftc -strict-concurrency=complete
2324

2425
shell:
2526
image: *image

docker/docker-compose.2204.59.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ services:
1919
#
2020
# - WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors
2121
- IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error
22+
- STRICT_CONCURRENCY_ARG=-Xswiftc -strict-concurrency=complete
2223

2324
shell:
2425
image: *image

docker/docker-compose.2204.main.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ services:
2020
#
2121
# - WARN_AS_ERROR_ARG=-Xswiftc -warnings-as-errors
2222
- IMPORT_CHECK_ARG=--explicit-target-dependency-import-check error
23+
- STRICT_CONCURRENCY_ARG=-Xswiftc -strict-concurrency=complete
2324

2425
shell:
2526
image: *image

docker/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030

3131
test:
3232
<<: *common
33-
command: /bin/bash -xcl "swift $${SWIFT_TEST_VERB-test} $${WARN_AS_ERROR_ARG-} $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-}"
33+
command: /bin/bash -xcl "swift $${SWIFT_TEST_VERB-test} $${WARN_AS_ERROR_ARG-} $${SANITIZER_ARG-} $${IMPORT_CHECK_ARG-} $${STRICT_CONCURRENCY_ARG-}"
3434

3535
shell:
3636
<<: *common

0 commit comments

Comments
 (0)