Skip to content

Commit e07e00f

Browse files
Add strict concurrency checks for Swift 6 support and fix concurrency warnings in tests (#130)
* Add checks for Swift 6 support and fix concurrency warnings * Update .devcontainer/devcontainer.json Co-authored-by: Tim Gymnich <tim@gymni.ch> --------- Co-authored-by: Tim Gymnich <tim@gymni.ch>
1 parent 99c4b9f commit e07e00f

File tree

6 files changed

+55
-10
lines changed

6 files changed

+55
-10
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FROM swift:6.1

.devcontainer/devcontainer.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "BigInt Dev",
3+
"build": {
4+
"dockerfile": "Dockerfile"
5+
},
6+
"features": {
7+
"ghcr.io/devcontainers/features/common-utils:2": {
8+
"installZsh": "false",
9+
"username": "ubuntu",
10+
"userUid": "automatic",
11+
"userGid": "automatic",
12+
"upgradePackages": "false"
13+
},
14+
"ghcr.io/devcontainers/features/git:1": {
15+
"version": "os-provided",
16+
"ppa": "false"
17+
}
18+
},
19+
"runArgs": [
20+
"--cap-add=SYS_PTRACE",
21+
"--security-opt",
22+
"seccomp=unconfined",
23+
"--network=host"
24+
],
25+
// Configure tool-specific properties.
26+
"customizations": {
27+
// Configure properties specific to VS Code.
28+
"vscode": {
29+
// Set *default* container specific settings.json values on container create.
30+
"settings": {
31+
"lldb.library": "/usr/lib/liblldb.so"
32+
},
33+
// Add the IDs of extensions you want installed when the container is created.
34+
"extensions": [
35+
"swiftlang.swift-vscode"
36+
]
37+
}
38+
},
39+
"remoteUser": "ubuntu"
40+
}

.github/workflows/swift.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ jobs:
2525
steps:
2626
- uses: actions/checkout@v4
2727
- name: Build
28-
run: swift build --build-tests --enable-test-discovery
28+
run: swift build --build-tests --enable-test-discovery -Xswiftc -strict-concurrency=complete
2929
- name: Test
30-
run: swift test --enable-test-discovery --parallel
30+
run: swift test --enable-test-discovery --parallel -Xswiftc -strict-concurrency=complete
3131

3232
android:
3333
runs-on: macos-13

Package.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ let package = Package(
2121
],
2222
products: [
2323
.library(name: "BigInt", targets: ["BigInt"])
24-
],
24+
],
2525
targets: [
26-
.target(name: "BigInt", path: "Sources"),
27-
.testTarget(name: "BigIntTests", dependencies: ["BigInt"], path: "Tests")
26+
.target(
27+
name: "BigInt", path: "Sources",
28+
swiftSettings: [.enableExperimentalFeature("StrictConcurrency")]),
29+
.testTarget(
30+
name: "BigIntTests", dependencies: ["BigInt"], path: "Tests",
31+
swiftSettings: [.enableExperimentalFeature("StrictConcurrency")]),
2832
]
2933
)

Tests/BigIntTests/Violet - Helpers/BitWidthTestCases.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ internal enum BitWidthTestCases {
6262
// TLDR: bitWidth = power + 2
6363
internal static let positivePowersOf2Correction = 2
6464

65-
internal static var positivePowersOf2: [PowerTestCase] = {
65+
internal static let positivePowersOf2: [PowerTestCase] = {
6666
var result = [PowerTestCase]()
6767

6868
for (power, value) in allPositivePowersOf2(type: Int.self) {
@@ -86,7 +86,7 @@ internal enum BitWidthTestCases {
8686
// TLDR: bitWidth = power + 1
8787
internal static let negativePowersOf2Correction = 1
8888

89-
internal static var negativePowersOf2: [PowerTestCase] = {
89+
internal static let negativePowersOf2: [PowerTestCase] = {
9090
var result = [PowerTestCase]()
9191

9292
for (power, value) in allNegativePowersOf2(type: Int.self) {

Tests/BigIntTests/Violet - Helpers/WordsTestCases.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ internal enum WordsTestCases {
6666
internal typealias HeapTestCase = (words: [Word], expected: [UInt])
6767

6868
// words: 1000 0000
69-
internal static var heapPositive: [HeapTestCase] = {
69+
internal static let heapPositive: [HeapTestCase] = {
7070
var result = [HeapTestCase]()
7171

7272
for zeroWordCount in [1, 2] {
@@ -92,7 +92,7 @@ internal enum WordsTestCases {
9292
// words: 1000 0000
9393
// invert: 0111 1111
9494
// complement: 1000 0000
95-
internal static var heapNegative_powerOf2: [HeapTestCase] = {
95+
internal static let heapNegative_powerOf2: [HeapTestCase] = {
9696
var result = [HeapTestCase]()
9797

9898
for zeroWordCount in [1, 2] {
@@ -121,7 +121,7 @@ internal enum WordsTestCases {
121121
// words: 1000 0001
122122
// invert: 0111 1110
123123
// complement: 1111 0111 1111
124-
internal static var heapNegative_notPowerOf2: [HeapTestCase] = {
124+
internal static let heapNegative_notPowerOf2: [HeapTestCase] = {
125125
var result = [HeapTestCase]()
126126

127127
for zeroWordCount in [1, 2] {

0 commit comments

Comments
 (0)