Browse Source

[+Jordi] setup new directory for petition scripts

Albert Hilazo 1 year ago
parent
commit
85035a2b39

+ 5 - 1
.gitignore

@@ -5,4 +5,8 @@ node_modules
5 5
 .idea
6 6
 *.iml
7 7
 .*.env
8
-
8
+venv/
9
+*.pyc
10
+target/
11
+.pytest_cache/
12
+__pycache__/

+ 0 - 0
apps/petitions/scripts/close.py


+ 6 - 0
apps/petitions/scripts/close_test.py

@@ -0,0 +1,6 @@
1
+import unittest
2
+
3
+
4
+class CloseTestCase(unittest.TestCase):
5
+    def test_dummy(self):
6
+        self.assertEqual(1, 1)

+ 52 - 0
apps/petitions/scripts/go.sh

@@ -0,0 +1,52 @@
1
+#!/bin/bash
2
+
3
+
4
+function setup_python_env() {
5
+    echo "Creating python virtual env in this project folder"
6
+    virtualenv -p $(which python2.7) venv
7
+    echo "Activating virtual env"
8
+    . venv/bin/activate
9
+    echo "Installing the app dependencies"
10
+    pip install -r requirements.txt
11
+}
12
+
13
+function unit_tests() {
14
+  . venv/bin/activate
15
+  PYTHONPATH=. py.test
16
+}
17
+
18
+function unit_tests_watch() {
19
+  . venv/bin/activate
20
+  PYTHONPATH=. ptw
21
+}
22
+
23
+function lint() {
24
+  . venv/bin/activate
25
+  pycodestyle --exclude='venv/*' --ignore=E501 .
26
+}
27
+
28
+function usage() {
29
+    echo "Some commands:"
30
+    echo "init       : creates virtual environment with installed dependencies"
31
+    echo "test       : runs unit tests"
32
+    echo "test-watch : runs unit tests for every change"
33
+    echo "lint       : check PEP-8 style guide"
34
+}
35
+
36
+OPTION="$1"
37
+  case $OPTION in
38
+    init)
39
+      setup_python_env
40
+      ;;
41
+    test)
42
+      unit_tests
43
+      ;;
44
+    test-watch)
45
+      unit_tests_watch
46
+      ;;
47
+    lint)
48
+      lint
49
+      ;;
50
+    *)
51
+      usage
52
+  esac

+ 69 - 0
apps/petitions/scripts/petition-scripts.gopipeline.json

@@ -0,0 +1,69 @@
1
+{
2
+  "name": "Petition-Scripts",
3
+  "environment_variables": [],
4
+  "group" : "ScaleModel",
5
+  "materials": [
6
+    {
7
+      "url": "https://gogs.dyne.org/DECODE/decode-prototype.git",
8
+      "type": "git",
9
+      "filter": {
10
+        "whitelist": [
11
+          "apps/petitions/scripts/**/*"
12
+        ]
13
+      }
14
+    }
15
+  ],
16
+  "stages": [
17
+    {
18
+      "name": "unit-test",
19
+      "fetch_materials": true,
20
+      "never_cleanup_artifacts": false,
21
+      "clean_working_directory": true,
22
+      "environment_variables": [],
23
+      "jobs": [
24
+        {
25
+          "name": "unit-test",
26
+          "environment_variables": [],
27
+          "tabs": [],
28
+          "resources": ["python"],
29
+          "artifacts": [],
30
+          "properties": [],
31
+          "run_instance_count": null,
32
+          "timeout": 0,
33
+          "tasks": [
34
+            {
35
+              "type": "exec",
36
+              "run_if": "passed",
37
+              "on_cancel" : null,
38
+              "command": "./go.sh",
39
+              "arguments": [
40
+                "init"
41
+              ],
42
+              "working_directory": "apps/petitions/scripts"
43
+            },
44
+            {
45
+              "type": "exec",
46
+              "run_if": "passed",
47
+              "on_cancel" : null,
48
+              "command": "./go.sh",
49
+              "arguments": [
50
+                "lint"
51
+              ],
52
+              "working_directory": "apps/petitions/scripts"
53
+            },
54
+            {
55
+              "type": "exec",
56
+              "run_if": "passed",
57
+              "on_cancel" : null,
58
+              "command": "./go.sh",
59
+              "arguments": [
60
+                "test"
61
+              ],
62
+              "working_directory": "apps/petitions/scripts"
63
+            }
64
+          ]
65
+        }
66
+      ]
67
+    }
68
+  ]
69
+}

+ 15 - 0
apps/petitions/scripts/requirements.txt

@@ -0,0 +1,15 @@
1
+argh==0.26.2
2
+attrs==18.1.0
3
+colorama==0.3.9
4
+docopt==0.6.2
5
+funcsigs==1.0.2
6
+more-itertools==4.1.0
7
+pathtools==0.1.2
8
+pluggy==0.6.0
9
+py==1.5.3
10
+pycodestyle==2.4.0
11
+pytest==3.5.1
12
+pytest-watch==4.1.0
13
+PyYAML==3.12
14
+six==1.11.0
15
+watchdog==0.8.3

+ 3 - 0
apps/wallet-proxy/go.sh

@@ -108,6 +108,9 @@ function usage() {
108 108
     echo "ssh prod     : start an ssh session on prod box"
109 109
     echo "open         : open the root in a browser"
110 110
     echo "health-check : makes a curl to the healthcheck and shows you the response"
111
+    echo "test       : runs unit tests"
112
+    echo "test-watch : runs unit tests for every change"
113
+    echo "lint       : check PEP-8 style guide"
111 114
 }
112 115
 
113 116
 OPTION="$1"