Skip to content

Commit cf195e9

Browse files
authored
Merge pull request #44 from akkyie/github-actions
Replace Willow w/ swift-log, Bitrise w/ GH Actions
2 parents 4bdc726 + c8626cf commit cf195e9

File tree

5 files changed

+53
-24
lines changed

5 files changed

+53
-24
lines changed

.github/workflows/main.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Build and test
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
build-macos:
11+
runs-on: macos-latest
12+
steps:
13+
# Checks-out the repo. More at: https://github.com/actions/checkout
14+
- uses: actions/checkout@v2
15+
- name: Select Xcode version
16+
run: sudo xcode-select -switch /Applications/Xcode_11.4.1.app
17+
- name: Test in Debug
18+
run: swift test -c debug
19+
20+
build-linux:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v2
24+
- uses: Didstopia/[email protected]
25+
with:
26+
swift-action: test --enable-test-discovery

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
/Tests/WAKitTests/XCTestManifests.swift
66

77
/spectest
8+
.vscode

Package.resolved

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ let package = Package(
1818
.package(url: "https://github.com/akkyie/SwiftLEB", from: "0.1.0"),
1919
.package(url: "https://github.com/jakeheis/SwiftCLI", from: "5.0.0"),
2020
.package(url: "https://github.com/onevcat/Rainbow", from: "3.1.4"),
21-
.package(url: "https://github.com/Nike-Inc/Willow", from: "5.1.0"),
21+
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
2222
],
2323
targets: [
2424
.target(
@@ -33,7 +33,7 @@ let package = Package(
3333
),
3434
.target(
3535
name: "CLI",
36-
dependencies: ["WAKit", "SwiftCLI", "Rainbow", "Willow"],
36+
dependencies: ["WAKit", "SwiftCLI", "Rainbow", "Logging"],
3737
path: "./Sources/CLI"
3838
),
3939
],

Sources/CLI/Run/RunCommand.swift

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import Foundation
2+
import Logging
23
import SwiftCLI
34
import WAKit
4-
import Willow
5+
6+
private let logger = Logger(label: "com.WAKit.CLI")
57

68
final class RunCommand: Command {
79
let name = "run"
@@ -11,33 +13,33 @@ final class RunCommand: Command {
1113
let functionName = Parameter()
1214
let arguments = OptionalCollectedParameter()
1315

14-
lazy var logger: Logger = {
15-
Logger(
16-
logLevels: isVerbose.value ? [.error, .warn, .event, .info] : [.error, .warn],
17-
writers: [ConsoleWriter()]
18-
)
19-
}()
20-
2116
func execute() throws {
2217
let isVerbose = self.isVerbose.value
18+
19+
LoggingSystem.bootstrap {
20+
var handler = StreamLogHandler.standardOutput(label: $0)
21+
handler.logLevel = isVerbose ? .info : .warning
22+
return handler
23+
}
24+
2325
let path = self.path.value
2426
let functionName = self.functionName.value
2527

2628
guard let fileHandle = FileHandle(forReadingAtPath: path) else {
27-
logger.errorMessage("File \"\(path)\" could not be opened")
29+
logger.error("File \"\(path)\" could not be opened")
2830
return
2931
}
3032
defer { fileHandle.closeFile() }
3133

3234
let stream = FileHandleStream(fileHandle: fileHandle)
3335

34-
logger.eventMessage("Started to parse module")
36+
logger.info("Started to parse module")
3537

3638
let (module, parseTime) = try measure(if: isVerbose) {
3739
try WASMParser.parse(stream: stream)
3840
}
3941

40-
logger.eventMessage("Ended to parse module: \(parseTime)")
42+
logger.info("Ended to parse module: \(parseTime)")
4143

4244
let runtime = Runtime()
4345
let moduleInstance = try runtime.instantiate(module: module, externalValues: [])
@@ -57,13 +59,13 @@ final class RunCommand: Command {
5759
parameters.append(parameter)
5860
}
5961

60-
logger.eventMessage("Started invoking function \"\(functionName)\" with parameters: \(parameters)")
62+
logger.info("Started invoking function \"\(functionName)\" with parameters: \(parameters)")
6163

6264
let (results, invokeTime) = try measure(if: isVerbose) {
6365
try runtime.invoke(moduleInstance, function: functionName, with: parameters)
6466
}
6567

66-
logger.infoMessage("Ended invoking function \"\(functionName)\": \(invokeTime)")
68+
logger.info("Ended invoking function \"\(functionName)\": \(invokeTime)")
6769

6870
stdout <<< results.description
6971
}

0 commit comments

Comments
 (0)