mirror of
https://github.com/github/codeql.git
synced 2025-12-18 18:10:39 +01:00
Track which projects/solutions fail to build
This commit is contained in:
@@ -17,6 +17,8 @@ namespace Semmle.Autobuild.CSharp
|
|||||||
{
|
{
|
||||||
private IEnumerable<Project<CSharpAutobuildOptions>> notDotNetProjects;
|
private IEnumerable<Project<CSharpAutobuildOptions>> notDotNetProjects;
|
||||||
|
|
||||||
|
public readonly List<IProjectOrSolution> FailedProjectsOrSolutions = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A list of projects which are incompatible with DotNet.
|
/// A list of projects which are incompatible with DotNet.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -67,7 +69,10 @@ namespace Semmle.Autobuild.CSharp
|
|||||||
|
|
||||||
var build = GetBuildScript(builder, dotNetPath, environment, projectOrSolution.FullPath);
|
var build = GetBuildScript(builder, dotNetPath, environment, projectOrSolution.FullPath);
|
||||||
|
|
||||||
ret &= BuildScript.Try(clean) & BuildScript.Try(restore) & build;
|
ret &= BuildScript.Try(clean) & BuildScript.Try(restore) & BuildScript.OnFailure(build, ret =>
|
||||||
|
{
|
||||||
|
FailedProjectsOrSolutions.Add(projectOrSolution);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -70,6 +70,9 @@ namespace Semmle.Autobuild.Shared
|
|||||||
/// <returns>The exit code from this build script.</returns>
|
/// <returns>The exit code from this build script.</returns>
|
||||||
public abstract int Run(IBuildActions actions, Action<string, bool> startCallback, Action<int, string, bool> exitCallBack, BuildOutputHandler onOutput, BuildOutputHandler onError);
|
public abstract int Run(IBuildActions actions, Action<string, bool> startCallback, Action<int, string, bool> exitCallBack, BuildOutputHandler onOutput, BuildOutputHandler onError);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A build script which executes an external program or script.
|
||||||
|
/// </summary>
|
||||||
private class BuildCommand : BuildScript
|
private class BuildCommand : BuildScript
|
||||||
{
|
{
|
||||||
private readonly string exe, arguments;
|
private readonly string exe, arguments;
|
||||||
@@ -154,6 +157,9 @@ namespace Semmle.Autobuild.Shared
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A build script which runs a C# function.
|
||||||
|
/// </summary>
|
||||||
private class ReturnBuildCommand : BuildScript
|
private class ReturnBuildCommand : BuildScript
|
||||||
{
|
{
|
||||||
private readonly Func<IBuildActions, int> func;
|
private readonly Func<IBuildActions, int> func;
|
||||||
@@ -333,6 +339,23 @@ namespace Semmle.Autobuild.Shared
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static BuildScript Try(BuildScript s) => s | Success;
|
public static BuildScript Try(BuildScript s) => s | Success;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a build script that runs the build script <paramref name="s" />. If
|
||||||
|
/// running <paramref name="s" /> fails, <paramref name="k" /> is invoked with
|
||||||
|
/// the exit code.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="s">The build script to run.</param>
|
||||||
|
/// <param name="k">
|
||||||
|
/// The callback that is invoked if <paramref name="s" /> failed.
|
||||||
|
/// </param>
|
||||||
|
/// <returns>The build script which implements this.</returns>
|
||||||
|
public static BuildScript OnFailure(BuildScript s, Action<int> k) =>
|
||||||
|
new BindBuildScript(s, ret => Create(actions =>
|
||||||
|
{
|
||||||
|
if (!Succeeded(ret)) k(ret);
|
||||||
|
return ret;
|
||||||
|
}));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a build script that deletes the given directory.
|
/// Creates a build script that deletes the given directory.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using Semmle.Util.Logging;
|
using Semmle.Util.Logging;
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace Semmle.Autobuild.Shared
|
namespace Semmle.Autobuild.Shared
|
||||||
{
|
{
|
||||||
@@ -31,6 +30,11 @@ namespace Semmle.Autobuild.Shared
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class MsBuildRule : IBuildRule<AutobuildOptionsShared>
|
public class MsBuildRule : IBuildRule<AutobuildOptionsShared>
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A list of solutions or projects which failed to build.
|
||||||
|
/// </summary>
|
||||||
|
public readonly List<IProjectOrSolution> FailedProjectsOrSolutions = new();
|
||||||
|
|
||||||
public BuildScript Analyse(IAutobuilder<AutobuildOptionsShared> builder, bool auto)
|
public BuildScript Analyse(IAutobuilder<AutobuildOptionsShared> builder, bool auto)
|
||||||
{
|
{
|
||||||
if (!builder.ProjectsOrSolutionsToBuild.Any())
|
if (!builder.ProjectsOrSolutionsToBuild.Any())
|
||||||
@@ -128,7 +132,13 @@ namespace Semmle.Autobuild.Shared
|
|||||||
|
|
||||||
command.Argument(builder.Options.MsBuildArguments);
|
command.Argument(builder.Options.MsBuildArguments);
|
||||||
|
|
||||||
ret &= command.Script;
|
// append the build script which invokes msbuild to the overall build script `ret`;
|
||||||
|
// we insert a check that building the current project or solution was successful:
|
||||||
|
// if it was not successful, we add it to `FailedProjectsOrSolutions`
|
||||||
|
ret &= BuildScript.OnFailure(command.Script, ret =>
|
||||||
|
{
|
||||||
|
FailedProjectsOrSolutions.Add(projectOrSolution);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user