Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add docs for automatin rules #6072

Merged
merged 9 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 137 additions & 0 deletions docs/automation-rules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
Automation Rules
================

Automation rules allow you to execute some actions over new versions.
stsewd marked this conversation as resolved.
Show resolved Hide resolved

By default when new versions are created,
they are not activated.
If you want to activate it and do other type of actions,
you need to log in your Read the Docs account first.
stsewd marked this conversation as resolved.
Show resolved Hide resolved

Creating an automation rule
---------------------------

#. Go to your project :guilabel:`Admin` > :guilabel:`Automation Rules`
stsewd marked this conversation as resolved.
Show resolved Hide resolved
stsewd marked this conversation as resolved.
Show resolved Hide resolved
#. Click on "Add Rule" button
stsewd marked this conversation as resolved.
Show resolved Hide resolved
#. Fill in the fields

- Description: A description of what the rule does
- Match: What versions the rule should be applied to
- Version type: What type of versions the rule should be applied to
- Action: What action should be applied to matching versions
stsewd marked this conversation as resolved.
Show resolved Hide resolved

#. Click "Save"
stsewd marked this conversation as resolved.
Show resolved Hide resolved

How do they work?
-----------------

When a new tag or branch is pushed to your repository,
Read the Docs creates a new version.

All rules are run over this version in the order they are listed,
stsewd marked this conversation as resolved.
Show resolved Hide resolved
if the version matches the version type and the pattern in the rule,
stsewd marked this conversation as resolved.
Show resolved Hide resolved
an action is executed over that version.
stsewd marked this conversation as resolved.
Show resolved Hide resolved

.. note::

All actions of the rules that the version matches will be executed over that version.
stsewd marked this conversation as resolved.
Show resolved Hide resolved

Predefined matches
------------------

There are some predefined matches:
stsewd marked this conversation as resolved.
Show resolved Hide resolved

- **Any version**: All new versions will match.
stsewd marked this conversation as resolved.
Show resolved Hide resolved
- **SemVer versions**: All new versions that follow `semantic versioning <https://semver.org/>`__ will match.
stsewd marked this conversation as resolved.
Show resolved Hide resolved

User defined matches
--------------------

If none of the above predefined matches meet your use case,
choose **Custom match**.
stsewd marked this conversation as resolved.
Show resolved Hide resolved

The custom match should be a valid `Python regular expression <https://docs.python.org/3/library/re.html>`__.
Each new version will be tested against this regular expression.

Actions
-------

Actions are the task to be executed over the matching version.
stsewd marked this conversation as resolved.
Show resolved Hide resolved
Currently, this actions are available:
stsewd marked this conversation as resolved.
Show resolved Hide resolved

- **Activate version**: Activates and builds the version.
- **Set version as default**: Sets the version as default,
i.e. the version of your project that `/` redirects to.
See more in :ref:`automatic-redirects:Root URL`.
stsewd marked this conversation as resolved.
Show resolved Hide resolved
It also activates and builds the version.

.. note::

If your versions follow :pep:`440`,
Read the Docs activates and builds the version if it's greater than the current stable version,
stsewd marked this conversation as resolved.
Show resolved Hide resolved
and updates the stable version.
stsewd marked this conversation as resolved.
Show resolved Hide resolved
See more in :doc:`versions`.

Order
-----

The order your rules are listed in :guilabel:`Admin` > :guilabel:`Automation Rules` matters.
Each action will be executed in that order,
so first rules have a higher priority.
stsewd marked this conversation as resolved.
Show resolved Hide resolved

You can change the order using the up and down arrow buttons.

.. note::

New rules are added at the end (lower priority).

Examples
--------

Activate all new tags
~~~~~~~~~~~~~~~~~~~~~

- Match: ``Any version``
- Version type: ``Tag``
- Action: ``Activate version``

Activate only new branches that belong to the ``1.x`` release
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Custom match: ``^1\.\d+$``
- Version type: ``Branch``
- Action: ``Activate version``

Set as default new tags that have the ``-stable`` or ``-release`` suffix
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Custom match: ``-(stable)|(release)$``
stsewd marked this conversation as resolved.
Show resolved Hide resolved
- Version type: ``Tag``
- Action: ``Set version as default``

.. note::

You can also create two rules, one to match ``-stable`` and
other to match ``-release``.

Activate all new tags and branches that start with ``v`` or ``V``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Custom match: ``^[vV]``
- Version type: ``Tag``
- Action: ``Activate version``


- Custom match: ``^[vV]``
- Version type: ``Branch``
- Action: ``Activate version``

Activate all new tags that don't contain the ``-nightly`` suffix
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a very common case, we can add new actions like Activate versions that don't match

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or an option for the rule like Match or Not match

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this example from the docs for now. Looks pretty complex to me and I'm not sure how many cases there are where -nightly is a tag.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The section is supposed to have complex examples, more than the suffix, is to have an example of how apply a rule on not-match

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm suggesting #6354 to make this more easy


.. TODO: update example if https://github.com/readthedocs/readthedocs.org/issues/6354 is approved.


- Custom match: ``.*(?<!-nightly)$``
- Version type: ``Tag``
- Action: ``Activate version``
5 changes: 5 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ out of your documentation and Read the Docs.
:doc:`User defined redirects <user-defined-redirects>` |
:doc:`Automatic redirects <automatic-redirects>`

* **Versions**
:doc:`Automation rules <automation-rules>`

* **Topic specific guides**:
:doc:`How-to guides <guides/index>`

Expand All @@ -142,6 +145,8 @@ out of your documentation and Read the Docs.
user-defined-redirects
automatic-redirects

automation-rules

guides/index

api/index
Expand Down