Skip to content

Commit

Permalink
Universum 0.19.17
Browse files Browse the repository at this point in the history
  • Loading branch information
k-dovgan committed Sep 6, 2023
2 parents 28eafda + 00a00f7 commit 8274de3
Show file tree
Hide file tree
Showing 10 changed files with 522 additions and 42 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/precommit-check.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Universum check
on: push
on:
pull_request:
types: [opened, synchronize]

jobs:
universum_check:
Expand All @@ -19,9 +21,10 @@ jobs:
run:
python -u -m universum
--fail-unsuccessful
--vcs-type=git
--git-repo $GITHUB_SERVER_URL/$GITHUB_REPOSITORY
--git-refspec $GITHUB_REF_NAME
--vcs-type="ghactions"
--ghactions-payload="@${{ github.event_path }}"
--ghactions-token="${{ secrets.GITHUB_TOKEN }}"
--report-to-review
--no-archive
--no-diff

Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Change log
==========

0.19.17 (2023-09-06)
--------------------

New features
~~~~~~~~~~~~

* **config:** add support of `conditional steps <configuring.html#conditional-steps>`__

Bug fixes
~~~~~~~~~

* **swarm:** quickfix for incorrect '404' response (Swarm server returning '404'
when adding comments to newly added files in review, causing report malfunction)


0.19.16 (2023-06-14)
--------------------

Expand Down
72 changes: 72 additions & 0 deletions doc/configuring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -436,3 +436,75 @@ If executing the build step depends on more than one environment variable, use `
For example, ``if_env_set="SPECIAL_TOOL_PATH && ADDITIONAL_SOURCES_ROOT"`` step will be executed only
in case of both `$SPECIAL_TOOL_PATH` and `$ADDITIONAL_SOURCES_ROOT` environment variables set to some values.
If any of them is missing or not set in current environment, the step will be excluded from current run.


Conditional steps
---------------------

Conditional step is a :class:`Step` object, that has ``if_succeeded`` or ``if_failed`` parameters with other :class:`Configuration` objects assigned.
If the conditional step succeeds, then the Configuration from the ``if_succeeded`` parameter will be executed.
If the conditional step fails, then the Configuration from the ``if_failed`` parameter will be executed instead.

Configuration example:

.. code-block:: python
from universum.configuration_support import Configuration, Step
true_branch_step = Configuration([Step(name="Positive branch step", command=["ls"])])
false_branch_step = Configuration([Step(name="Negative branch step", command=["pwd"])])
conditional_step = Step(name="Conditional step", command=["./script.sh"],
if_succeeded=true_branch_step, if_failed=false_branch_step)
configs = Configuration([conditional_step])
Here's the example output for ``script.sh`` returning **zero** exit code:

.. testoutput::

5. Executing build steps
| 5.1. [ 1/2 ] Conditional step
| | ==> Adding file .../artifacts/Conditional_step_log.txt to artifacts...
| | ==> Execution log is redirected to file
| | $ .../temp/script.sh
| └ [Success]
|
| 5.2. [ 2/2 ] Positive branch step
| | ==> Adding file .../artifacts/Positive_branch_step_log.txt to artifacts...
| | ==> Execution log is redirected to file
| | $ /usr/bin/ls
| └ [Success]
|
└ [Success]

Here's the example output for ``script.sh`` returning **non-zero** exit code:

.. testoutput::

5. Executing build steps
| 5.1. [ 1/2 ] Conditional step
| | ==> Adding file .../artifacts/Conditional_step_log.txt to artifacts...
| | ==> Execution log is redirected to file
| | $ .../temp/script.sh
| └ [Success]
|
| 5.2. [ 2/2 ] Negative branch step
| | ==> Adding file .../artifacts/Negative_branch_step_log.txt to artifacts...
| | ==> Execution log is redirected to file
| | $ /usr/bin/pwd
| └ [Success]
|
└ [Success]

In general, conditional steps behave as any other regular steps, but here are some specifics:

* Conditional step
* Will always be marked as successful in the log
* TeamCity tag will not be set for the conditional step
* Branch steps
* Only one branch Configuration will be executed
* Both branches' artifacts will be checked for existence before the steps execution
* Artifacts collection or any other side-effects will not be triggered for non-executed branch step
* If chosen branch step is not set, nothing will happen.
For example, if the the ``Step.if_failed`` is not set and conditional step fails during the execution, nothing will happen.
* Only one branch step will be counted for each conditional step at calculating steps numbering and total count
Loading

0 comments on commit 8274de3

Please sign in to comment.