Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:
- name: Select latest Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.4'
xcode-version: '16.1'

- name: 🛠️ Run All Tests
run: |
xcodebuild test -scheme public-api-diff -destination "platform=iOS,name=Any iOS Device" -skipPackagePluginValidation | xcpretty --utf --color && exit ${PIPESTATUS[0]}
xcodebuild test -scheme public-api-diff-Package -destination "platform=macOS" -skipPackagePluginValidation | xcpretty --utf --color && exit ${PIPESTATUS[0]}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public struct MarkdownOutputGenerator: OutputGenerating {
let changes = Self.changeLines(changesPerModule: changesPerTarget)

var lines = [
Self.title(changesPerTarget: changesPerTarget)
Self.title(changesPerTarget: changesPerTarget, allTargets: allTargets)
]

if let oldVersionName, let newVersionName {
Expand All @@ -46,7 +46,7 @@ public struct MarkdownOutputGenerator: OutputGenerating {
lines += changes + [separator]
}

if let allTargets {
if let allTargets, !allTargets.isEmpty {
lines += [
Self.analyzedModulesInfo(allTargets: allTargets)
]
Expand All @@ -60,7 +60,15 @@ public struct MarkdownOutputGenerator: OutputGenerating {

private extension MarkdownOutputGenerator {

static func title(changesPerTarget: [String: [Change]]) -> String {
static func title(
changesPerTarget: [String: [Change]],
allTargets: [String]?
) -> String {

if let allTargets, allTargets.isEmpty {
// We got targets but the list is empty -> Show an error
return "# ‼️ No analyzable targets detected"
}

if changesPerTarget.keys.isEmpty {
return "# ✅ No changes detected"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public protocol OutputGenerating<OutputType> {
/// Generates an output from input parameters
/// - Parameters:
/// - changesPerTarget: A list of changes per target/module
/// - allTargets: A list of all targets/modules that were analysed in previous steps
/// - allTargets: A list of all targets/modules that were analysed in previous steps - if targets are provided but the list is empty it is treated like a failure
/// - oldVersionName: The name of the old/reference version
/// - newVersionName: The name of the new/updated version
/// - warnings: A list of warnings produced in previous steps
Expand Down
58 changes: 57 additions & 1 deletion Tests/UnitTests/OutputGeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class OutputGeneratorTests: XCTestCase {
newVersionName: "new_source",
warnings: []
)

XCTAssertEqual(output, expectedOutput)
}

Expand Down Expand Up @@ -57,10 +58,11 @@ class OutputGeneratorTests: XCTestCase {
newVersionName: "new_source",
warnings: []
)

XCTAssertEqual(output, expectedOutput)
}

func test_multipleChanges_multipleModules() {
func multipleChanges_multipleModules() {

let expectedOutput = """
# ⚠️ 4 public changes detected ⚠️
Expand Down Expand Up @@ -109,6 +111,60 @@ class OutputGeneratorTests: XCTestCase {
newVersionName: "new_source",
warnings: []
)

XCTAssertEqual(output, expectedOutput)
}

struct AllTargetsExpectation {
let allTargets: [String]?
let expectedTitle: String
let expectedTargetSection: String
}

func test_allTargets_shouldChangeOutputAsExpected() {

let testExpectations: [AllTargetsExpectation] = [
.init(
allTargets: [],
expectedTitle: "‼️ No analyzable targets detected",
expectedTargetSection: ""
),
.init(
allTargets: nil,
expectedTitle: "✅ No changes detected",
expectedTargetSection: ""
),
.init(
allTargets: ["SomeTarget"],
expectedTitle: "✅ No changes detected",
expectedTargetSection: "\n**Analyzed targets:** SomeTarget"
)
]

testExpectations.forEach { argument in
allTargets_shouldChangeOutputAsExpected(argument: argument)
}
}

private func allTargets_shouldChangeOutputAsExpected(argument: AllTargetsExpectation) {

let expectedOutput = """
# \(argument.expectedTitle)
_Comparing `new_source` to `old_repository @ old_branch`_

---\(argument.expectedTargetSection)
"""

let outputGenerator = MarkdownOutputGenerator()

let output = outputGenerator.generate(
from: [:],
allTargets: argument.allTargets,
oldVersionName: "old_repository @ old_branch",
newVersionName: "new_source",
warnings: []
)

XCTAssertEqual(output, expectedOutput)
}
}
2 changes: 2 additions & 0 deletions Tests/public-api-diff.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@
},
"testTargets" : [
{
"parallelizable" : true,
"target" : {
"containerPath" : "container:",
"identifier" : "IntegrationTests",
"name" : "IntegrationTests"
}
},
{
"parallelizable" : true,
"target" : {
"containerPath" : "container:",
"identifier" : "UnitTests",
Expand Down
Loading