Exemple #1
0
        protected override IEnumerable <TeamCityBuildType> GetBuildTypes(
            NukeBuild build,
            ExecutableTarget executableTarget,
            TeamCityVcsRoot vcsRoot,
            LookupTable <ExecutableTarget, TeamCityBuildType> buildTypes,
            IReadOnlyCollection <ExecutableTarget> relevantTargets)
        {
            var dictionary = new Dictionary <string, string>
            {
                { nameof(Compile), "⚙️" },
                { nameof(Test), "🚦" },
                { nameof(Pack), "📦" },
                { nameof(Coverage), "📊" },
                { nameof(Publish), "🚚" },
                { nameof(Announce), "🗣" }
            };

            return(base.GetBuildTypes(build, executableTarget, vcsRoot, buildTypes, relevantTargets)
                   .ForEachLazy(x =>
            {
                var symbol = dictionary.GetValueOrDefault(x.InvokedTargets.Last()).NotNull("symbol != null");
                x.Name = x.PartitionName == null
                        ? $"{symbol} {x.Name}"
                        : $"{symbol} {x.InvokedTargets.Last()} 🧩 {x.Partition}";
            }));
        }
Exemple #2
0
        protected override IEnumerable <TeamCityBuildType> GetBuildTypes(
            NukeBuild build,
            ExecutableTarget executableTarget,
            TeamCityVcsRoot vcsRoot,
            LookupTable <ExecutableTarget, TeamCityBuildType> buildTypes)
        {
            var dictionary = new Dictionary <string, string>
            {
                { nameof(Compile), "⚙️" },
                { nameof(Test), "🚦" },
                { nameof(Pack), "📦" },
                { nameof(Publish), "🚚" },
                { nameof(Announce), "🗣" }
            };

            return(base.GetBuildTypes(build, executableTarget, vcsRoot, buildTypes)
                   .ForEachLazy(x =>
            {
                if (dictionary.TryGetValue(x.Name, out var prefix))
                {
                    x.Name = $"{prefix} {x.Name}";
                }
                else if (dictionary.TryGetValue(x.PartitionTarget, out var prefix2))
                {
                    x.Name = $"{prefix2} {x.PartitionTarget} 🧩 {x.Partition}";
                }
            }));
        }
Exemple #3
0
 protected override IEnumerable <TeamCityBuildType> GetBuildTypes(
     NukeBuild build,
     ExecutableTarget executableTarget,
     TeamCityVcsRoot vcsRoot,
     LookupTable <ExecutableTarget, TeamCityBuildType> buildTypes,
     IReadOnlyCollection <ExecutableTarget> relevantTargets)
 {
     return(base.GetBuildTypes(build, executableTarget, vcsRoot, buildTypes, relevantTargets)
            .ForEachLazy(x =>
     {
         var symbol = CustomNames.GetValueOrDefault(x.InvokedTargets.Last());
         x.Name = (x.Partition == null
                 ? $"{symbol} {x.Name}"
                 : $"{symbol} {x.InvokedTargets.Last()} 🧩 {x.Partition}").Trim();
     }));
 }
