Search in sources :

Example 1 with DefectSubmitResult

use of com.facebook.buck.rage.DefectSubmitResult in project buck by facebook.

the class RageCommand method runWithoutHelp.

@Override
public int runWithoutHelp(CommandRunnerParams params) throws IOException, InterruptedException {
    ProjectFilesystem filesystem = params.getCell().getFilesystem();
    BuckConfig buckConfig = params.getBuckConfig();
    RageConfig rageConfig = RageConfig.of(buckConfig);
    ProcessExecutor processExecutor = new DefaultProcessExecutor(params.getConsole());
    VersionControlCmdLineInterfaceFactory vcsFactory = new DefaultVersionControlCmdLineInterfaceFactory(params.getCell().getFilesystem().getRootPath(), new PrintStreamProcessExecutorFactory(), new VersionControlBuckConfig(buckConfig), buckConfig.getEnvironment());
    Optional<VcsInfoCollector> vcsInfoCollector = VcsInfoCollector.create(vcsFactory.createCmdLineInterface());
    ExtraInfoCollector extraInfoCollector = new DefaultExtraInfoCollector(rageConfig, filesystem, processExecutor);
    Optional<WatchmanDiagReportCollector> watchmanDiagReportCollector = WatchmanDiagReportCollector.newInstanceIfWatchmanUsed(params.getCell(), filesystem, processExecutor, new ExecutableFinder(), params.getEnvironment());
    AbstractReport report;
    DefaultDefectReporter reporter = new DefaultDefectReporter(filesystem, params.getObjectMapper(), rageConfig, params.getBuckEventBus(), params.getClock());
    if (params.getConsole().getAnsi().isAnsiTerminal() && !nonInteractive) {
        report = new InteractiveReport(reporter, filesystem, params.getObjectMapper(), params.getConsole(), params.getStdIn(), params.getBuildEnvironmentDescription(), vcsInfoCollector, rageConfig, extraInfoCollector, watchmanDiagReportCollector);
    } else {
        report = new AutomatedReport(reporter, filesystem, params.getObjectMapper(), params.getConsole(), params.getBuildEnvironmentDescription(), gatherVcsInfo ? vcsInfoCollector : Optional.empty(), rageConfig, extraInfoCollector);
    }
    Optional<DefectSubmitResult> defectSubmitResult = report.collectAndSubmitResult();
    report.presentDefectSubmitResult(defectSubmitResult, showJson);
    return 0;
}
Also used : ExecutableFinder(com.facebook.buck.io.ExecutableFinder) VcsInfoCollector(com.facebook.buck.rage.VcsInfoCollector) AutomatedReport(com.facebook.buck.rage.AutomatedReport) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) DefaultExtraInfoCollector(com.facebook.buck.rage.DefaultExtraInfoCollector) ExtraInfoCollector(com.facebook.buck.rage.ExtraInfoCollector) RageConfig(com.facebook.buck.rage.RageConfig) DefaultVersionControlCmdLineInterfaceFactory(com.facebook.buck.util.versioncontrol.DefaultVersionControlCmdLineInterfaceFactory) VersionControlBuckConfig(com.facebook.buck.util.versioncontrol.VersionControlBuckConfig) ProcessExecutor(com.facebook.buck.util.ProcessExecutor) DefaultProcessExecutor(com.facebook.buck.util.DefaultProcessExecutor) DefaultVersionControlCmdLineInterfaceFactory(com.facebook.buck.util.versioncontrol.DefaultVersionControlCmdLineInterfaceFactory) VersionControlCmdLineInterfaceFactory(com.facebook.buck.util.versioncontrol.VersionControlCmdLineInterfaceFactory) DefectSubmitResult(com.facebook.buck.rage.DefectSubmitResult) VersionControlBuckConfig(com.facebook.buck.util.versioncontrol.VersionControlBuckConfig) WatchmanDiagReportCollector(com.facebook.buck.rage.WatchmanDiagReportCollector) AbstractReport(com.facebook.buck.rage.AbstractReport) InteractiveReport(com.facebook.buck.rage.InteractiveReport) DefaultDefectReporter(com.facebook.buck.rage.DefaultDefectReporter) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) PrintStreamProcessExecutorFactory(com.facebook.buck.util.PrintStreamProcessExecutorFactory) DefaultExtraInfoCollector(com.facebook.buck.rage.DefaultExtraInfoCollector)

