frank.rst 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. Frank can be configured using the following yaml::
  2. .frank.yml
  3. commads:
  4. - test
  5. - deploy
  6. - publish
  7. newtag:
  8. - python:
  9. - frank.actions:detect_new_tag
  10. deploy:
  11. - cmd
  12. - runif
  13. - test
  14. - newtag
  15. publish:
  16. - shell:
  17. - cd docs; make html
  18. - python:
  19. - frank.actions:recursive_copy
  20. The sections commands is a simple list of command you would
  21. like to define.
  22. This section is optional. It's main purpose is for you to decalre
  23. which commands frank should execute upon recieving a load.
  24. Each command is a dictionary with the following possible keys::
  25. cmd_name:
  26. - cmd # not mandatory if you include it in the list of commands
  27. - runif # a conditional to determine whether to run or skip the command
  28. # it can contain multiple directives which can be python
  29. # code to execute
  30. # or shell code
  31. For example, let's say you would like to build the sphinx documentation
  32. of your project after every push. You start by defining a command
  33. build_docs in the following way::
  34. build_docs:
  35. - cmd
  36. - shell:
  37. - cd docs
  38. - make html
  39. You could also specify::
  40. build_docs:
  41. - cmd
  42. - shell: cd docs; make html
  43. or::
  44. build_docs:
  45. - shell:
  46. - cwd: docs
  47. - cmd: make html
  48. This tells that `build_docs` is a command that executes after every push.
  49. It will execute a shell and will run the shell commands
  50. `cd docs; make html`. Pretty straight forward!
  51. Now, let's refine. Suppose we want to build the docs only if the docs changed,
  52. thus ignoring completely, changes in the embeded docs strings*::
  53. build_docs:
  54. - cmd
  55. - runif:
  56. - shell:
  57. - git --no-pager diff --name-status HEAD~1 | grep -v docs
  58. - shell: cd docs; make html
  59. Now, the command will run if the latest git commit have changed the docs
  60. directory. Since the grep command will return exit with 1.
  61. Alternatively, the conditional to run can be some python code that returns
  62. True or False. Here is how to specify this:
  63. build_docs:
  64. - cmd
  65. - runif:
  66. - python: frank.githubparsers:detect_changes_in_docs
  67. - shell: cd docs; make html
  68. This, will invoke the method ``detect_changes_in_docs`` which is
  69. found in the module `frank.githubparsers`.
  70. If this function will return True the shell command will execute.
  71. If the methods takes some arguments, they could also be given.
  72. Suppose the function is called `detect_changes_in` and this function
  73. takes a single paramter called path we can configure the
  74. build_docs command in the following way::
  75. build_docs:
  76. - cmd
  77. - runif:
  78. - python:
  79. - function: frank.githubparsers:detect_changes_in
  80. - args:
  81. - path: docs
  82. note::
  83. This is probably a lame idea, but it's good for demonstration.
  84. So, do write doc-strings, and do build your docs often.