aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.rst65
-rwxr-xr-xplayground/server.sh2
-rw-r--r--schemas_json/server.yaml2
-rw-r--r--src_py/hatter/server.py9
4 files changed, 65 insertions, 13 deletions
diff --git a/README.rst b/README.rst
index 775b474..fd69ec3 100644
--- a/README.rst
+++ b/README.rst
@@ -10,7 +10,7 @@ Key features:
* automated projects based on git repositories
* containers as execution runners
* per project configuration as YAML file inside project's repository
- * web based control and monitoring interface
+ * web based control and monitoring interface (without JavaScript)
* webhook/periodic execution triggering
* CLI executor
@@ -23,20 +23,71 @@ Runtime requirements
* podman
+Install
+-------
+
+::
+
+ $ pip install hatter
+
+
Running
-------
+Hatter enables execution of actions described by simple YAML files which
+contain container image name and Posix shell execution script. Actions files
+are stored as part of git repositories (default name of action file is
+`.hatter.yaml`, stored in root of git working tree).
+
+These actions can be executed with::
+
+ $ hatter execute <path>
+
+where ``<path>`` is path to git repository containing action definition.
+Referenced git repository can be local or remote.
+
+Additionally, hatter can be run as daemon providing web server interface::
+
+ $ hatter server
+
+When run as server, hatter periodically lists configured git repository
+references, and schedules action executions if new commits are available.
+New commit checking can also be triggered by webhooks available at listening
+`/repo/<repo_name>/webhook` URL path (``<repo_name>`` is configured repository
+name).
+
+Hatter server provides basic web GUI which can be used for monitoring
+action executions and scheduling new executions based on user provided
+git reference.
+
+Action and server configurations are defined and documented by JSON schemas
+`schemas_json/action.yaml`_ and `schemas_json/server.yaml`_.
+
+For additional options, see::
+
+ $ hatter --help
+
+
+Configuration example
+---------------------
+
+* `.hatter.yaml`
-Server
-''''''
+ ::
+ image: alpine
+ command: |
+ echo "hello $WHO"
-CLI executor
-''''''''''''
+* `server.yaml`
+ ::
-Configuration
--------------
+ repos:
+ example:
+ url: path/to/example/repository
+ env:
+ WHO: world
Build
diff --git a/playground/server.sh b/playground/server.sh
index 7abe54e..567ff81 100755
--- a/playground/server.sh
+++ b/playground/server.sh
@@ -4,5 +4,5 @@
exec $PYTHON -m hatter server \
--conf $RUN_PATH/server.yaml \
- --db $DATA_PATH/hatter.db
+ --db $DATA_PATH/hatter.db \
"$@"
diff --git a/schemas_json/server.yaml b/schemas_json/server.yaml
index 2c65830..988f811 100644
--- a/schemas_json/server.yaml
+++ b/schemas_json/server.yaml
@@ -45,7 +45,7 @@ properties:
minimum time delay (in seconds) between
two consecutive remote ref synchronizations
(null disables synchronization limiting)
- default: 5
+ default: 60
max_sync_delay:
type:
- number
diff --git a/src_py/hatter/server.py b/src_py/hatter/server.py
index bce5880..5f00707 100644
--- a/src_py/hatter/server.py
+++ b/src_py/hatter/server.py
@@ -3,6 +3,7 @@ import collections
import contextlib
import itertools
import multiprocessing
+import os
import subprocess
import sys
import time
@@ -101,7 +102,7 @@ class Server(aio.Resource):
try:
url = repo_conf['url']
refs = repo_conf.get('refs', ['refs/heads/*'])
- min_sync_delay = repo_conf.get('min_sync_delay') or 0
+ min_sync_delay = repo_conf.get('min_sync_delay', 60) or 0
max_sync_delay = repo_conf.get('max_sync_delay')
last_sync = time.monotonic() - min_sync_delay
@@ -173,11 +174,11 @@ async def _execute(action, env, url, ref):
*itertools.chain.from_iterable(('--env', i) for i in env),
url, ref]
- p = await asyncio.create_subprocess_exec(cmd,
+ p = await asyncio.create_subprocess_exec(*cmd,
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
- env=env)
+ env={**os.environ, **env})
try:
output, _ = await p.communicate()
@@ -196,7 +197,7 @@ async def _execute(action, env, url, ref):
async def _git_ls_remote(url, refs):
cmd = ['git', 'ls-remote', url, *refs]
- p = await asyncio.create_subprocess_exec(cmd,
+ p = await asyncio.create_subprocess_exec(*cmd,
stdin=subprocess.DEVNULL,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)