Skip to content

Commit ce18ad6

Browse files
authored
Merge branch 'master' into support_mannequin_user_type
2 parents 34f8d71 + e035543 commit ce18ad6

File tree

6 files changed

+72
-118
lines changed

6 files changed

+72
-118
lines changed

.github/workflows/ci.yml

Lines changed: 40 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,24 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15-
test-on-macos-13:
16-
name: Test on macOS 13
17-
runs-on: macOS-13
15+
test-on-macos:
16+
name: Test on macOS
1817
strategy:
1918
fail-fast: false
2019
matrix:
21-
xcode: ["14.3.1"]
20+
include:
21+
- runner: "macos-13"
22+
xcode: "14.3.1"
23+
- runner: "macos-14"
24+
xcode: "15.4"
25+
- runner: "macos-15"
26+
xcode: "16.1"
27+
runs-on: ${{ matrix.runner }}
2228
steps:
23-
- uses: actions/checkout@v2
29+
- uses: actions/checkout@v4
2430

2531
- name: Cache dependencies
26-
uses: actions/cache@v2
32+
uses: actions/cache@v4
2733
with:
2834
path: |
2935
.build/artifacts
@@ -50,57 +56,22 @@ jobs:
5056
if: ${{ github.event_name == 'pull_request' }}
5157
env:
5258
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53-
test-on-macos-14:
54-
name: Test on macOS 14
55-
runs-on: macOS-14
56-
strategy:
57-
fail-fast: false
58-
matrix:
59-
xcode: ["15.4", "16.0"]
60-
steps:
61-
- uses: actions/checkout@v2
62-
63-
- name: Cache dependencies
64-
uses: actions/cache@v2
65-
with:
66-
path: |
67-
.build/artifacts
68-
.build/checkouts
69-
.build/repositories
70-
key: ${{ runner.os }}-dependencies-${{ matrix.xcode }}-${{ hashFiles('**/Package.resolved') }}
71-
restore-keys: |
72-
${{ runner.os }}-dependencies-${{ matrix.xcode }}-${{ hashFiles('**/Package.resolved') }}
73-
${{ runner.os }}-dependencies-${{ matrix.xcode }}-
74-
75-
- name: Select Xcode
76-
run: |
77-
xcodebuild -version
78-
ls -nt /Applications/ | grep "Xcode*"
79-
sudo xcode-select -switch /Applications/Xcode_${{ matrix.xcode }}.app
80-
xcodebuild -version
81-
82-
- name: Install danger-js
83-
run: brew install danger/tap/danger-js
84-
85-
- run: swift test
86-
87-
- run: swift run danger-swift ci --verbose --failOnErrors
88-
if: ${{ github.event_name == 'pull_request' }}
89-
env:
90-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91-
9259
test-dependencies-resolver:
9360
name: Test dependencies resolver
94-
runs-on: macOS-14
9561
strategy:
9662
fail-fast: false
9763
matrix:
98-
xcode: ["15.4", "16.0"]
64+
include:
65+
- runner: "macos-14"
66+
xcode: "15.4"
67+
- runner: "macos-15"
68+
xcode: "16.1"
69+
runs-on: ${{ matrix.runner }}
9970
steps:
100-
- uses: actions/checkout@v2
71+
- uses: actions/checkout@v4
10172

10273
- name: Cache dependencies
103-
uses: actions/cache@v2
74+
uses: actions/cache@v4
10475
with:
10576
path: |
10677
.build/artifacts
@@ -138,11 +109,11 @@ jobs:
138109
matrix:
139110
swift: ["5.9", "5.10", "6.0"]
140111
steps:
141-
- uses: actions/checkout@v2
142-
- uses: actions/setup-node@v2
112+
- uses: actions/checkout@v4
113+
- uses: actions/setup-node@v4
143114

144115
- name: Cache dependencies
145-
uses: actions/cache@v2
116+
uses: actions/cache@v4
146117
with:
147118
path: |
148119
.build/artifacts
@@ -169,18 +140,24 @@ jobs:
169140
env:
170141
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
171142

172-
test-without-spm-on-macos-13:
173-
name: Test without SPM on macOS 13
174-
runs-on: macOS-13
143+
test-without-spm-on-macos:
144+
name: Test without SPM on macOS
175145
strategy:
176146
fail-fast: false
177147
matrix:
178-
xcode: ["14.3.1"]
148+
include:
149+
- runner: "macos-13"
150+
xcode: "14.3.1"
151+
- runner: "macos-14"
152+
xcode: "15.4"
153+
- runner: "macos-15"
154+
xcode: "16.1"
155+
runs-on: ${{ matrix.runner }}
179156
steps:
180-
- uses: actions/checkout@v2
157+
- uses: actions/checkout@v4
181158