Exemple #4
0
        protected virtual IEnumerable <TeamCityBuildType> GetBuildTypes(
            NukeBuild build,
            ExecutableTarget executableTarget,
            TeamCityVcsRoot vcsRoot,
            LookupTable <ExecutableTarget, TeamCityBuildType> buildTypes,
            IReadOnlyCollection <ExecutableTarget> relevantTargets)
        {
            var chainLinkTargets = GetInvokedTargets(executableTarget, relevantTargets).ToArray();
            var isPartitioned    = ArtifactExtensions.Partitions.ContainsKey(executableTarget.Definition);

            var artifactRules = chainLinkTargets.SelectMany(x =>
                                                            ArtifactExtensions.ArtifactProducts[x.Definition].Select(GetArtifactRule)).ToArray();
            var artifactDependencies = chainLinkTargets.SelectMany(x =>
                                                                   from artifactDependency in ArtifactExtensions.ArtifactDependencies[x.Definition]
                                                                   let dependency                         = relevantTargets.Single(y => y.Factory == artifactDependency.Item1)
                                                                                                let rules = (artifactDependency.Item2.Any()
                        ? artifactDependency.Item2
                        : ArtifactExtensions.ArtifactProducts[dependency.Definition])
                                                                                                            .Select(GetArtifactRule).ToArray()
                                                                                                            select new TeamCityArtifactDependency
            {
                BuildType     = buildTypes[dependency].Single(y => y.Partition == null),
                ArtifactRules = rules
            }).ToArray <TeamCityDependency>();

            var snapshotDependencies = GetTargetDependencies(executableTarget)
                                       .SelectMany(x => buildTypes[x])
                                       .Where(x => x.Partition == null)
                                       .Select(x => new TeamCitySnapshotDependency
            {
                BuildType     = x,
                FailureAction = TeamCityDependencyFailureAction.FailToStart,
                CancelAction  = TeamCityDependencyFailureAction.Cancel
            }).ToArray <TeamCityDependency>();

            if (isPartitioned)
            {
                var(partitionName, totalPartitions) = ArtifactExtensions.Partitions[executableTarget.Definition];
                for (var i = 0; i < totalPartitions; i++)
                {
                    var partition = new Partition {
                        Part = i + 1, Total = totalPartitions
                    };
                    yield return(new TeamCityBuildType
                    {
                        Id = $"{executableTarget.Name}_P{partition.Part}T{partition.Total}",
                        Name = $"{executableTarget.Name} {partition}",
                        Description = executableTarget.Description,
                        BuildCmdPath = BuildCmdPath,
                        ArtifactRules = artifactRules,
                        Partition = partition,
                        PartitionName = partitionName,
                        InvokedTargets = chainLinkTargets.Select(x => x.Name).ToArray(),
                        VcsRoot = new TeamCityBuildTypeVcsRoot {
                            Root = vcsRoot, CleanCheckoutDirectory = CleanCheckoutDirectory
                        },
                        Dependencies = snapshotDependencies.Concat(artifactDependencies).ToArray()
                    });
                }

                artifactRules        = new[] { "**/*" };
                snapshotDependencies = buildTypes[executableTarget]
                                       .Select(x => new TeamCitySnapshotDependency
                {
                    BuildType     = x,
                    FailureAction = TeamCityDependencyFailureAction.AddProblem,
                    CancelAction  = TeamCityDependencyFailureAction.Cancel
                }).ToArray <TeamCityDependency>();
                artifactDependencies = buildTypes[executableTarget]
                                       .Select(x => new TeamCityArtifactDependency
                {
                    BuildType     = x,
                    ArtifactRules = new[] { "**/*" }
                }).ToArray <TeamCityDependency>();
            }

            var parameters = executableTarget.Requirements
                             .Where(x => !(x is Expression <Func <bool> >))
                             .Select(x => GetParameter(x.GetMemberInfo(), build, required: true))
                             .Concat(new TeamCityKeyValueParameter(
                                         "teamcity.ui.runButton.caption",
                                         executableTarget.Name.SplitCamelHumpsWithSeparator(" ", Constants.KnownWords))).ToArray();
            var triggers = GetTriggers(executableTarget, buildTypes).ToArray();

            yield return(new TeamCityBuildType
            {
                Id = executableTarget.Name,
                Name = executableTarget.Name,
                Description = executableTarget.Description,
                BuildCmdPath = BuildCmdPath,
                VcsRoot = new TeamCityBuildTypeVcsRoot
                {
                    Root = vcsRoot,
                    ShowDependenciesChanges = isPartitioned,
                    CleanCheckoutDirectory = CleanCheckoutDirectory
                },
                IsComposite = isPartitioned,
                IsDeployment = ManuallyTriggeredTargets.Contains(executableTarget.Name),
                InvokedTargets = chainLinkTargets.Select(x => x.Name).ToArray(),
                ArtifactRules = artifactRules,
                Dependencies = snapshotDependencies.Concat(artifactDependencies).ToArray(),
                Parameters = parameters,
                Triggers = triggers
            });
        }
