mozharness: actions
Oct. 12th, 2011 12:10 am![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
that allows production infrastructure and individual developers to use the same scripts.
What are actions?
Actions are discrete logical steps to a script, similar to [simple] makefile targets.
Since certain actions, like upload
or notify
might not be useful to certain consumers of a script, it's helpful to be able to turn those off.
Versatile, reusable configs are key to sharing scripts between automation and users with different workflows. Actions are another key ingredient.
What are default actions?
default_actions
is a subset of all_actions
, and specifies the list of actions to run if no action-specific command line options are specified.
Using the configtest.py
script as an example:
deathduck:~/src/clean/mozharness [19:09:59] (default) 621$ scripts/configtest.py --list-actions Actions available: list-config-files, test-json-configs, test-python-configs Default actions: test-json-configs, test-python-configs
These are specified here.
It's now possible to specify your own default_actions
in your config file, so if you want to run a script with a different set of default actions, you can do so without copy/pasting a ton of command line arguments.
How is the list of actions-to-run generated?
I have that documented here.
Using configtest.py
as an example again:
# Only run the list-config-files action configtest.py --list-config-files # Run the list-config-files and test-json-configs actions configtest.py --list-config-files --test-json-configs # or configtest.py --action list-config-files,test-json-configs # or configtest.py --action list-config-files --action test-json-configs # Run list-config-files in addition to the default actions configtest.py --add-action list-config-files # Run the default actions, but not test-python-configs configtest.py --no-test-python-configs
How are the actions run in the script?
That's handled by BaseScript.run():
- Change all dashes in the action name to underscores; that's the method to call
- If the action is not in the list of actions to run, skip + go to the next action.
-
if
preflight_METHODNAME
exists, run that before runningMETHODNAME
. -
Call
METHODNAME
. -
If
postflight_METHODNAME
exists, run that after runningMETHODNAME
.