182159
- name: Cache dependencies
183-
uses: actions/cache@v2
160+
uses: actions/cache@v4
184161
with:
185162
path: |
186163
.build/artifacts
@@ -202,47 +179,9 @@ jobs:
202179
run: brew install danger/tap/danger-js
203180

204181
- run: make install
205-
206-
- run: rm -rf .build && rm -rf Package.swift
207-
208-
- run: danger-swift ci --verbose --failOnErrors
209-
if: ${{ github.event_name == 'pull_request' }}
210-
env:
211-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
212-
213-
test-without-spm-on-macos-14:
214-
name: Test without SPM on macOS 14
215-
runs-on: macOS-14
216-
strategy:
217-
fail-fast: false
218-
matrix:
219-
xcode: ["15.4", "16.0"]
220-
steps:
221-
- uses: actions/checkout@v2
222-
223-
- name: Cache dependencies
224-
uses: actions/cache@v2
225-
with:
226-
path: |
227-
.build/artifacts
228-
.build/checkouts
229-
.build/repositories
230-
key: ${{ runner.os }}-without-spm-package-${{ matrix.xcode }}-${{ hashFiles('**/Package.resolved') }}
231-
restore-keys: |
232-
${{ runner.os }}-without-spm-package-${{ matrix.xcode }}-${{ hashFiles('**/Package.resolved') }}
233-
${{ runner.os }}-without-spm-package-${{ matrix.xcode }}-
234-
235-
- name: Select Xcode
236-
run: |
237-
xcodebuild -version
238-
ls -nt /Applications/ | grep "Xcode*"
239-
sudo xcode-select -switch /Applications/Xcode_${{ matrix.xcode }}.app
240-
xcodebuild -version
241-
242-
- name: Install danger-js
243-
run: brew install danger/tap/danger-js
244-
182+
if: ${{ matrix.runner == 'macos-13' }}
245183
- run: make install PREFIX='/opt/homebrew'
184+
if: ${{ matrix.runner != 'macos-13' }}
246185

247186
- run: rm -rf .build && rm -rf Package.swift
248187

@@ -259,11 +198,11 @@ jobs:
259198
matrix:
260199
swift: ["5.9", "5.10", "6.0"]
261200
steps:
262-
- uses: actions/checkout@v2
263-
- uses: actions/setup-node@v2
201+
- uses: actions/checkout@v4
202+
- uses: actions/setup-node@v4
264203

265204
- name: Cache dependencies
266-
uses: actions/cache@v2
205+
uses: actions/cache@v4
267206
with:
268207
path: |
269208
.build/artifacts

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
## Master
1515