Example 2 with DefectSubmitResult

use of com.facebook.buck.rage.DefectSubmitResult in project buck by facebook.

the class DoctorCommand method runWithoutHelp.

@Override
public int runWithoutHelp(CommandRunnerParams params) throws IOException, InterruptedException {
    ProjectFilesystem filesystem = params.getCell().getFilesystem();
    BuildLogHelper buildLogHelper = new BuildLogHelper(filesystem, params.getObjectMapper());
    UserInput userInput = new UserInput(params.getConsole().getStdOut(), new BufferedReader(new InputStreamReader(params.getStdIn())));
    DoctorReportHelper helper = new DoctorReportHelper(params.getCell().getFilesystem(), userInput, params.getConsole(), params.getObjectMapper(), params.getBuckConfig().getView(DoctorConfig.class));
    Optional<BuildLogEntry> entry = helper.promptForBuild(new ArrayList<>(buildLogHelper.getBuildLogs()));
    if (!entry.isPresent()) {
        params.getConsole().getStdOut().println("No interesting commands found in buck-out/log.");
        return 0;
    }
    Optional<DefectSubmitResult> rageResult = generateRageReport(params, userInput, entry.get());
    if (!rageResult.isPresent()) {
        params.getConsole().printErrorText("Failed to generate report to send.");
        return 1;
    }
    DoctorEndpointRequest request = helper.generateEndpointRequest(entry.get(), rageResult.get());
    DoctorEndpointResponse response = helper.uploadRequest(request);
    helper.presentResponse(response);
    helper.presentRageResult(rageResult);
    return 0;
}
Also used : InputStreamReader(java.io.InputStreamReader) DoctorEndpointRequest(com.facebook.buck.doctor.config.DoctorEndpointRequest) DoctorReportHelper(com.facebook.buck.doctor.DoctorReportHelper) BuildLogHelper(com.facebook.buck.rage.BuildLogHelper) UserInput(com.facebook.buck.rage.UserInput) DoctorConfig(com.facebook.buck.doctor.config.DoctorConfig) BuildLogEntry(com.facebook.buck.rage.BuildLogEntry) DefectSubmitResult(com.facebook.buck.rage.DefectSubmitResult) BufferedReader(java.io.BufferedReader) DoctorEndpointResponse(com.facebook.buck.doctor.config.DoctorEndpointResponse) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem)

Aggregations

ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)2 DefectSubmitResult (com.facebook.buck.rage.DefectSubmitResult)2 DoctorReportHelper (com.facebook.buck.doctor.DoctorReportHelper)1 DoctorConfig (com.facebook.buck.doctor.config.DoctorConfig)1 DoctorEndpointRequest (com.facebook.buck.doctor.config.DoctorEndpointRequest)1 DoctorEndpointResponse (com.facebook.buck.doctor.config.DoctorEndpointResponse)1 ExecutableFinder (com.facebook.buck.io.ExecutableFinder)1 AbstractReport (com.facebook.buck.rage.AbstractReport)1 AutomatedReport (com.facebook.buck.rage.AutomatedReport)1 BuildLogEntry (com.facebook.buck.rage.BuildLogEntry)1 BuildLogHelper (com.facebook.buck.rage.BuildLogHelper)1 DefaultDefectReporter (com.facebook.buck.rage.DefaultDefectReporter)1 DefaultExtraInfoCollector (com.facebook.buck.rage.DefaultExtraInfoCollector)1 ExtraInfoCollector (com.facebook.buck.rage.ExtraInfoCollector)1 InteractiveReport (com.facebook.buck.rage.InteractiveReport)1 RageConfig (com.facebook.buck.rage.RageConfig)1 UserInput (com.facebook.buck.rage.UserInput)1 VcsInfoCollector (com.facebook.buck.rage.VcsInfoCollector)1 WatchmanDiagReportCollector (com.facebook.buck.rage.WatchmanDiagReportCollector)1 DefaultProcessExecutor (com.facebook.buck.util.DefaultProcessExecutor)1