Exemple #5
0
        protected virtual IEnumerable <TeamCityBuildType> GetBuildTypes(
            NukeBuild build,
            ExecutableTarget executableTarget,
            TeamCityVcsRoot vcsRoot,
            LookupTable <ExecutableTarget, TeamCityBuildType> buildTypes)
        {
            var isPartitioned        = ArtifactExtensions.Partitions.ContainsKey(executableTarget.Definition);
            var artifactRules        = ArtifactExtensions.ArtifactProducts[executableTarget.Definition].Select(GetArtifactRule).ToArray();
            var artifactDependencies = (
                from artifactDependency in ArtifactExtensions.ArtifactDependencies[executableTarget.Definition]
                let dependency = executableTarget.ExecutionDependencies.Single(x => x.Factory == artifactDependency.Item1)
                                 let rules = (artifactDependency.Item2.Any()
                        ? artifactDependency.Item2
                        : ArtifactExtensions.ArtifactProducts[dependency.Definition])
                                             .Select(GetArtifactRule).ToArray()
                                             select new TeamCityArtifactDependency
            {
                BuildType = buildTypes[dependency].Single(x => x.Partition == null),
                ArtifactRules = rules
            }).ToArray <TeamCityDependency>();

            var invokedTargets = executableTarget
                                 .DescendantsAndSelf(x => x.ExecutionDependencies, x => NonEntryTargets.Contains(x.Name))
                                 .Where(x => x == executableTarget || NonEntryTargets.Contains(x.Name))
                                 .Reverse()
                                 .Select(x => x.Name).ToArray();
            var snapshotDependencies = executableTarget.ExecutionDependencies
                                       .Where(x => !ExcludedTargets.Contains(x.Name) && !NonEntryTargets.Contains(x.Name))
                                       .SelectMany(x => buildTypes[x])
                                       .Where(x => x.Partition == null)
                                       .Select(x => new TeamCitySnapshotDependency
            {
                BuildType     = x,
                FailureAction = TeamCityDependencyFailureAction.FailToStart,
                CancelAction  = TeamCityDependencyFailureAction.Cancel
            }).ToArray <TeamCityDependency>();

            if (isPartitioned)
            {
                var partitions = ArtifactExtensions.Partitions[executableTarget.Definition];
                for (var i = 0; i < partitions; i++)
                {
                    var partition = new Partition {
                        Part = i + 1, Total = partitions
                    };
                    yield return(new TeamCityBuildType
                    {
                        Id = $"{executableTarget.Name}_P{partition.Part}T{partition.Total}",
                        Name = $"{executableTarget.Name} {partition}",
                        Description = executableTarget.Description,
                        Platform = Platform,
                        ArtifactRules = artifactRules,
                        Partition = partition,
                        PartitionTarget = executableTarget.Name,
                        InvokedTargets = invokedTargets,
                        VcsRoot = new TeamCityBuildTypeVcsRoot {
                            Root = vcsRoot
                        },
                        Dependencies = snapshotDependencies.Concat(artifactDependencies).ToArray()
                    });
                }

                snapshotDependencies = buildTypes[executableTarget]
                                       .Select(x => new TeamCitySnapshotDependency
                {
                    BuildType     = x,
                    FailureAction = TeamCityDependencyFailureAction.FailToStart,
                    CancelAction  = TeamCityDependencyFailureAction.Cancel
                }).ToArray <TeamCityDependency>();
                artifactDependencies = new TeamCityDependency[0];
            }

            var parameters = executableTarget.Requirements
                             .Where(x => !(x is Expression <Func <bool> >))
                             .Select(x => GetParameter(x.GetMemberInfo(), build, required: true)).ToArray();
            var triggers = GetTriggers(executableTarget, buildTypes).ToArray();

            yield return(new TeamCityBuildType
            {
                Id = executableTarget.Name,
                Name = executableTarget.Name,
                Description = executableTarget.Description,
                Platform = Platform,
                VcsRoot = new TeamCityBuildTypeVcsRoot
                {
                    Root = vcsRoot,
                    ShowDependenciesChanges = isPartitioned
                },
                IsComposite = isPartitioned,
                InvokedTargets = invokedTargets,
                ArtifactRules = artifactRules,
                Dependencies = snapshotDependencies.Concat(artifactDependencies).ToArray(),
                Parameters = parameters,
                Triggers = triggers
            });
        }