1616
- Support user type mannequin on for GitHub [@f-meloni][] - [#638](https://github.com/danger/swift/pull/638)
17+
- Add Android support [@marcprux][] - [#635](https://github.com/danger/swift/pull/635)
1718

1819
## 3.20.2
1920

Sources/Danger/Danger.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import Foundation
22

3-
#if os(Linux)
3+
#if canImport(Glibc)
44
import Glibc
5+
#elseif canImport(Android)
6+
import Android
57
#else
68
import Darwin.C
79
#endif

Sources/DangerShellExecutor/ShellExecutor.swift

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import Foundation
2+
#if canImport(FoundationNetworking)
3+
import FoundationNetworking
4+
#endif
25

36
public enum SpawnError: Error {
47
case commandFailed(command: String, exitCode: Int32, stdout: String, stderr: String)
@@ -62,16 +65,19 @@ public struct ShellExecutor: ShellExecuting {
6265
with: arguments,
6366
environmentVariables: environmentVariables,
6467
outputFile: outputFile)
68+
do {
69+
let pipe = Pipe()
70+
task.standardOutput = pipe
71+
try task.run()
6572

66-
let pipe = Pipe()
67-
task.standardOutput = pipe
68-
task.launch()
73+
let data = pipe.fileHandleForReading.readDataToEndOfFile()
6974

70-
let data = pipe.fileHandleForReading.readDataToEndOfFile()
75+
task.waitUntilExit()
7176

72-
task.waitUntilExit()
73-
74-
return String(data: data, encoding: .utf8)!.trimmingCharacters(in: .whitespacesAndNewlines)
77+
return String(data: data, encoding: .utf8)!.trimmingCharacters(in: .whitespacesAndNewlines)
78+
} catch {
79+
return error.localizedDescription
80+
}
7581
}
7682

7783
// Similar to above, but can throw, and throws with most of
@@ -90,7 +96,7 @@ public struct ShellExecutor: ShellExecuting {
9096
task.standardOutput = stdout
9197
let stderr = Pipe()
9298
task.standardError = stderr
93-
task.launch()
99+
try task.run()
94100

95101
// Pull out the STDOUT as a string because we'll need that regardless
96102
let stdoutData = stdout.fileHandleForReading.readDataToEndOfFile()
@@ -131,10 +137,10 @@ public struct ShellExecutor: ShellExecuting {
131137
let script = "\(command) \(arguments.joined(separator: " "))" + scriptOutputFile
132138

133139
let task = Process()
134-
task.launchPath = "/bin/sh"
140+
task.executableURL = URL(fileURLWithPath: "/bin/sh")
135141
task.arguments = ["-c", script]
136142
task.environment = mergeEnvs(localEnv: environmentVariables, processEnv: ProcessInfo.processInfo.environment)
137-
task.currentDirectoryPath = FileManager.default.currentDirectoryPath
143+
task.currentDirectoryURL = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
138144
return task
139145
}
140146

Sources/Runner/Commands/RunDangerJS.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import Foundation
22
import Logger
33
import RunnerLib
4+
#if canImport(FoundationNetworking)
5+
import FoundationNetworking
6+
#endif
47

58
func runDangerJSCommandToRunDangerSwift(_ command: DangerCommand, logger: Logger) throws -> Int32 {
69
guard let dangerJS = try? getDangerCommandPath(logger: logger) else {
@@ -22,7 +25,7 @@ func runDangerJSCommandToRunDangerSwift(_ command: DangerCommand, logger: Logger
2225

2326
let proc = Process()
2427
proc.environment = ProcessInfo.processInfo.environment
25-
proc.launchPath = dangerJS
28+
proc.executableURL = URL(fileURLWithPath: dangerJS)
2629

2730
let dangerOptionsIndexes = DangerSwiftOption.allCases
2831
.compactMap { option -> (DangerSwiftOption, Int)? in
@@ -62,8 +65,8 @@ func runDangerJSCommandToRunDangerSwift(_ command: DangerCommand, logger: Logger
6265
proc.standardOutput = standardOutput
6366
proc.standardError = standardOutput
6467

65-
logger.debug("Running: \(proc.launchPath!) \(proc.arguments!.joined(separator: " ")) ")
66-
proc.launch()
68+
logger.debug("Running: \(proc.executableURL!) \(proc.arguments!.joined(separator: " ")) ")
69+
try proc.run()
6770
proc.waitUntilExit()
6871

6972
return proc.terminationStatus

Sources/Runner/Commands/Runner.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import DangerShellExecutor
33
import Foundation
44
import Logger
55
import RunnerLib
6+
#if canImport(FoundationNetworking)
7+
import FoundationNetworking
8+
#endif
69

710
// swiftlint:disable:next function_body_length
811
func runDanger(version dangerSwiftVersion: String, logger: Logger) throws {
@@ -152,19 +155,19 @@ func runDanger(version dangerSwiftVersion: String, logger: Logger) throws {
152155

153156
// Create a process to eval the Swift file
154157
let proc = Process()
155-
proc.launchPath = swiftC
158+
proc.executableURL = URL(fileURLWithPath: swiftC)
156159
proc.arguments = args
157160
let standardOutput = FileHandle.standardOutput
158161
if let cwdOptionIndex = CommandLine.arguments.firstIndex(of: DangeSwiftRunnerOption.cwd.rawValue),
159162
(cwdOptionIndex + 1) < CommandLine.arguments.count,
160163
let directoryURL = URL(string: CommandLine.arguments[cwdOptionIndex + 1])
161164
{
162-
proc.currentDirectoryPath = directoryURL.absoluteString
165+
proc.currentDirectoryURL = directoryURL
163166
}
164167
proc.standardOutput = standardOutput
165168
proc.standardError = standardOutput
166169

167-
proc.launch()
170+
try proc.run()
168171
proc.waitUntilExit()
169172

170173
logger.debug("Completed evaluation")

0 commit comments

Comments
 (0)