Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Add end-to-end continuous integration tests for Homebrew distribution #243

Merged
merged 4 commits into from
Apr 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/homebrew_ci.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 2 additions & 6 deletions Tests/EndToEndTests/CoverageSubcommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions Tests/EndToEndTests/DiagramSubcommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 2 additions & 5 deletions Tests/EndToEndTests/GenerateSubcommandTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions Tests/EndToEndTests/Helpers/XCTestCase+Extensions.swift
Original file line number Diff line number Diff line change
@@ -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
}
}