Posts

Showing posts with the label automatization

GitLab - rules keyword

Image
Today we are going to learn more about the rules  keyword in GitLab. Normally, when you want to spawn your job on a specific branch or only in merge requests you can just use the only/except keywords. But, sometimes it is not enough. For example, what if you want to spawn a job always on develop  branch and run it automatically, but in merge requests you want to run it manually? You cannot (easily) do that with the only/except  keywords. Excerpt from GitLab documentation about the rules  keyword: The rules keyword can be used to include or exclude jobs in pipelines.  Rules are evaluated in order until the first match. When matched, the job is either included or excluded from the pipeline, depending on the configuration. If included, the job also has certain attributes added to it.  rules replaces only/except and can’t be used in conjunction with it. If you attempt to use both keywords in the same job, the linter returns a key may not be used with rules ...

GitLab - extends keyword

Image
In the previous post I had written about the include keyword. Now, let's dive in the extends  keyword. What can you do with this? Here is the definition from GitLab documentation: extends defines entry names that a job that uses extends inherits from. It’s an alternative to using YAML anchors and is a little more flexible and readable. So, when is it useful? It is useful when you want to be DRY and keep your setup cleanly. Let's assume that you want to build a docker image and give developers possibility to deploy the image on dev , staging and prod environments. We are going to do that without the extends keyword, and after that we will think how we can do it better. Example without the extends  keyword: As you can see, there is a lot of code which repeats itself: stage, image, when  and script . We can remove a lot of code! So, let's do that. We are going to create a hidden job .deploy  (you will not see this job in a pipeline) and the rest of the jobs ...

How you can use watchdog to improve your productivity.

Watchdog is a python API and shell utilities to monitor file system events . I am using it for tasks like build sphinx docs or run tests after changes in file/directory. It's very easy to use. For instance, you are writing documentation and after each saving file you have to run command like "make html". So, why you don't this automatically?   Simple command: watchmedo shell-command --command="make html" --wait source What does it? Watchdog began to watch source directory. If something in this directory will be changed, then watchdog will run your command (make html). Simply, right? If you use Firefox you can install Auto Reload add-on. Auto Reload automatically reloads matching tabs when selected local files change. So, after saving file, your documentation will build automatically and Firefox automatically will refresh tab with documentation in browser, brilliant! You can also use patterns. For example, you want to run tests after saving file...