Example #1
0
        private TestHostContext Setup(
            [CallerMemberName] string name = "")
        {
            // Setup the host context.
            TestHostContext hc = new TestHostContext(this, name);

            // Setup the execution context.
            _ec = new Mock <IExecutionContext>();

            GitHubContext githubContext = new GitHubContext();

            _ec.Setup(x => x.GetGitHubContext("repository")).Returns("actions/runner");

            // Store the expected tracking file path.
            _trackingFile = Path.Combine(
                hc.GetDirectory(WellKnownDirectory.Work),
                Constants.Pipeline.Path.PipelineMappingDirectory,
                "actions/runner",
                Constants.Pipeline.Path.TrackingConfigFile);

            _workspaceOptions = new Pipelines.WorkspaceOptions();

            // Setup the tracking manager.
            _trackingManager = new Mock <ITrackingManager>();
            hc.SetSingleton <ITrackingManager>(_trackingManager.Object);

            // Setup the build directory manager.
            _pipelineDirectoryManager = new PipelineDirectoryManager();
            _pipelineDirectoryManager.Initialize(hc);
            return(hc);
        }
Example #2
0
        /// <summary>
        /// Job request message sent to the runner
        /// </summary>
        /// <param name="environmentVariables">Hierarchy of environment variables to overlay, last wins.</param>
        public AgentJobRequestMessage(
            TaskOrchestrationPlanReference plan,
            TimelineReference timeline,
            Guid jobId,
            String jobDisplayName,
            String jobName,
            TemplateToken jobContainer,
            TemplateToken jobServiceContainers,
            IList <TemplateToken> environmentVariables,
            IDictionary <String, VariableValue> variables,
            IList <MaskHint> maskHints,
            JobResources jobResources,
            DictionaryContextData contextData,
            WorkspaceOptions workspaceOptions,
            IEnumerable <JobStep> steps,
            IList <String> fileTable,
            TemplateToken jobOutputs,
            IList <TemplateToken> defaults,
            ActionsEnvironmentReference actionsEnvironment)
        {
            this.MessageType          = JobRequestMessageTypes.PipelineAgentJobRequest;
            this.Plan                 = plan;
            this.JobId                = jobId;
            this.JobDisplayName       = jobDisplayName;
            this.JobName              = jobName;
            this.JobContainer         = jobContainer;
            this.JobServiceContainers = jobServiceContainers;
            this.Timeline             = timeline;
            this.Resources            = jobResources;
            this.Workspace            = workspaceOptions;
            this.JobOutputs           = jobOutputs;
            this.ActionsEnvironment   = actionsEnvironment;
            m_variables               = new Dictionary <String, VariableValue>(variables, StringComparer.OrdinalIgnoreCase);
            m_maskHints               = new List <MaskHint>(maskHints);
            m_steps = new List <JobStep>(steps);

            if (environmentVariables?.Count > 0)
            {
                m_environmentVariables = new List <TemplateToken>(environmentVariables);
            }

            if (defaults?.Count > 0)
            {
                m_defaults = new List <TemplateToken>(defaults);
            }

            this.ContextData = new Dictionary <String, PipelineContextData>(StringComparer.OrdinalIgnoreCase);
            if (contextData?.Count > 0)
            {
                foreach (var pair in contextData)
                {
                    this.ContextData[pair.Key] = pair.Value;
                }
            }

            if (fileTable?.Count > 0)
            {
                m_fileTable = new List <String>(fileTable);
            }
        }
 private WorkspaceOptions(WorkspaceOptions optionsToCopy)
 {
     this.Clean = optionsToCopy.Clean;
 }