forked from reanahub/reana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.py
184 lines (138 loc) · 5.64 KB
/
cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# -*- coding: utf-8 -*-
#
# This file is part of REANA.
# Copyright (C) 2018, 2019, 2020 CERN.
#
# REANA is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Helper scripts for REANA developers. Run `reana-dev --help` for help."""
import click
from reana.reana_dev.client import client_commands_list
from reana.reana_dev.cluster import cluster_commands_list
from reana.reana_dev.docker import docker_commands_list
from reana.reana_dev.git import git_commands_list
from reana.reana_dev.helm import helm_commands_list
from reana.reana_dev.kind import kind_commands_list
from reana.reana_dev.kubectl import kubectl_commands_list
from reana.reana_dev.python import python_commands_list
from reana.reana_dev.release import release_commands_list
from reana.reana_dev.run import run_commands_list
@click.group()
def reana_dev(): # noqa: D301
"""Run REANA development and integration commands.
How to prepare your environment:
.. code-block:: console
\b
$ # prepare directory that will hold sources
$ mkdir -p ~/project/reana/src
$ cd ~/project/reana/src
$ # create new virtual environment
$ virtualenv ~/.virtualenvs/reana
$ source ~/.virtualenvs/reana/bin/activate
$ # install reana-dev developer helper script
$ pip install git+git://github.com/reanahub/reana.git#egg=reana
$ # run ssh-agent locally to simplify GitHub interaction
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa
How to fork and clone all REANA repositories:
.. code-block:: console
\b
$ reana-dev git-fork -c ALL
$ eval "$(reana-dev git-fork -c ALL)"
$ reana-dev git-clone -c ALL -u tiborsimko
How to run CI tests:
.. code-block:: console
\b
$ # example (a): fast, CLI mode only, fast example
$ reana-dev cluster-delete
$ reana-dev run-ci -m /var/reana:/var/reana -c r-d-helloworld --exclude-components=r-ui,r-a-vomsproxy
--admin-email john.doe@example.org --admin-password mysecretpassword
$ # example (b): slow, CLI and Web modes, all examples
$ reana-dev cluster-delete
$ reana-dev run-ci --admin-email john.doe@example.org --admin-password mysecretpassword
How to create REANA cluster:
.. code-block:: console
\b
$ # example (a): simple cluster creation
$ reana-dev cluster-create
$ # example (b): mount sharing /var/reana with host
$ reana-dev cluster-create -m /var/reana:/var/reana
$ # example (c): mount sharing /var/reana with host and /cvmfs for jobs
$ reana-dev cluster-create -m /var/reana:/var/reana -j /cvmfs:/cvmfs
$ # example (d): debug mode with code sharing as well
$ reana-dev cluster-create -m /var/reana:/var/reana --mode debug
How to set up your shell environment variables:
.. code-block:: console
\b
$ eval $(reana-dev client-setup-environment)
How to run full REANA example using a given workflow engine:
.. code-block:: console
\b
$ reana-dev run-example -c reana-demo-root6-roofit -w serial
How to run Python unit tests in independent virtual environments:
.. code-block:: console
\b
$ reana-dev python-unit-tests -c r-server -c r-w-controller
$ reana-dev python-unit-tests -c CLUSTER
$ reana-dev python-unit-tests -c ALL
How to test one component pull request:
.. code-block:: console
\b
$ cd reana-workflow-controller
$ reana-dev git-checkout -b . 72 --fetch
$ reana-dev docker-build -c .
$ reana-dev kind-load-docker-image -c .
$ reana-dev kubectl-delete-pod -c .
How to test multiple component branches:
.. code-block:: console
\b
$ reana-dev git-checkout -b reana-server 72
$ reana-dev git-checkout -b reana-workflow-controller 98
$ reana-dev git-status
$ reana-dev docker-build
$ reana-dev kind-load-docker-image -c reana-server
$ reana-dev kubectl-delete-pod -c reana-server
$ reana-dev kind-load-docker-image -c reana-workflow-controller
$ reana-dev kubectl-delete-pod -c reana-workflow-controller
How to test multiple component branches with commits to shared modules:
.. code-block:: console
\b
$ reana-dev git-checkout -b reana-commons 72
$ reana-dev git-checkout -b reana-db 73
$ reana-dev git-checkout -b reana-workflow-controller 98
$ reana-dev git-checkout -b reana-server 112
$ reana-dev run-ci [using same old options]
How to release and push cluster component images:
.. code-block:: console
\b
$ reana-dev git-clean
$ reana-dev docker-build --no-cache
$ # we should now run one more test with non-cached ``latest``
$ # once it works, we can tag and push
$ reana-dev docker-build -t 0.3.0.dev20180625
$ reana-dev docker-push -t 0.3.0.dev20180625
$ # we should now publish stable helm charts for tag via chartpress
"""
pass
@click.command()
def version():
"""Show version."""
from reana.version import __version__
click.echo(__version__)
@click.command()
def help():
"""Display usage help tips and tricks."""
click.echo(cli.__doc__)
for cmd in (
client_commands_list
+ cluster_commands_list
+ docker_commands_list
+ kind_commands_list
+ kubectl_commands_list
+ git_commands_list
+ python_commands_list
+ run_commands_list
+ release_commands_list
+ helm_commands_list
):
reana_dev.add_command(cmd)