Skip to content

Commit 361a83f

Browse files
authored
Merge pull request #627 from danger/xcode_16_ci
Xcode 16 support
2 parents c8d2aeb + fcb3bd5 commit 361a83f

32 files changed

+149
-95
lines changed

.github/workflows/ci.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
strategy:
5757
fail-fast: false
5858
matrix:
59-
xcode: ["15.2", "15.4"]
59+
xcode: ["15.4", "16.0"]
6060
steps:
6161
- uses: actions/checkout@v2
6262

@@ -95,7 +95,7 @@ jobs:
9595
strategy:
9696
fail-fast: false
9797
matrix:
98-
xcode: ["15.2", "15.4"]
98+
xcode: ["15.4", "16.0"]
9999
steps:
100100
- uses: actions/checkout@v2
101101

@@ -136,7 +136,7 @@ jobs:
136136
strategy:
137137
fail-fast: false
138138
matrix:
139-
swift: ["5.8", "5.9", "5.10"]
139+
swift: ["5.9", "5.10", "6.0"]
140140
steps:
141141
- uses: actions/checkout@v2
142142
- uses: actions/setup-node@v2
@@ -214,7 +214,7 @@ jobs:
214214
strategy:
215215
fail-fast: false
216216
matrix:
217-
xcode: ["15.2", "15.4"]
217+
xcode: ["15.4", "16.0"]
218218
steps:
219219
- uses: actions/checkout@v2
220220

@@ -253,7 +253,7 @@ jobs:
253253
strategy:
254254
fail-fast: false
255255
matrix:
256-
swift: ["5.8", "5.9", "5.10"]
256+
swift: ["5.9", "5.10", "6.0"]
257257
steps:
258258
- uses: actions/checkout@v2
259259
- uses: actions/setup-node@v2

Package.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ let isDevelop = true
99

1010
let swiftLint: Package.Dependency = {
1111
#if compiler(>=5.9)
12-
return .package(url: "https://github.com/Realm/SwiftLint", from: "0.56.0")
12+
return .package(url: "https://github.com/Realm/SwiftLint", from: "0.56.0")
1313
#else
14-
return .package(url: "https://github.com/Realm/SwiftLint", exact: "0.53.0")
14+
return .package(url: "https://github.com/Realm/SwiftLint", exact: "0.53.0")
1515
#endif
1616
}()
1717

@@ -33,17 +33,17 @@ let devTargets: [Target] = isDevelop
3333
dependencies: [
3434
"Danger",
3535
"DangerFixtures",
36-
.product(name: "SnapshotTesting", package: "swift-snapshot-testing")
36+
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
3737
]),
3838
.testTarget(name: "RunnerLibTests",
3939
dependencies: [
4040
"RunnerLib",
41-
.product(name: "SnapshotTesting", package: "swift-snapshot-testing")
42-
], exclude: ["__Snapshots__"]),
41+
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
42+
], exclude: ["__Snapshots__"]),
4343
.testTarget(name: "DangerDependenciesResolverTests",
4444
dependencies: [
4545
"DangerDependenciesResolver",
46-
.product(name: "SnapshotTesting", package: "swift-snapshot-testing")
46+
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
4747
],
4848
exclude: ["__Snapshots__"]),
4949
]
@@ -70,7 +70,7 @@ let package = Package(
7070
dependencies: [
7171
.product(name: "OctoKit", package: "octokit.swift"),
7272
"Logger",
73-
"DangerShellExecutor"
73+
"DangerShellExecutor",
7474
]
7575
),
7676
.target(name: "RunnerLib", dependencies: ["Logger", "DangerShellExecutor", "Version"]),

Scripts/install.sh

+8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ else
2121
swift build --disable-sandbox
2222
fi
2323

