diff --git a/.github/workflows/homebrew_ci.yml b/.github/workflows/homebrew_ci.yml new file mode 100644 index 00000000..50bcc06d --- /dev/null +++ b/.github/workflows/homebrew_ci.yml @@ -0,0 +1,45 @@ +name: Homebrew CI + +on: + push: + branches: [master] + schedule: + - cron: 0 0 * * * + +jobs: + homebrew-bottle: + runs-on: macos-10.15 + name: Test Homebrew installation from bottle + + steps: + - name: Checkout + uses: actions/checkout@v1 + - uses: actions/cache@v2 + with: + path: .build + key: ${{ runner.os }}-spm-xcode-${{ matrix.xcode }}-${{ hashFiles('**/Package.resolved') }} + restore-keys: | + ${{ runner.os }}-spm-xcode-${{ matrix.xcode }}- + - name: Install swift-doc + run: brew install swiftdocorg/formulae/swift-doc --force-bottle + - name: Run Tests + run: | + swift test --filter EndToEndTests. -Xswiftc -DUSE_HOMEBREW + + homebrew-sources: + runs-on: macos-11.0 + + name: Test Homebrew installation from sources + steps: + - name: Checkout + uses: actions/checkout@v1 + - uses: actions/cache@v2 + with: + path: .build + key: ${{ runner.os }}-spm-xcode-${{ hashFiles('**/Package.resolved') }} + restore-keys: | + ${{ runner.os }}-spm-xcode- + - name: Install swift-doc + run: brew install swiftdocorg/formulae/swift-doc --build-from-source + - name: Run Tests + run: swift test --filter EndToEndTests. -Xswiftc -DUSE_HOMEBREW diff --git a/Tests/EndToEndTests/CoverageSubcommandTests.swift b/Tests/EndToEndTests/CoverageSubcommandTests.swift index 548befa0..c28bb772 100644 --- a/Tests/EndToEndTests/CoverageSubcommandTests.swift +++ b/Tests/EndToEndTests/CoverageSubcommandTests.swift @@ -2,12 +2,10 @@ import XCTest final class CoverageSubcommandTests: XCTestCase { func testStandardOutput() throws { - let command = Bundle.productsDirectory.appendingPathComponent("swift-doc") - let outputDirectory = try temporaryDirectory() defer { try? FileManager.default.removeItem(at: outputDirectory) } - try Process.run(command: command, + try Process.run(command: swiftDocCommand, arguments: [ "coverage", "Sources" @@ -20,13 +18,11 @@ final class CoverageSubcommandTests: XCTestCase { } func testFileOutput() throws { - let command = Bundle.productsDirectory.appendingPathComponent("swift-doc") - let outputDirectory = try temporaryDirectory() let outputFile = outputDirectory.appendingPathComponent("report.json") defer { try? FileManager.default.removeItem(at: outputDirectory) } - try Process.run(command: command, + try Process.run(command: swiftDocCommand, arguments: [ "coverage", "--output", outputFile.path, diff --git a/Tests/EndToEndTests/DiagramSubcommandTests.swift b/Tests/EndToEndTests/DiagramSubcommandTests.swift index 60a3ea27..04feb3cd 100644 --- a/Tests/EndToEndTests/DiagramSubcommandTests.swift +++ b/Tests/EndToEndTests/DiagramSubcommandTests.swift @@ -2,12 +2,10 @@ import XCTest final class DiagramSubcommandTests: XCTestCase { func testStandardOutput() throws { - let command = Bundle.productsDirectory.appendingPathComponent("swift-doc") - let outputDirectory = try temporaryDirectory() defer { try? FileManager.default.removeItem(at: outputDirectory) } - try Process.run(command: command, + try Process.run(command: swiftDocCommand, arguments: [ "diagram", "Sources" diff --git a/Tests/EndToEndTests/GenerateSubcommandTests.swift b/Tests/EndToEndTests/GenerateSubcommandTests.swift index dc2bcde4..8557d5fc 100644 --- a/Tests/EndToEndTests/GenerateSubcommandTests.swift +++ b/Tests/EndToEndTests/GenerateSubcommandTests.swift @@ -2,12 +2,10 @@ import XCTest final class GenerateSubcommandTests: XCTestCase { func testCommonMark() throws { - let command = Bundle.productsDirectory.appendingPathComponent("swift-doc") - let outputDirectory = try temporaryDirectory() defer { try? FileManager.default.removeItem(at: outputDirectory) } - try Process.run(command: command, + try Process.run(command: swiftDocCommand, arguments: [ "generate", "--module-name", "SwiftDoc", @@ -44,11 +42,10 @@ final class GenerateSubcommandTests: XCTestCase { } func testHTML() throws { - let command = Bundle.productsDirectory.appendingPathComponent("swift-doc") let outputDirectory = try temporaryDirectory() defer { try? FileManager.default.removeItem(at: outputDirectory) } - try Process.run(command: command, + try Process.run(command: swiftDocCommand, arguments: [ "generate", "--module-name", "SwiftDoc", diff --git a/Tests/EndToEndTests/Helpers/XCTestCase+Extensions.swift b/Tests/EndToEndTests/Helpers/XCTestCase+Extensions.swift new file mode 100644 index 00000000..32ced846 --- /dev/null +++ b/Tests/EndToEndTests/Helpers/XCTestCase+Extensions.swift @@ -0,0 +1,12 @@ +import XCTest +import Foundation + +extension XCTestCase { + var swiftDocCommand: URL { + #if USE_HOMEBREW + return URL(fileURLWithPath: "/usr/local/bin/swift-doc") + #else + return Bundle.productsDirectory.appendingPathComponent("swift-doc") + #endif + } +}