Exemple #1
0
        private void ProcessStep()
        {
            pMain.Visible = pInputForms.Visible = false;
            UITools.ShowToolBarButton(MainToolBar, "Apply");
            UITools.ShowToolBarButton(MainToolBar, "Prev");
            UITools.ShowToolBarButton(MainToolBar, "Next");
            switch (Step)
            {
            case StepEnum.MainInfo:
                lbWizardTitle.Text = "Item categorization";
                pMain.Visible      = true;
                StepNumber         = 1;
                UITools.HideToolBarButton(MainToolBar, "Apply");
                UITools.HideToolBarButton(MainToolBar, "Prev");
                RetrievePossibleParents();
                break;

            case StepEnum.InputFormsInfo:
                lbWizardTitle.Text  = "Inputforms attached";
                pInputForms.Visible = true;
                UITools.HideToolBarButton(MainToolBar, "Next");
                InputFormsInfo();
                break;
            }
            if (Step != StepEnum.MainInfo)
            {
                lbWizardTitle.Text = lbWizardTitle.Text + " [step " + StepNumber.ToString() + "/" + NbSteps.ToString() + "]";
            }
        }
Exemple #2
0
 /// <inheritdoc/>
 public IEnumerable <V1Container> GetContainersFor(StepNumber number, ImprovementContext context)
 {
     return(new []   {
         new V1Container {
             Name = "dotnet-test",
             Image = "microsoft/dotnet:2.2-sdk-bionic",
             Command = new [] {
                 "/bin/bash", "-c",
                 "for TEST_PROJECT in ./Specifications/**/*.csproj; do dotnet test $TEST_PROJECT --no-build --configuration=Release --logger=\"trx;LogFileName=$TEST_PROJECT.trx\" --results-directory=/tests/ ; done"
             },
             WorkingDir = "/source/",
             VolumeMounts = new []   {
                 new V1VolumeMount {
                     Name = "workdir",
                     SubPath = "source",
                     MountPath = "/source/",
                 },
                 new V1VolumeMount {
                     Name = "workdir",
                     SubPath = "nuget",
                     MountPath = "/nuget/",
                 },
                 new V1VolumeMount {
                     Name = "azure",
                     SubPath = context.GetImprovementSubPath("tests"),
                     MountPath = "/tests/",
                 },
             },
         },
     });
 }
Exemple #3
0
 public override void WriterAddAttribute(XmlWriter writer)
 {
     writer.WriteAttributeString("FirstNumber", FirstNumber.ToString());
     writer.WriteAttributeString("LastNumber", LastNumber.ToString());
     writer.WriteAttributeString("StepNumber", StepNumber.ToString());
     base.WriterAddAttribute(writer);
 }
        /// <summary>
        /// Задает значения по умолчанию (значения по варианту).
        /// </summary>
        private void DefaultValues_Click(object sender, EventArgs e)
        {
            RangeFrom             = 0;
            RangeFromTextBox.Text = RangeFrom.ToString();
            RangeFromChecked      = true;

            RangeTo             = 0.05;
            RangeToTextBox.Text = RangeTo.ToString();
            RangeToChecked      = true;

            StepNumber             = 100;
            StepNumberTextBox.Text = StepNumber.ToString();
            StepNumberChecked      = true;

            InitialCondition             = 0;
            InitialConditionTextBox.Text = InitialCondition.ToString();
            InitialConditionChecked      = true;

            Resistance             = 1000;
            ResistanceTextBox.Text = Resistance.ToString();
            ResistanceChecked      = true;

            Capacity             = Math.Pow(10, -5);
            CapacityTextBox.Text = Capacity.ToString();
            CapacityChecked      = true;

            Voltage             = 10;
            VoltageTextBox.Text = Voltage.ToString();
            VoltageChecked      = true;
        }
Exemple #5
0
 public override int GetHashCode()
 {
     if (Project == null)
     {
         return(StepNumber.GetHashCode());
     }
     return(StepNumber.GetHashCode() + Project.GetHashCode());
 }
