Skip to content

Commit 5e0384f

Browse files
Merge pull request #2 from SwiftPackageIndex/add-ci
Add ci
2 parents db112a2 + eabda0f commit 5e0384f

File tree

8 files changed

+71
-86
lines changed

8 files changed

+71
-86
lines changed

.devcontainer/devcontainer.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "swift 5.8",
3+
"image": "swift:5.8",
4+
"customizations": {
5+
// Configure properties specific to VS Code.
6+
"vscode": {
7+
"extensions": [
8+
"sswg.swift-lang"
9+
],
10+
"settings": {
11+
"lldb.library": "/usr/lib/liblldb.so",
12+
"terminal.integrated.env.linux": {
13+
"LOCALSTACK_ENDPOINT": "http://localstack:4566"
14+
}
15+
}
16+
}
17+
},
18+
"forwardPorts": [8080]
19+
}

.github/workflows/ci.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ main ]
7+
pull_request:
8+
branches: [ main ]
9+
10+
jobs:
11+
macOS:
12+
# https://github.com/actions/runner-images
13+
runs-on: macos-13
14+
strategy:
15+
matrix:
16+
xcode: ['15.0', '14.3.1']
17+
steps:
18+
- uses: actions/checkout@v3
19+
- run: git config --global user.email "[email protected]"
20+
- run: git config --global user.name "Name"
21+
- name: Get swift version
22+
run: env DEVELOPER_DIR="/Applications/Xcode_${{ matrix.xcode }}.app" swift --version
23+
- name: Test
24+
run: env DEVELOPER_DIR="/Applications/Xcode_${{ matrix.xcode }}.app" swift test
25+
- name: Build release
26+
run: env DEVELOPER_DIR="/Applications/Xcode_${{ matrix.xcode }}.app" swift build -c release
27+
28+
Linux:
29+
# https://github.com/actions/runner-images
30+
runs-on: ubuntu-latest
31+
strategy:
32+
matrix:
33+
image: [
34+
'swift:5.8',
35+
'swiftlang/swift@sha256:f212429011a4c3592ffaa660fd78b5bc149e9df7920da02dfc0e7a761582fa10' # swiftlang/swift:nightly-5.9-focal 2023-08-16
36+
]
37+
container:
38+
image: ${{ matrix.image }}
39+
steps:
40+
- uses: actions/checkout@v3
41+
- run: git config --global user.email "[email protected]"
42+
- run: git config --global user.name "Name"
43+
- name: Get swift version
44+
run: swift --version
45+
- name: Test
46+
run: swift test
47+
- name: Build release
48+
run: swift build -c release

.swift-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.travis.yml

Lines changed: 0 additions & 8 deletions
This file was deleted.

Sources/ShellOut.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,6 @@ public extension ShellOutCommand {
316316
.init(command: "swift".unchecked, arguments: ["package", "update"].verbatim)
317317
}
318318