24+
MAJOR_VERSION=$(swift --version | awk '{print $4}' | cut -d '.' -f 1)
25+
2426
ARRAY=()
2527
for ARG in "${SWIFT_LIB_FILES[@]}"; do
2628
ARRAY+=("$BUILD_FOLDER/$ARG")
@@ -29,6 +31,12 @@ done
2931
mkdir -p "$PREFIX/bin"
3032
mkdir -p "$LIB_INSTALL_PATH"
3133
cp -f "$BUILD_FOLDER/$TOOL_NAME" "$INSTALL_PATH"
34+
35+
if [[ $MAJOR_VERSION -ge 6 ]]; then
36+
BUILD_FOLDER+="/Modules"
37+
SWIFT_LIB_FILES=($(ls "$BUILD_FOLDER"))
38+
fi
39+
3240
cp -fr "${ARRAY[@]}" "$LIB_INSTALL_PATH" 2>/dev/null || :
3341

3442
sed -e "s/$DANGER_LIB_DYNAMIC_DECLARATION/$DANGER_LIB_DECLARATION/g" Package.swift > tmpPackage

Sources/Danger/Danger.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ final class DangerRunner {
7272

7373
if !FileManager.default.createFile(atPath: outputPath,
7474
contents: data,
75-
attributes: nil) {
75+
attributes: nil)
76+
{
7677
logger.logError("Could not create a temporary file " +
7778
"for the Dangerfile DSL at: \(outputPath)")
7879
exit(0)

Sources/Danger/DangerDSL.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public struct DangerDSL: Decodable {
5858
// Setup the OctoKit once all other
5959
if runningOnGithub {
6060
let config: TokenConfiguration
61-
61+
6262
if let baseURL = settings.github.baseURL {
6363
config = TokenConfiguration(settings.github.accessToken, url: baseURL)
6464
} else {

Sources/Danger/DangerUtils.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public struct DangerUtils {
5454

5555
let lines = readFile(file).components(separatedBy: .newlines)
5656

57-
lines.enumerated().forEach { index, line in
57+
for (index, line) in lines.enumerated() {
5858
if line.contains(string) {
5959
result.append(index + 1)
6060
}
@@ -174,7 +174,7 @@ public extension DangerUtils.Environment {
174174
}
175175
}
176176

177-
public extension Optional where Wrapped == DangerUtils.Environment.Value {
177+
public extension DangerUtils.Environment.Value? {
178178
func getString(default defaultString: String) -> String {
179179
if case let .string(value) = self { return value }
180180
return defaultString

Sources/Danger/Extensions/DateFormatterExtensions.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public extension DateFormatter {
2828
}
2929
}
3030

31-
private final class OptionalFractionalSecondsDateFormatter: DateFormatter {
31+
private final class OptionalFractionalSecondsDateFormatter: DateFormatter, @unchecked Sendable {
3232
static let withMilliseconds: DateFormatter = {
3333
let formatter = DateFormatter()
3434
setUpFormatter(formatter)

Sources/Danger/GitDiff.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ struct DiffParser {
119119
.deletingPrefix("b/") ?? ""
120120

121121
let change: FileDiff.ParsedHeader.ChangeType
122-
122+
123123
if lines.contains(where: { $0.hasPrefix("deleted file mode ") }) {
124124
change = .deleted
125125
} else if lines.contains(where: { $0.hasPrefix("new file mode") }) {
@@ -167,7 +167,8 @@ struct DiffParser {
167167
let oldLineStart = Int(dividedSpan[0][0]),
168168
let oldLineSpan = Int(dividedSpan[0][1]),
169169
let newLineStart = Int(dividedSpan[1][0]),
170-
let newLineSpan = Int(dividedSpan[1][1]) {
170+
let newLineSpan = Int(dividedSpan[1][1])
171+
{
171172
return HunkSpan(oldLineStart: oldLineStart,
172173
oldLineSpan: oldLineSpan,
173174
newLineStart: newLineStart,

Sources/Danger/Plugins/SwiftLint/CurrentPathProvider.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import Foundation
22

3-
internal protocol CurrentPathProvider {
3+
protocol CurrentPathProvider {
44
var currentPath: String { get }
55
}
66

7-
internal final class DefaultCurrentPathProvider: CurrentPathProvider {
7+
final class DefaultCurrentPathProvider: CurrentPathProvider {
88
var currentPath: String {
99
FileManager.default.currentDirectoryPath
1010
}

Sources/Danger/Plugins/SwiftLint/SwiftLint.swift

+21-15
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ public enum SwiftLint {
4848
strict: Bool = false,
4949
quiet: Bool = true,
5050
swiftlintPath: String,
51-
markdownAction: (String) -> Void = markdown) -> [SwiftLintViolation] {
51+
markdownAction: (String) -> Void = markdown) -> [SwiftLintViolation]
52+
{
5253
lint(lintStyle,
5354
inline: inline,
5455
configFile: configFile,
@@ -70,8 +71,8 @@ public enum SwiftLint {
7071
strict: Bool = false,
7172
quiet: Bool = true,
7273
swiftlintPath: SwiftlintPath? = nil,
73-
markdownAction: (String) -> Void = markdown
74-
) -> [SwiftLintViolation] {
74+
markdownAction: (String) -> Void = markdown) -> [SwiftLintViolation]
75+
{
7576
lint(lintStyle: lintStyle,
7677
danger: danger,
7778
shellExecutor: shellExecutor,
@@ -80,8 +81,7 @@ public enum SwiftLint {
8081
configFile: configFile,
8182
strict: strict,
8283
quiet: quiet,
83-
markdownAction: markdownAction
84-
)
84+
markdownAction: markdownAction)
8585
}
8686
}
8787

@@ -112,7 +112,7 @@ extension SwiftLint {
112112
arguments.append("--quiet")
113113
}
114114

115-
if let configFile = configFile {
115+
if let configFile {
116116
arguments.append("--config \"\(configFile)\"")
117117
}
118118

@@ -133,10 +133,11 @@ extension SwiftLint {
133133
outputFilePath: outputFilePath,
134134
failAction: failAction,
135135
readFile: readFile)
136+
136137
case let .modifiedAndCreatedFiles(directory):
137138
// Gathers modified+created files, invokes SwiftLint on each, and posts collected errors+warnings to Danger.
138139
var files = (danger.git.createdFiles + danger.git.modifiedFiles)
139-
if let directory = directory {
140+
if let directory {
140141
files = files.filter { $0.hasPrefix(directory) }
141142
}
142143

@@ -181,10 +182,11 @@ extension SwiftLint {
181182
swiftlintPath: String,
182183
outputFilePath: String,
183184
failAction: (String) -> Void,
184-
readFile: (String) -> String) -> [SwiftLintViolation] {
185+
readFile: (String) -> String) -> [SwiftLintViolation]
186+
{
185187
var arguments = arguments
186188

187-
if let directory = directory {
189+
if let directory {
188190
arguments.append(directory)
189191
}
190192

@@ -205,7 +207,8 @@ extension SwiftLint {
205207
swiftlintPath: String,
206208
outputFilePath: String,
207209
failAction: (String) -> Void,
208-
readFile: (String) -> String) -> [SwiftLintViolation] {
210+
readFile: (String) -> String) -> [SwiftLintViolation]
211+
{
209212
let files = files.filter { $0.fileType == .swift }
210213

211214
// Only run Swiftlint, if there are files to lint
@@ -236,7 +239,8 @@ extension SwiftLint {
236239
let swiftPackageDepPattern = #"\.package\(.*SwiftLint(\.git)?".*"#
237240
if let packageContent = try? String(contentsOfFile: packagePath),
238241
let regex = try? NSRegularExpression(pattern: swiftPackageDepPattern, options: .allowCommentsAndWhitespace),
239-
regex.firstMatchingString(in: packageContent) != nil {
242+
regex.firstMatchingString(in: packageContent) != nil
243+
{
240244
return "swift run swiftlint"
241245
} else {
242246
return "swiftlint"
@@ -248,9 +252,10 @@ extension SwiftLint {
248252
inline: Bool,
249253
markdownAction: (String) -> Void,
250254
failInlineAction: (String, String, Int) -> Void,
251-
warnInlineAction: (String, String, Int) -> Void) {
255+
warnInlineAction: (String, String, Int) -> Void)
256+
{
252257
if inline {
253-
violations.forEach { violation in
258+
for violation in violations {
254259
switch violation.severity {
255260
case .error:
256261
failInlineAction(violation.messageText, violation.file, violation.line)
@@ -276,7 +281,8 @@ extension SwiftLint {
276281
outputFilePath: String,
277282
shellExecutor: ShellExecuting,
278283
failAction: (String) -> Void,
279-
readFile: (String) -> String) -> [SwiftLintViolation] {
284+
readFile: (String) -> String) -> [SwiftLintViolation]
285+
{
280286
shellExecutor.execute(swiftlintPath,
281287
arguments: arguments,
282288
environmentVariables: environmentVariables,
@@ -309,7 +315,7 @@ extension SwiftLint {
309315
}
310316
}
311317

312-
private extension Array where Element == SwiftLintViolation {
318+
private extension [SwiftLintViolation] {
313319
func updatingForCurrentPathProvider(_ currentPathProvider: CurrentPathProvider, strictSeverity: Bool) -> [Element] {
314320
let currentPath = currentPathProvider.currentPath
315321
return map { violation -> SwiftLintViolation in

Sources/Danger/Report.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public extension DangerDSL {
117117
/// Adds an inline suggestion to the Danger report (sends a normal message if suggestions are not supported)
118118
func suggestion(code: String, file: String, line: Int) {
119119
let message: String
120-
120+
121121
if dangerRunner.dsl.supportsSuggestions {
122122
message = """
123123
```suggestion

Sources/DangerDependenciesResolver/InlineDependenciesFinder.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ struct InlineDependenciesFinder {
3434

3535
let url: URL? = {
3636
#if os(macOS) && compiler(>=5.9)
37-
if #available(macOS 14.0, *) {
38-
return URL(string: splittedImportString[0], encodingInvalidCharacters: false)
39-
}
37+
if #available(macOS 14.0, *) {
38+
return URL(string: splittedImportString[0], encodingInvalidCharacters: false)
39+
}
4040
#endif
4141
return URL(string: splittedImportString[0])
4242
}()
43-
guard let url = url else {
43+
guard let url else {
4444
throw Errors.invalidInlineDependencyURL(splittedImportString[0])
4545
}
4646

Sources/DangerDependenciesResolver/Package.swift

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ extension Package {
1313
func dependencyString(forToolsVersion version: Version) -> String {
1414
switch version {
1515
case Version(5, 6, 0)...:
16-
if let minorVersion = minorVersion, let patchVersion = patchVersion {
16+
if let minorVersion, let patchVersion {
1717
return #".package(url: "\#(url.absoluteString)", exact: "\#(majorVersion).\#(minorVersion).\#(patchVersion)")"#
1818
} else {
1919
return #".package(url: "\#(url.absoluteString)", from: "\#(majorVersion).0.0")"#
2020
}
2121
case Version(5, 2, 0)...:
22-
if let minorVersion = minorVersion, let patchVersion = patchVersion {
22+
if let minorVersion, let patchVersion {
2323
return #".package(name: "\#(name)", url: "\#(url.absoluteString)", .exact("\#(majorVersion).\#(minorVersion).\#(patchVersion)"))"#
2424
} else {
2525
return #".package(name: "\#(name)", url: "\#(url.absoluteString)", from: "\#(majorVersion).0.0")"#
2626
}
2727
default:
28-
if let minorVersion = minorVersion, let patchVersion = patchVersion {
28+
if let minorVersion, let patchVersion {
2929
return #".package(url: "\#(url.absoluteString)", .exact("\#(majorVersion).\#(minorVersion).\#(patchVersion)"))"#
3030
} else {
3131
return #".package(url: "\#(url.absoluteString)", from: "\#(majorVersion).0.0")"#
@@ -66,6 +66,7 @@ extension Package.Pinned {
6666
}
6767

6868
// MARK: - swift-tools-version >= 5.6
69+
6970
extension Package {
7071
struct PinnedV2: Decodable, Equatable {
7172
let name: String
@@ -99,7 +100,8 @@ extension Package.PinnedV2 {
99100
}
100101

101102
// MARK: -
102-
extension Sequence where Element == Package.PinnedV2 {
103+
104+
extension Sequence<Package.PinnedV2> {
103105
func v1Converted() -> [Package.Pinned] {
104106
map(\.v1)
105107
}

0 commit comments

Comments
 (0)