]> git.immae.eu Git - github/fretlink/ansible-clever.git/commitdiff
vars: fix `clever_base_env` by removing a variable if not necessary 60/head
authorPaul Bonaud <paul.bonaud@fretlink.com>
Tue, 24 Mar 2020 09:18:14 +0000 (10:18 +0100)
committerPaul Bonaud <paul.bonaud@fretlink.com>
Tue, 24 Mar 2020 15:09:45 +0000 (16:09 +0100)
The `CC_RUN_COMMAND` variable was defined in case we use haskell
binary as entrypoints. However if the `clever_haskell_entry_point`
variable is not defined we shouldn't define the `CC_RUN_COMMAND` env variable.

.travis.yml
defaults/main.yml
templates/env.j2
tests/fake.sh [new file with mode: 0755]
tests/inventory
tests/test.yml
vars/main.yml

index 22e80b39f6a3aacc7fdcad65f44e6cb3efadd89f..0fcb053b7525ef5d95b87a846864e62476489760 100644 (file)
@@ -24,6 +24,12 @@ script:
   - ansible-lint .
   - shellcheck **/*.sh
   - scripts/dhall_check.sh
+  # Run integration test
+  - mkdir -p ~/.local/bin
+  - cp tests/fake.sh ~/.local/bin/clever
+  - cp tests/fake.sh ~/.local/bin/git
+  - ansible-playbook tests/test.yml -i tests/inventory
 
 notifications:
   slack: fretlink:pTIylIN7zkwRFuL3aHERmsbB
+  webhooks: https://galaxy.ansible.com/api/v1/notifications/
index d4aa86d9477ea71afcfd1383004edcc93ffc28ed..0e4bada24411ba3ad23dd55f02ac481ad0974f08 100644 (file)
@@ -1,12 +1,12 @@
 ---
 # defaults file for clever
-clever_cli_version: 1.4.2
+clever_cli_version: 1.6.3
 clever_user_path: .local/bin
 clever_app_root: "{{ app_root | default(playbook_dir + '/..') }}"
 clever_app_confdir: "{{ clever_app_root }}/.clever_cloud"
 clever_login_file: "{{ clever_app_confdir }}/login"
 
-clever_haskell_entry_point: "{{ clever_entry_point | default('') }}"
+clever_haskell_entry_point: "{{ clever_entry_point | default(None) }}"
 clever_env: {}
 
 clever_disable_metrics: false
index d2bf44643411c1375b280ef5238192277b1aa383..66e550897af090ad3c8307c21675020734522f8e 100644 (file)
@@ -1,3 +1,9 @@
 {% for key, value in (clever_base_env | combine(clever_env)).items() %}
-{{ key }}="{{ value | tojson }}"
+{{ key }}="{{ value | to_json }}"
 {% endfor %}
+
+{%- if clever_haskell_entry_point %}
+{# Haskell only #}
+{# https://www.clever-cloud.com/doc/get-help/reference-environment-variables/#haskell #}
+CC_RUN_COMMAND="{{'~/.local/bin/' + clever_haskell_entry_point | to_json }}"
+{% endif %}
diff --git a/tests/fake.sh b/tests/fake.sh
new file mode 100755 (executable)
index 0000000..2835e85
--- /dev/null
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+binary="${0/*\/}"
+fakeCommit="aaa000aaa000aaa000aaa000aaa000aaa000aaa0"
+
+if [ "${binary}" = "clever" ] && [ "${1}" = "--version" ]; then
+    echo "1.6.3"
+elif [ "${binary}" = "clever" ] && [ "${1}" = "activity" ]; then
+    echo "2020-02-02T20:20:02+02:00  OK         DEPLOY     ${fakeCommit}  Git"
+elif [ "${binary}" = "git" ]; then
+    echo "${fakeCommit}"
+else
+    echo "${binary} called with arguments: ${*}"
+fi
index 878877b0776c44f55fc4e458f70840f31da5bb01..49d4fe2b5512af203cb13f051d20bf17a7c911ac 100644 (file)
@@ -1,2 +1,2 @@
-localhost
+localhost ansible_connection=local
 
index 3e3c57ff350ecb5a0313183995e09670880c3bb8..663bc6bc385d564bcf50dc3eda1ad0d6f6422ba0 100644 (file)
@@ -2,4 +2,8 @@
 - hosts: localhost
   remote_user: root
   roles:
-    - clever
\ No newline at end of file
+    - role: clever
+      vars:
+        clever_token: 123abc
+        clever_secret: cba321
+        clever_app: app_00000000-0000-0000-0000-000000000000
index 94ee792657d6565164ecfb5925c42347bc1c3d8f..a9625f01f6f6100022f7884918286c0186e67284 100644 (file)
@@ -2,9 +2,6 @@
 # vars file for clever
 clever_base_env:
   CACHE_DEPENDENCIES: "true"
-  # Haskell only
-  # https://www.clever-cloud.com/doc/get-help/reference-environment-variables/#haskell
-  CC_RUN_COMMAND:     "~/.local/bin/{{ clever_haskell_entry_point }}"
   CC_DISABLE_METRICS: "{{ clever_disable_metrics | lower }}"
   PORT:               "8080"