319-
/// Generate an Xcode project for a Swift package
320-
static func generateSwiftPackageXcodeProject() -> ShellOutCommand {
321-
.init(command: "swift".unchecked,
322-
arguments: ["package", "generate-xcodeproj"].verbatim)
323-
}
324-
325319
/// Build a Swift package using a given configuration (see SwiftBuildConfiguration for options)
326320
static func buildSwiftPackage(withConfiguration configuration: SwiftBuildConfiguration = .debug) -> ShellOutCommand {
327321
.init(command: "swift".unchecked,
@@ -424,7 +418,6 @@ private extension Process {
424418
let errorPipe = Pipe()
425419
standardError = errorPipe
426420

427-
#if !os(Linux)
428421
outputPipe.fileHandleForReading.readabilityHandler = { handler in
429422
let data = handler.availableData
430423
outputQueue.async {
@@ -440,21 +433,13 @@ private extension Process {
440433
errorHandle?.write(data)
441434
}
442435
}
443-
#endif
444436

445437
#if os(Linux)
446438
try run()
447439
#else
448440
launch()
449441
#endif
450442

451-
#if os(Linux)
452-
outputQueue.sync {
453-
outputData = outputPipe.fileHandleForReading.readDataToEndOfFile()
454-
errorData = errorPipe.fileHandleForReading.readDataToEndOfFile()
455-
}
456-
#endif
457-
458443
waitUntilExit()
459444

460445
if let handle = outputHandle, !handle.isStandard {
@@ -465,10 +450,8 @@ private extension Process {
465450
handle.closeFile()
466451
}
467452

468-
#if !os(Linux)
469453
outputPipe.fileHandleForReading.readabilityHandler = nil
470454
errorPipe.fileHandleForReading.readabilityHandler = nil
471-
#endif
472455

473456
// Block until all writes have occurred to outputData and errorData,
474457
// and then read the data back out.

Tests/LinuxMain.swift

Lines changed: 0 additions & 6 deletions
This file was deleted.

Tests/ShellOutTests/ShellOutTests+Linux.swift

Lines changed: 0 additions & 24 deletions
This file was deleted.

Tests/ShellOutTests/ShellOutTests.swift

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,16 @@ class ShellOutTests: XCTestCase {
4242
}
4343

4444
func testSingleCommandAtPath() throws {
45+
let tempDir = NSTemporaryDirectory()
4546
try shellOut(
4647
to: "echo".checked,
47-
arguments: [#"Hello" > \#(NSTemporaryDirectory())ShellOutTests-SingleCommand.txt"#.quoted]
48+
arguments: ["Hello", ">".verbatim, "\(tempDir)ShellOutTests-SingleCommand.txt".quoted]
4849
)
4950

5051
let textFileContent = try shellOut(
5152
to: "cat".checked,
5253
arguments: ["ShellOutTests-SingleCommand.txt".quoted],
53-
at: NSTemporaryDirectory()
54+
at: tempDir
5455
)
5556

5657
XCTAssertEqual(textFileContent, "Hello")
@@ -70,7 +71,7 @@ class ShellOutTests: XCTestCase {
7071
}
7172

7273
func testSingleCommandAtPathContainingTilde() throws {
73-
let homeContents = try shellOut(to: "ls".checked, at: "~")
74+
let homeContents = try shellOut(to: "ls".checked, arguments: ["-a"], at: "~")
7475
XCTAssertFalse(homeContents.isEmpty)
7576
}
7677

@@ -180,33 +181,6 @@ class ShellOutTests: XCTestCase {
180181
XCTAssertEqual(try shellOut(to: .readFile(at: filePath)), "Hello again")
181182
}
182183

183-
func testSwiftPackageManagerCommands() throws {
184-
// Setup & clear state
185-
let tempFolderPath = NSTemporaryDirectory()
186-
try shellOut(to: "rm".checked,
187-
arguments: ["-rf", "SwiftPackageManagerTest"].verbatim,
188-
at: tempFolderPath)
189-
try shellOut(to: .createFolder(named: "SwiftPackageManagerTest"), at: tempFolderPath)
190-
191-
// Create a Swift package and verify that it has a Package.swift file
192-
let packagePath = tempFolderPath + "/SwiftPackageManagerTest"
193-
try shellOut(to: .createSwiftPackage(), at: packagePath)
194-
XCTAssertFalse(try shellOut(to: .readFile(at: packagePath + "/Package.swift")).isEmpty)
195-
196-
// Build the package and verify that there's a .build folder
197-
try shellOut(to: .buildSwiftPackage(), at: packagePath)
198-
XCTAssertTrue(
199-
try shellOut(to: "ls".checked, arguments: ["-a".verbatim], at: packagePath) .contains(".build")
200-
)
201-
202-
// Generate an Xcode project
203-
try shellOut(to: .generateSwiftPackageXcodeProject(), at: packagePath)
204-
XCTAssertTrue(
205-
try shellOut(to: "ls".checked, arguments: ["-a".verbatim], at: packagePath)
206-
.contains("SwiftPackageManagerTest.xcodeproj")
207-
)
208-
}
209-
210184
func testArgumentQuoting() throws {
211185
XCTAssertEqual(try shellOut(to: "echo".checked,
212186
arguments: ["foo ; echo bar".quoted]),

0 commit comments

Comments
 (0)