Exemple #6
0
 public override bool Equals(object obj)
 {
     if (obj is IBuildStep)
     {
         var step = (IBuildStep)obj;
         return(StepNumber.Equals(step.StepNumber));
     }
     else
     {
         return(base.Equals(obj));
     }
 }
Exemple #7
0
        /// <summary>
        /// Возращает путь на диске, где можно сохранять любые файлы, необходимые для логики отката шага транзакции
        /// </summary>
        /// <returns>Путь к папке с файлами</returns>
        public string GetPath(string transactionsPath)
        {
            //string transactionsPath = context.ExecutedPackage.TransactionsPath;
            string transactionPath = Path.Combine(transactionsPath, TransactionName);
            string stepsPath       = Path.Combine(transactionPath, STEPS_SUBFOLDER_NAME);
            string stepPath        = Path.Combine(stepsPath, StepNumber.ToString());

            if (!Directory.Exists(stepPath))
            {
                Directory.CreateDirectory(stepPath);
            }
            return(stepPath);
        }
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(-1);
            }

            IBuildStep step = obj as IBuildStep;

            if (step == null)
            {
                return(-1);
            }

            return(StepNumber.CompareTo(step.StepNumber));
        }
        /// <inheritdoc />
        public void HandleSuccessfulStep(
            RecipeType recipeType,
            StepNumber stepNumber,
            ImprovementId improvement,
            ImprovableId improvable,
            Concepts.Version version)
        {
            var context = _improvementContextFactory.GetFor(improvable, version);
            var recipe  = _recipeLocator.GetByType(recipeType);
            var steps   = recipe.GetStepsFor(context).ToArray();
            var step    = steps[stepNumber];
            var events  = step.GetSucceededEventsFor(context);

            events = events.Concat(new[] { new StepSucceeded(stepNumber) });
            ApplyEventsFor(context, events);
        }
        public void HandleFailedStep(
            RecipeType recipeType,
            StepNumber stepNumber,
            ImprovementId improvement,
            ImprovableId improvable,
            VersionString version)
        {
            var context = _improvementContextFactory.GetFor(improvable, version);
            var recipe  = _recipeLocator.GetByName(recipeType);
            var steps   = recipe.GetStepsFor(context).ToArray();
            var step    = steps[stepNumber];
            var events  = step.GetFailedEventsFor(context);

            events = events.Concat(new[] { new StepFailed(stepNumber) });
            ApplyEventsFor(context, events);
        }
Exemple #11
0
        /// <inheritdoc/>
        public IEnumerable <V1Container> GetContainersFor(StepNumber number, ImprovementContext context)
        {
            var containers = new List <V1Container>();

            if (!context.PullRequest)
            {
                containers.Add(new V1Container {
                    Name         = "git-update-repository",
                    Image        = "dolittlebuild/sourcecontrol-git-update:1.0.0",
                    Command      = new [] { "/bin/sh", "/usr/bin/update_repository.sh", "/source/", context.Improvable.SourceControl.Repository },
                    VolumeMounts = new []   {
                        new V1VolumeMount {
                            Name      = "azure",
                            SubPath   = context.GetImprovableSubPath("source"),
                            MountPath = "/source/",
                        },
                    },
                });
            }

            containers.Add(new V1Container {
                Name         = "copy-source-from-repository",
                Image        = "alpine:3.9",
                Command      = new [] { "/bin/cp", "-R", "/repository/.", "/source/" },
                VolumeMounts = new []   {
                    new V1VolumeMount {
                        Name      = "azure",
                        SubPath   = context.GetImprovableSubPath("source"),
                        MountPath = "/repository/",
                    },
                    new V1VolumeMount {
                        Name      = "workdir",
                        SubPath   = "source",
                        MountPath = "/source/",
                    },
                },
            });

            if (context.PullRequest)
            {
                // FIXME: We need to checkout the merged sha as well!
                throw new System.NotImplementedException();
            }

            return(containers);
        }
        private void UpdateFormVisuals()
        {
            lblGen.Text = StepNumber.ToString();
            lblPop.Text = _lifeGame.LiveCellCount.ToString();

            grdLife.UpdateGrid(_lifeGame.CurrentStates);

            if (InfiniteLoops == false && _lifeGame.LastStates.Count == 10)
            {
                if (_lifeGame.ShortStop)
                {
                    //the game is in an infinite loop. stop it
                    _timer.Stop();
                    _lifeGame.LastStates.Clear();
                    MessageBox.Show("Ending because it will continue repeating as it is forever!");
                }
            }
        }
