Skip to content

Commit 9d594e2

Browse files
Merge pull request #4 from SwiftPackageIndex/linux-support
Add linux support
2 parents abc3527 + 4d7c664 commit 9d594e2

File tree

8 files changed

+83
-12
lines changed

8 files changed

+83
-12
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,27 @@ on:
77

88
jobs:
99
build:
10-
runs-on: macos-11
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
os: [macos-11, ubuntu-20.04]
14+
15+
runs-on: ${{ matrix.os }}
1116
env:
1217
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer
1318

1419
steps:
1520
- uses: actions/checkout@v2
16-
- name: Build
21+
- name: Release Build
1722
run: make build
1823

1924
test:
20-
runs-on: macos-11
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
os: [macos-11, ubuntu-20.04]
29+
30+
runs-on: ${{ matrix.os }}
2131
env:
2232
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer
2333

@@ -27,13 +37,18 @@ jobs:
2737
run: make test
2838

2939
install:
30-
runs-on: macos-11
40+
strategy:
41+
fail-fast: false
42+
matrix:
43+
os: [macos-11, ubuntu-20.04]
44+
45+
runs-on: ${{ matrix.os }}
3146
env:
3247
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app/Contents/Developer
3348

3449
steps:
3550
- uses: actions/checkout@v2
3651
- name: Install
37-
run: make install
52+
run: env prefix=/tmp make install
3853
- name: Uninstall
39-
run: make uninstall
54+
run: env prefix=/tmp make uninstall

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ let package = Package(
3636
]
3737
),
3838
.testTarget(
39-
name: "ReleaseNotesCoreTests",
39+
name: "ReleaseNotesTests",
4040
dependencies: ["ReleaseNotesCore"]
4141
),
4242
]

Sources/ReleaseNotesCore/App.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import ArgumentParser
22

33

4-
@main
5-
struct App {
6-
static func main() async {
4+
public struct App {
5+
public static func main() async {
76
await ReleaseNotes.main()
87
}
98
}

Sources/ReleaseNotesCore/Parser.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import Parsing
22
import SemanticVersion
3-
import Darwin
43

54

65
enum Parser {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import Foundation
2+
import ReleaseNotesCore
3+
4+
5+
let group = DispatchGroup()
6+
group.enter()
7+
Task {
8+
defer { group.leave() }
9+
await App.main()
10+
}
11+
12+
group.wait()

Sources/swift-release-notes/release-notes.swift

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import XCTest
2+
import class Foundation.Bundle
3+
4+
5+
final class LaunchTests: XCTestCase {
6+
7+
func test_launch() throws {
8+
let process = Process()
9+
process.executableURL = productsDirectory
10+
.appendingPathComponent("swift-release-notes")
11+
process.arguments = ["--help"]
12+
13+
let pipe = Pipe()
14+
process.standardOutput = pipe
15+
16+
try process.run()
17+
process.waitUntilExit()
18+
19+
let data = pipe.fileHandleForReading.readDataToEndOfFile()
20+
let output = try XCTUnwrap(String(data: data, encoding: .utf8))
21+
22+
XCTAssertEqual(output, """
23+
USAGE: release-notes [<working-direcory>]
24+
25+
ARGUMENTS:
26+
<working-direcory> (default: .)
27+
28+
OPTIONS:
29+
-h, --help Show help information.
30+
31+
32+
""")
33+
}
34+
35+
/// Returns path to the built products directory.
36+
var productsDirectory: URL {
37+
#if os(macOS)
38+
for bundle in Bundle.allBundles where bundle.bundlePath.hasSuffix(".xctest") {
39+
return bundle.bundleURL.deletingLastPathComponent()
40+
}
41+
fatalError("couldn't find the products directory")
42+
#else
43+
return Bundle.main.bundleURL
44+
#endif
45+
}
46+
47+
}

0 commit comments

Comments
 (0)