Exemplo n.º 1
0
        protected virtual TeamCityProject GetProject(
            NukeBuild build,
            IReadOnlyCollection <ExecutableTarget> executableTargets)
        {
            var relevantTargets = VcsTriggeredTargets.Concat(ManuallyTriggeredTargets)
                                  .SelectMany(x => ExecutionPlanner.GetExecutionPlan(executableTargets, new[] { x }))
                                  .Distinct()
                                  .Where(x => !ExcludedTargets.Contains(x.Name) && !NonEntryTargets.Contains(x.Name)).ToList();

            var vcsRoot     = GetVcsRoot(build);
            var lookupTable = new LookupTable <ExecutableTarget, TeamCityBuildType>();
            var buildTypes  = relevantTargets
                              .SelectMany(x => GetBuildTypes(build, x, vcsRoot, lookupTable), (x, y) => (ExecutableTarget: x, BuildType: y))
                              .ForEachLazy(x => lookupTable.Add(x.ExecutableTarget, x.BuildType))
                              .Select(x => x.BuildType).ToArray();

            var parameters = GetGlobalParameters(build);

            if (Platform == TeamCityAgentPlatform.Windows)
            {
                parameters = parameters
                             .Concat(new TeamCityKeyValueParameter
                {
                    Key   = "teamcity.runner.commandline.stdstreams.encoding",
                    Value = "IBM-437"
                });
            }

            return(new TeamCityProject
            {
                VcsRoot = vcsRoot,
                BuildTypes = buildTypes,
                Parameters = parameters.ToArray()
            });
        }
Exemplo n.º 2
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));
 }
Exemplo n.º 3
0
        protected override void Generate(NukeBuild build, IReadOnlyCollection <ExecutableTarget> executableTargets)
        {
            var relevantTargets = InvokedTargets
                                  .SelectMany(x => ExecutionPlanner.GetExecutionPlan(executableTargets, new[] { x }))
                                  .Distinct()
                                  .Where(x => !ExcludedTargets.Contains(x.Name) && !NonEntryTargets.Contains(x.Name)).ToList();

            var configuration = GetConfiguration(relevantTargets);

            using var writer = new CustomFileWriter(ConfigurationFile, indentationFactor: 2);
            configuration.Write(writer);
        }
Exemplo n.º 4
0
        protected override void Generate(NukeBuild build, IReadOnlyCollection <ExecutableTarget> executableTargets)
        {
            var relevantTargets = VcsTriggeredTargets.Concat(ManuallyTriggeredTargets)
                                  .SelectMany(x => ExecutionPlanner.GetExecutionPlan(executableTargets, new[] { x }))
                                  .Distinct()
                                  .Where(x => !ExcludedTargets.Contains(x.Name) && !NonEntryTargets.Contains(x.Name)).ToList();
            var configuration = GetConfiguration(build, relevantTargets);

            ControlFlow.Assert(NukeBuild.RootDirectory != null, "NukeBuild.RootDirectory != null");

            TextTasks.WriteAllLines(
                PomFile,
                ResourceUtility.GetResourceAllLines <TeamCityConfigurationEntity>("pom.xml"));

            using var writer = new CustomFileWriter(SettingsFile, indentationFactor: 4);
            configuration.Write(writer);
        }
Exemplo n.º 5
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
            });
        }
Exemplo n.º 6
0
        protected IEnumerable <ExecutableTarget> GetInvokedTargets(ExecutableTarget executableTarget, IReadOnlyCollection <ExecutableTarget> relevantTargets)
        {
            var invokedTargets = new List <ExecutableTarget> {
                executableTarget
            };
            ICollection <ExecutableTarget> additionalInvokedTargets;

            do
            {
                additionalInvokedTargets = invokedTargets.SelectMany(x => x.ExecutionDependencies)
                                           .Concat(invokedTargets.SelectMany(x => x.Triggers))
                                           .Except(invokedTargets)
                                           .Where(x => NonEntryTargets.Contains(x.Name))
                                           .Where(x => !ExcludedTargets.Contains(x.Name)).ToList();
                invokedTargets.AddRange(additionalInvokedTargets);
            } while (additionalInvokedTargets.Count > 0);

            return(ExecutionPlanner.GetExecutionPlan(invokedTargets, new[] { executableTarget.Name }));
        }
        protected IEnumerable <ExecutableTarget> GetInvokedTargets(ExecutableTarget executableTarget, IReadOnlyCollection <ExecutableTarget> relevantTargets)
        {
            var invokedTargets = new List <ExecutableTarget> {
                executableTarget
            };
            ICollection <ExecutableTarget> additionalInvokedTargets;

            do
            {
                additionalInvokedTargets = invokedTargets.SelectMany(x => x.ExecutionDependencies)
                                           .Concat(invokedTargets.SelectMany(x => x.Triggers))
                                           .Except(invokedTargets)
                                           .Where(x => NonEntryTargets.Contains(x.Name))
                                           .Where(x => !ExcludedTargets.Contains(x.Name)).ToList();
                invokedTargets.AddRange(additionalInvokedTargets);
            } while (additionalInvokedTargets.Count > 0);

            Assert.True(invokedTargets.Except(new[] { executableTarget }).Count(x => x.PartitionSize != null) == 0,
                        $"Non-entry targets for {executableTarget.Name} cannot define partitions");
            return(ExecutionPlanner.GetExecutionPlan(invokedTargets, new[] { executableTarget.Name }));
        }