Exemple #13
0
 /// <inheritdoc/>
 public IEnumerable <V1Container> GetContainersFor(StepNumber number, ImprovementContext context)
 {
     return(new []   {
         new V1Container {
             Name = "dotnet-restore",
             Image = "microsoft/dotnet:2.2-sdk-bionic",
             Command = new [] { "/usr/bin/dotnet", "restore", "--force", "--packages=/nuget/" },
             WorkingDir = "/source/",
             VolumeMounts = new []   {
                 new V1VolumeMount {
                     Name = "workdir",
                     SubPath = "source",
                     MountPath = "/source/",
                 },
                 new V1VolumeMount {
                     Name = "workdir",
                     SubPath = "nuget",
                     MountPath = "/nuget/",
                 },
             },
         },
         new V1Container {
             Name = "dotnet-build",
             Image = "microsoft/dotnet:2.2-sdk-bionic",
             Command = new [] { "/usr/bin/dotnet", "build", "--no-restore", "--packages=/nuget/", "--configuration=Release" },
             WorkingDir = "/source/",
             VolumeMounts = new []   {
                 new V1VolumeMount {
                     Name = "workdir",
                     SubPath = "source",
                     MountPath = "/source/",
                 },
                 new V1VolumeMount {
                     Name = "workdir",
                     SubPath = "nuget",
                     MountPath = "/nuget/",
                 },
             },
         },
     });
 }
        public override int GetHashCode()
        {
            int hash = 1;

            if (StoryboardGmtId.Length != 0)
            {
                hash ^= StoryboardGmtId.GetHashCode();
            }
            if (StepNumber != 0L)
            {
                hash ^= StepNumber.GetHashCode();
            }
            if (RequestVersion != 0)
            {
                hash ^= RequestVersion.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Exemple #15
0
 /// <inheritdoc/>
 public IEnumerable <V1Container> GetContainersFor(StepNumber number, ImprovementContext context)
 {
     return(new []   {
         new V1Container {
             Name = "dotnet-package",
             Image = "microsoft/dotnet:2.2-sdk-bionic",
             WorkingDir = "/source/",
             Command = new [] {
                 "/usr/bin/dotnet", "pack",
                 "--no-build",
                 "--packages=/nuget/",
                 "--configuration=Release",
                 "--output=/output/",
                 "--include-symbols",
                 "--include-source",
                 $"-p:PackageVersion={context.Version}"
             },
             VolumeMounts = new []   {
                 new V1VolumeMount {
                     Name = "workdir",
                     SubPath = "source",
                     MountPath = "/source/",
                 },
                 new V1VolumeMount {
                     Name = "workdir",
                     SubPath = "nuget",
                     MountPath = "/nuget/",
                 },
                 new V1VolumeMount {
                     Name = "workdir",
                     SubPath = "output",
                     MountPath = "/output/",
                 },
             },
         },
         new V1Container {
             Name = "move-symbols-nupkg",
             Image = "alpine:3.9",
             WorkingDir = "/output/",
             Command = new [] { "/bin/sh", "-c", "for NUPKG in *.symbols.nupkg; do cp $NUPKG /publish/${NUPKG/.symbols/} ; mv $NUPKG /nuget/${NUPKG/.symbols/} ; done" },
             VolumeMounts = new []   {
                 new V1VolumeMount {
                     Name = "workdir",
                     SubPath = "output",
                     MountPath = "/output/",
                 },
                 new V1VolumeMount {
                     Name = "workdir",
                     SubPath = "publish",
                     MountPath = "/publish/",
                 },
                 new V1VolumeMount {
                     Name = "azure",
                     SubPath = context.GetImprovementSubPath("nuget"),
                     MountPath = "/nuget/",
                 },
             },
         },
         new V1Container {
             Name = "nuget-push",
             Image = "microsoft/dotnet:2.2-sdk-bionic",
             WorkingDir = "/publish/",
             Command = new [] {
                 "/usr/bin/dotnet", "nuget", "push", "./",
                 "--source=https://www.myget.org/F/dolittle/api/v2/package",
                 "--api-key=SECRET_HERE",
             },
             VolumeMounts = new []   {
                 new V1VolumeMount {
                     Name = "workdir",
                     SubPath = "publish",
                     MountPath = "/publish/",
                 },
             },
         },
     });
 }
Exemple #16
0
 /// <inheritdoc/>
 public LogParserName GetLogParserNameFor(StepNumber number, ImprovementContext context) => "dotnet";
 /// <summary>
 /// Instantiate an instance of
 /// </summary>
 /// <param name="step"></param>
 /// <param name="statuses"></param>
 public TrackedStepStatuses(StepNumber step, IEnumerable <StepStatus> statuses)
 {
     Step     = step;
     Statuses = statuses;
 }
Exemple #18
0
        public string PrintPageComSelenium(IWebDriver driver, bool full = false, int sleep = 0)
        {
            try
            {
                if (sleep > 0)
                {
                    System.Threading.Thread.Sleep(sleep * 1000);
                }

                //Create base directory and set image filename
                string printPath = GetAppPath() + "/Prints" + "/" + CustomerName + "/" + RptID.ToString() + "/" + SuiteName + "/" + ScenarioName + "/" + TestName;
                if (!Directory.Exists(printPath))
                {
                    Directory.CreateDirectory(printPath);
                }
                string filename = printPath + "/" + StepNumber.ToString().PadLeft(4, '0') + "_" + StepTurn.ToString().PadLeft(2, '0') + "-" + TestName.Replace("-", "_") + ".png";
                if (File.Exists(filename))
                {
                    File.Delete(filename);
                }

                if (full)
                {
                    /*
                     *  Dispositivo			Width	X	Heigh
                     *  Reponsive			400		X	1397
                     *  Galaxy S5			360		X	640
                     *  Pixel 2				411		X	731
                     *  Pixel 2 XL			411		X	823
                     *  iPhone 5/SE			320		X	568
                     *  iPhone 6/7/8		375		X	667
                     *  iPhone 6/7/8 Plus	414		X	736
                     *  iPhone X			375		X	812
                     *  iPad				768		X	1024
                     *  iPad Pro			1024	X	1366
                     */

                    Bitmap stitchedImage = null;

                    // First scroll to load all page components
                    ((IJavaScriptExecutor)driver).ExecuteScript(String.Format("window.scrollBy({0}, {1})", 0, -100000));
                    for (int p = 0; p < 200; p++)
                    {
                        ((IJavaScriptExecutor)driver).ExecuteScript(String.Format("window.scrollBy({0}, {1})", 0, 500));
                        System.Threading.Thread.Sleep(5);
                    }
                    ((IJavaScriptExecutor)driver).ExecuteScript(String.Format("window.scrollBy({0}, {1})", 0, -100000));
                    System.Threading.Thread.Sleep(200);

                    // Get full page size
                    long totalwidth1  = (long)((IJavaScriptExecutor)driver).ExecuteScript("return document.body.offsetWidth");//documentElement.scrollWidth");
                    long totalHeight1 = (long)((IJavaScriptExecutor)driver).ExecuteScript("return document.body.parentNode.scrollHeight");
                    int  totalWidth   = (int)totalwidth1;
                    int  totalHeight  = (int)totalHeight1;

                    // Get viewport size
                    long viewportWidth1  = (long)((IJavaScriptExecutor)driver).ExecuteScript("return document.body.clientWidth"); //documentElement.scrollWidth");
                    long viewportHeight1 = (long)((IJavaScriptExecutor)driver).ExecuteScript("return window.innerHeight");        //documentElement.scrollWidth");
                    int  viewportWidth   = (int)viewportWidth1;
                    int  viewportHeight  = (int)viewportHeight1;

                    // Split screen in multiple rectangles
                    List <Rectangle> rectangles = new List <Rectangle>();

                    // Loop until total height
                    for (int i = 0; i < totalHeight; i += viewportHeight)
                    {
                        int newHeight = viewportHeight;

                        // Fix if element height too big
                        if (i + viewportHeight > totalHeight)
                        {
                            newHeight = totalHeight - i;
                        }

                        // Loop until total width
                        for (int ii = 0; ii < totalWidth; ii += viewportWidth)
                        {
                            int newWidth = viewportWidth;

                            // Fix if element width too big
                            if (ii + viewportWidth > totalWidth)
                            {
                                newWidth = totalWidth - ii;
                            }

                            // Create and add new rectangle
                            Rectangle currRect = new Rectangle(ii, i, newWidth, newHeight);
                            rectangles.Add(currRect);
                        }
                    }

                    // Build image
                    stitchedImage = new Bitmap(totalWidth, totalHeight);

                    // Get all screenshots together
                    Rectangle previous = Rectangle.Empty;
                    foreach (var rectangle in rectangles)
                    {
                        // Calculate needed scrolling
                        if (previous != Rectangle.Empty)
                        {
                            int xDiff = rectangle.Right - previous.Right;
                            int yDiff = rectangle.Bottom - previous.Bottom;
                            ((IJavaScriptExecutor)driver).ExecuteScript(String.Format("window.scrollBy({0}, {1})", xDiff, yDiff));
                            System.Threading.Thread.Sleep(200);
                        }

                        // Take screenshot
                        var screenshot = ((ITakesScreenshot)driver).GetScreenshot();

                        // Build an image from the screenshot
                        Image screenshotImage;
                        using (MemoryStream memStream = new MemoryStream(screenshot.AsByteArray))
                        {
                            screenshotImage = Image.FromStream(memStream);
                        }

                        // Calculate source rectangle
                        Rectangle sourceRectangle = new Rectangle(viewportWidth - rectangle.Width, viewportHeight - rectangle.Height, rectangle.Width, rectangle.Height);

                        // Copy image
                        using (Graphics g = Graphics.FromImage(stitchedImage))
                        {
                            g.DrawImage(screenshotImage, rectangle, sourceRectangle, GraphicsUnit.Pixel);
                        }

                        // Set previous rectangle
                        previous = rectangle;
                    }

                    // Save image file
                    stitchedImage.Save(filename, ImageFormat.Png);
                }
                else
                {
                    Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot();
                    ss.SaveAsFile(filename, ScreenshotImageFormat.Png);
                }
                return(filename);
            }
            catch (Exception ex)
            {
                Print("Exception at PrintPageComSelenium", ex);
                return(null);
            }
        }
 public virtual string[] DeriveKeys()
 {
     return(new string[] { ParentAction.Id.ToString(), Stage.ToString(), StepNumber.ToString() });
 }
        protected override void OnLoad(EventArgs e)
        {
            // startup init script
            WetControls.Extensions.ClientScript.InitScript(Page);

            // datepicker script
            if (IsDate)
            {
                WetControls.Extensions.ClientScript.InitDatePicker(this.Page);
            }
            // gouvernment email script
            if (IsGovernmentEmail)
            {
                WetControls.Extensions.ClientScript.InitFrmvldGovemail(this.Page, this.ErrorGovEmail);
            }
            // price script
            if (IsPrice)
            {
                WetControls.Extensions.ClientScript.InitFrmvldPrice(this.Page, this.ErrorPrice);
            }

            if (EnableClientValidation)
            {
                // attributes validation conflicts
                VerifyValidationConflicts();

                if (IsRequired)
                {
                    base.Attributes.Add("required", "required");
                }
                if (IsPhoneNumber)
                {
                    base.Attributes.Add("data-rule-phoneUS", "true");
                }
                if (IsPostalCode)
                {
                    base.Attributes.Add("size", "7");
                    base.Attributes.Add("data-rule-postalCodeCA", "true");
                }
                if (IsEmail)
                {
                    base.Attributes.Add("type", "email");
                }
                if (IsGovernmentEmail)
                {
                    base.Attributes.Add("data-rule-govemail", "true");
                }
                if (IsUrl)
                {
                    base.Attributes.Add("type", "url");
                }
                if (IsDate)
                {
                    base.Attributes.Add("type", "date");
                    base.Attributes.Add("data-rule-dateISO", "true");
                }
                if (IsTime)
                {
                    base.Attributes.Add("type", "time");
                }
                if (IsAlphanumeric)
                {
                    base.Attributes.Add("pattern", "[A-Za-z0-9_\\s]");
                    base.Attributes.Add("data-rule-alphanumeric", "true");
                }
                if (IsDigitsOnly)
                {
                    base.Attributes.Add("type", "number");
                    base.Attributes.Add("data-rule-digits", "true");
                }
                if (IsPrice)
                {
                    base.Attributes.Add("data-rule-price", "true");
                }
                if (IsLettersOnly)
                {
                    base.Attributes.Add("pattern", "[A-Za-z\\s]");
                    base.Attributes.Add("data-rule-lettersonly", "true");
                }
                if (IsLettersWithBasicPunc)
                {
                    base.Attributes.Add("pattern", "[A-Za-z-.,()'\"\\s]");
                    base.Attributes.Add("data-rule-letterswithbasicpunc", "true");
                }
                if (IsNoWhiteSpace)
                {
                    base.Attributes.Add("pattern", "[A-Za-z-.,()'\"\\s]");
                    base.Attributes.Add("data-rule-nowhitespace", "true");
                }
                if (IsNumber)
                {
                    base.Attributes.Add("type", "number");
                }
                if (MinNumber != 0 && MaxNumber != 0)
                {
                    base.Attributes.Add("data-rule-range", string.Format("[{0},{1}]", MinNumber, MaxNumber));
                }
                else if (MinNumber != 0)
                {
                    base.Attributes.Add("min", MinNumber.ToString());
                }
                else if (MaxNumber != 0)
                {
                    base.Attributes.Add("max", MaxNumber.ToString());
                }
                if (StepNumber != 0)
                {
                    base.Attributes.Add("step", StepNumber.ToString());
                }
                if (MinLength > 0 && MaxLength > 0)
                {
                    base.Attributes.Add("data-rule-rangelength", string.Format("[{0},{1}]", MinLength, MaxLength));
                }
                else if (MinLength > 0)
                {
                    base.Attributes.Add("data-rule-minlength", MinLength.ToString());
                }
                else if (MaxLength > 0)
                {
                    base.Attributes.Add("maxlength", MaxLength.ToString());
                }
                if (MinWords > 0 && MaxWords > 0)
                {
                    base.Attributes.Add("data-rule-rangeWords", string.Format("[{0},{1}]", MinWords, MaxWords));
                }
                else if (MinWords > 0)
                {
                    base.Attributes.Add("data-rule-minWords", MinWords.ToString());
                }
                else if (MaxWords > 0)
                {
                    base.Attributes.Add("data-rule-maxWords", MaxWords.ToString());
                }
                if (!string.IsNullOrEmpty(EqualTo))
                {
                    Control ctrl = Page.FindControlRecursive(EqualTo.TrimStart('#')); // prevent tag at beginning
                    base.Attributes.Add("data-rule-equalTo", (ctrl == null ? "#" + EqualTo : "#" + ctrl.ClientID));
                }
                if (!string.IsNullOrEmpty(ValidationErrorMsg))
                {
                    base.Attributes.Add("data-msg", ValidationErrorMsg);
                }
            }
            if (!string.IsNullOrEmpty(Placeholder))
            {
                base.Attributes.Add("placeholder", Placeholder);
            }

            base.OnLoad(e);
        }
 void UpdateDisplay()
 {
     timeText.text = timeElapsed.ToString();
     stepText.text = StepNumber.ToString();
 }
Exemple #22
0
        void ReportStepStatuses(V1Pod pod)
        {
            if (CheckWarnAndDeleteIfPodIsMissingLabels(pod))
            {
                return;
            }

            TenantId      tenantId      = new Guid(pod.Metadata.Labels[PodLabels.Tenant]);
            RecipeType    recipeType    = pod.Metadata.Labels[PodLabels.RecipeType];
            ImprovementId improvementId = new Guid(pod.Metadata.Labels[PodLabels.Improvement]);
            ImprovableId  improvableId  = new Guid(pod.Metadata.Labels[PodLabels.Improvable]);
            VersionString versionString = pod.Metadata.Labels[PodLabels.Version];

            _executionContextManager.CurrentFor(tenantId);
            var stepResultHandler = _stepResultHandlerFactory();

            var buildSteps = new Dictionary <StepNumber, List <StepStatus> >();

            pod.Status.InitContainerStatuses.ForEach(container => {
                var match = _stepNameRegex.Match(container.Name);
                if (match.Success)
                {
                    StepNumber stepNumber = int.Parse(match.Groups[1].Value);
                    //int subStepNumber = int.Parse(match.Groups[2].Value);
                    //var subStepName = match.Groups[3].Value;
                    var exitCode = container.State.Terminated?.ExitCode;

                    var subStepStatus = StepStatus.NotStarted;

                    if (exitCode.HasValue && exitCode != 0)
                    {
                        subStepStatus = StepStatus.Failed;
                    }
                    else if (exitCode.HasValue)
                    {
                        subStepStatus = StepStatus.Succeeded;
                    }
                    else if (container.State.Running != null)
                    {
                        subStepStatus = StepStatus.InProgress;
                    }

                    if (buildSteps.TryGetValue(stepNumber, out var subStepStatuses))
                    {
                        subStepStatuses.Add(subStepStatus);
                    }
                    else
                    {
                        buildSteps.Add(stepNumber, new List <StepStatus>(new [] { subStepStatus }));
                    }
                }
            });
            buildSteps.ForEach(kv => {
                var stepNumber      = kv.Key;
                var subStepStatuses = kv.Value;

                // TODO: These will be called multiple times for each step (at least for successful ones), make sure the state is kept somewhere else!
                if (subStepStatuses.Any(_ => _ == StepStatus.Failed))
                {
                    stepResultHandler.HandleFailedStep(recipeType, stepNumber, improvementId, improvableId, versionString);
                }
                else if (subStepStatuses.All(_ => _ == StepStatus.Succeeded))
                {
                    stepResultHandler.HandleSuccessfulStep(recipeType, stepNumber, improvementId, improvableId, versionString);
                }
            });
        }
Exemple #23
0
        /// <inheritdoc/>
        public V1Pod BuildFrom(ImprovementContext context, IRecipe recipe)
        {
            var pod = new V1Pod {
                Metadata = new V1ObjectMeta {
                    Name = context.Improvement.Id.ToString(),
                    NamespaceProperty = "dolittle-builds",
                    Labels            = new Dictionary <string, string> {
                        { PodLabels.RecipeType, recipe.GetType().Name },
                        { PodLabels.Version, context.Version },
                        { PodLabels.Tenant, context.Tenant.ToString() },
                        { PodLabels.Improvement, context.Improvement.Id.ToString() },
                        { PodLabels.Improvable, context.Improvement.Improvable.ToString() },
                    },
                },

                Spec = new V1PodSpec {
                    RestartPolicy = "Never",

                    Containers = new [] {
                        new V1Container {
                            Name    = "done",
                            Image   = "alpine:3.9",
                            Command = new [] { "/bin/true" },
                        },
                    },

                    Volumes = new [] {
                        new V1Volume {
                            Name      = "azure",
                            AzureFile = new V1AzureFileVolumeSource {
                                ShareName        = "continuousimprovement",
                                SecretName       = "azure-storage-secret",
                                ReadOnlyProperty = false,
                            },
                        },
                        new V1Volume {
                            Name     = "workdir",
                            EmptyDir = new V1EmptyDirVolumeSource {
                            },
                        },
                    },
                },
            };

            var containers = pod.Spec.InitContainers = new List <V1Container>();

            // Copy the loghandler binary to the workdir before anything else
            containers.Add(new V1Container {
                Name         = "copy-loghandler-to-workdir",
                Image        = "alpine:3.9",
                Command      = new [] { "/bin/cp", "/azure-binaries/loghandler", "/workdir-binaries/loghandler" },
                VolumeMounts = new [] {
                    new V1VolumeMount {
                        Name      = "azure",
                        SubPath   = "binaries",
                        MountPath = "/azure-binaries/",
                    },
                    new V1VolumeMount {
                        Name      = "workdir",
                        SubPath   = "binaries",
                        MountPath = "/workdir-binaries/",
                    },
                },
            });

            // Prepare the actual build steps
            StepNumber stepNumber = 0;

            recipe.GetStepsFor(context).ForEach(step => {
                StepNumber subStepNumber = 0;
                step.GetContainersFor(stepNumber, context).ForEach(subStep => {
                    containers.Add(subStep);

                    // Prepend the name of the container with step-N-M- to identify the step later
                    subStep.Name = $"step-{stepNumber}-{subStepNumber}-{subStep.Name}";

                    // Use the log handler to run the actual command
                    ThrowIfNoCommandIsSetForStepContainer(subStep);
                    subStep.Command = subStep.Command.Prepend("/dolittle/loghandler").ToList();

                    if (subStep.Env == null)
                    {
                        subStep.Env = new List <V1EnvVar>();
                    }
                    subStep.Env.Add(new V1EnvVar {
                        Name = "DOLITTLE_BUILD_LOG_RAW_PATH", Value = $"/steps/{stepNumber}.log"
                    });
                    subStep.Env.Add(new V1EnvVar {
                        Name = "DOLITTLE_BUILD_LOG_PARSED_PATH", Value = $"/steps/{stepNumber}.json"
                    });
                    subStep.Env.Add(new V1EnvVar {
                        Name = "DOLITTLE_BUILD_LOG_PARSER", Value = step.GetLogParserNameFor(stepNumber, context)
                    });

                    if (subStep.VolumeMounts == null)
                    {
                        subStep.VolumeMounts = new List <V1VolumeMount>();
                    }
                    subStep.VolumeMounts = subStep.VolumeMounts.Concat(new []   {
                        new V1VolumeMount {
                            Name      = "azure",
                            SubPath   = context.GetImprovementSubPath("steps"),
                            MountPath = "/steps/",
                        },
                        new V1VolumeMount {
                            Name      = "workdir",
                            SubPath   = "binaries",
                            MountPath = "/dolittle/",
                        },
                    }).ToList();

                    subStepNumber++;
                });
                stepNumber++;
            });

            return(pod);
        }
Exemple #24
0
 /// <summary>
 /// Initializes a new instance of <see cref="Step"/>
 /// </summary>
 /// <param name="type"><see cref="Type"/> of <see cref="IPerformer{T}"/></param>
 /// <param name="number"></param>
 /// <param name="configuration">Configuration object instance, if any - can be null</param>
 public Step(Type type, StepNumber number, object configuration = null)
 {
     Type = type;
     Number = number;
     Configuration = configuration;
 }