rockbruno / danger-SwiftInfo

📊Print SwiftInfo results to individual pull requests.
MIT License
29 stars 0 forks source link

Danger message is empty. #5

Open me2k opened 3 years ago

me2k commented 3 years ago

When running the plug in using Swift info from the command line the danger output is empty.

As I am unable to raise a pull request against this project here is the fix for anyone that may stumble upon this:

To fix this issue, In the /lib/danger_plugin.rb file Replace the run block with this:

def run(path)
    binPath = path + " -pullRequest -s"
    output = `#{binPath}`
    html = output.sub("\n", "<br>")
    message(output)
end

The bash command is being executed without the -pullRequest -s parameters and therefore the Infofile.swift using the suggested if block from the read me will only save the output to a json file and not print anything to the Danger message in the PR.

rockbruno commented 3 years ago

Holy cow, that was a nice find. Thanks a lot for finding this, will push a PR to fix it.

douglastaquary commented 2 years ago

Hey guys,

I'm trying to run SwiftInfo via danger-swiftinfo but the message via danger in PR is empty. In CI it logs the error message when executing swiftinfo via Pods: swiftinfo.run './Pods/SwiftInfo/bin/swiftinfo'

error: unknown argument: '-toolchain'

We use Azure Pipelines.

SwiftInfo version: 2.6.0
Danger-swiftinfo version: 0.1.0

Any suggestion? :)

Log from error:

Generating script.
Script contents:
danger --verbose
========================== Starting Command Output ===========================

error: unknown argument: '-toolchain' 

{"content":"⚠️ 2 Warnings. Don't worry, everything is fixable.\n\n| | 2 Warnings |\n|---|---|\n| ⚠️ | Modified azure-pipelines.yml |\n| ⚠️ | Modified Podfile |\n\n| | 1 Message |\n|---|---|\n| 📖 |  |\n\n\n\nGenerated by :no_entry_sign: [Danger]([https://danger.systems/](https://mcas-proxyweb.mcas.ms/certificate-checker?login=false&originalUrl=https%3A%2F%2Fdanger.systems.mcas.ms%2F%3FMcasTsid%3D26110&McasCSRF=849521a7a3a30e043f4af92d4343b63638dad3ca86b53b5b98f1f95a685a5a67) \"generated_by_danger\")\n"}
Results:

Warnings:
- [ ] Modified azure-pipelines.yml
- [ ] Modified Podfile

Messages:
- [ ] 
Finishing: Run Danger

Infofile.swift:

import SwiftInfoCore
import Foundation

FileUtils.buildLogFilePath = "./build/build_log/MyProject.log"
FileUtils.testLogFilePath = "./build/tests_log/MyProject.log"

let projectInfo = ProjectInfo(xcodeproj: "./MyProject.xcodeproj",
                              target: "MyProject",
                              configuration: isInPullRequestMode ? "Homolog": "Production",
                              plistPath: "./MyProject/Supporting Files/Info.plist")

let api = SwiftInfo(projectInfo: projectInfo)

let output = api.extract(IPASizeProvider.self) +
             api.extract(TotalTestDurationProvider.self) +
             api.extract(TargetCountProvider.self, args: .init(mode: .complainOnRemovals)) +
             api.extract(TestCountProvider.self)

// Lastly, process the output.

if isInPullRequestMode {
    // If called from danger-SwiftInfo, print the results to the pull request
    api.print(output: output)
} else {
    // If called manually, send the results to Slack...
    //api.sendToSlack(output: output, webhookUrl: url)
    // ...and save the output to your repo so it serves as the basis for new comparisons.
    api.save(output: output)
} 
douglastaquary commented 2 years ago

Hey guys,

I did other tests using xcode 12.5 and it worked. 🥳 As of xcode 13.+ gives error when running: ./Pods/SwiftInfo/bin/swiftinfo --verbose

Error: error: unknown argument: '-toolchain'

willwfsp commented 2 years ago

Hey guys,

I did other tests using xcode 12.5 and it worked. 🥳 As of xcode 13.+ gives error when running: ./Pods/SwiftInfo/bin/swiftinfo --verbose

Error: error: unknown argument: '-toolchain'

Hey Bruno and guys 👋

I'm facing the same issue using code 13.+. However, the example app is working pretty well Did anybody find a solution for this?