From 93a9750906fdd0a4534be34fdfc6d6f17d29d7a2 Mon Sep 17 00:00:00 2001
From: Soeren Peters <peters@irmb.tu-bs.de>
Date: Mon, 26 Oct 2020 15:03:52 +0100
Subject: [PATCH] Add cppcheck depoy job.

---
 .gitlab-ci.yml                | 16 ++++++++++++++++
 ansible/hosts.cfg             |  2 ++
 ansible/playbook.yml          |  3 ---
 ansible/playbook_cppcheck.yml | 10 ++++++++++
 4 files changed, 28 insertions(+), 3 deletions(-)
 create mode 100644 ansible/playbook_cppcheck.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index bbb0c2240..210e1092d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -188,3 +188,19 @@ cppcheck:
       - html_report/
 
 
+deploy_cppcheck_to_elladan:
+  stage: deploy
+  needs: ["cppcheck"]
+
+  before_script:
+    - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
+    - apt-get install -y rsync
+    - mkdir -p ~/.ssh
+    - chmod 700 ~/.ssh
+    - eval $(ssh-agent -s)
+    - echo "SSH_PRIVATE_KEY_ELLADAN" | tr -d '\r' | ssh-add -
+    - ssh-keyscan -t rsa elladan.irmb.bau.tu-bs.de >> ~/.ssh/known_hosts
+    - pip3 install ansible
+
+  script:
+    - ansible-playbook -i ansible/hosts.cfg -u public_pages ansible/playbook_cppcheck.yml
diff --git a/ansible/hosts.cfg b/ansible/hosts.cfg
index 9c6d00b05..791cf36df 100644
--- a/ansible/hosts.cfg
+++ b/ansible/hosts.cfg
@@ -2,3 +2,5 @@
 host_key_checking=False
 [gitlab_ci_deploy_targets]
 phoenix.hlr.rz.tu-bs.de ansible_ssh_private_key_file=./private_key
+[gitlab_ci_deploy_cppcheck]
+elladan.irmb.bau.tu-bs.de
diff --git a/ansible/playbook.yml b/ansible/playbook.yml
index 2653089c7..4f0633a95 100644
--- a/ansible/playbook.yml
+++ b/ansible/playbook.yml
@@ -25,6 +25,3 @@
         - { src: '../gpu.cmake', dest: '~/VirtualFluids_dev/gpu.cmake' }
         - { src: '../pyproject.toml', dest: '~/VirtualFluids_dev/pyproject.toml' }
         - { src: '../setup.py', dest: '~/VirtualFluids_dev/setup.py' }
-
-
-
diff --git a/ansible/playbook_cppcheck.yml b/ansible/playbook_cppcheck.yml
new file mode 100644
index 000000000..b33d71ba8
--- /dev/null
+++ b/ansible/playbook_cppcheck.yml
@@ -0,0 +1,10 @@
+- hosts: gitlab_ci_deploy_cppcheck
+  tasks:
+    - name: Create remote cppcheck dir
+      command: mkdir ~/cppcheck
+      ignore_errors: yes
+
+    - name: Synchronize cppcheck with remote
+      synchronize:
+        src: "../html_report"
+        dest: "~/cppcheck/html_report"
-- 
GitLab