Example #1
0
 protected IEnumerable <string> GetInvokedTargets(ExecutableTarget executableTarget)
 {
     return(executableTarget
            .DescendantsAndSelf(x => x.ExecutionDependencies.Concat(x.Triggers), x => IrrelevantTargetNames.Contains(x.Name))
            .Where(x => x == executableTarget || NonEntryTargets.Contains(x.Name))
            .Reverse()
            .Select(x => x.Name));
 }
Example #2
0
        protected virtual AzurePipelinesJob GetJob(
            ExecutableTarget executableTarget,
            LookupTable <ExecutableTarget, AzurePipelinesJob> jobs)
        {
            var(partitionName, totalPartitions) = ArtifactExtensions.Partitions.GetValueOrDefault(executableTarget.Definition);
            var publishedArtifacts = ArtifactExtensions.ArtifactProducts[executableTarget.Definition]
                                     .Select(x => (AbsolutePath)x)
                                     .Select(x => x.DescendantsAndSelf(y => y.Parent).FirstOrDefault(y => !y.ToString().ContainsOrdinalIgnoreCase("*")))
                                     .Distinct()
                                     .Select(x => x.ToString().TrimStart(x.Parent.ToString()).TrimStart('/', '\\')).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 dependencies = executableTarget.ExecutionDependencies
                               .Where(x => !ExcludedTargets.Contains(x.Name) && !NonEntryTargets.Contains(x.Name))
                               .SelectMany(x => jobs[x]).ToArray();

            return(new AzurePipelinesJob
            {
                Name = executableTarget.Name,
                DisplayName = executableTarget.Name,
                ScriptPath = PowerShellScript,
                Dependencies = dependencies,
                Parallel = totalPartitions,
                PartitionName = partitionName,
                InvokedTargets = invokedTargets,
                PublishArtifacts = publishedArtifacts
            });
        }
Example #3
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
            });
        }