Skip to content

Commit 5e82a34

Browse files
committed
Handle google_health's testing needs
- Add: Ansible playbook for securely handling placing the `params.json` template we need for testing. This will happen during the Jenkins build stage when we are setting up the venv in the workspace on the Jenkins server. - Add: Test `params.json` template. - Add: Jenkins user variable. - Fix: Was incorrectly trying to use a file instead of a template in `ansible-deploy.yaml`. - Add: Call the small Ansible playbook from the Jenkins build wrapper.
1 parent f78eae5 commit 5e82a34

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

ansible/ansible-deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
when: file.stat.exists
3737

3838
- name: Set production params template.
39-
copy:
39+
template:
4040
src: templates/{{ indicator }}-params-prod.json.j2
4141
dest: "{{ indicators_runtime_dir }}/{{ indicator }}/params.json"
4242
owner: "{{ runtime_user }}"

ansible/google_health-build.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
- hosts: localhost
3+
vars_files:
4+
- vars.yaml
5+
- vault.yaml
6+
tasks:
7+
- name: Set test params template.
8+
template:
9+
src: templates/{{ indicator }}-params-test.json.j2
10+
dest: "{{ workspace }}/{{ indicator }}/tests/params.json"
11+
owner: "{{ jenkins_user }}"
12+
group: "{{ jenkins_user }}"
13+
mode: "0644"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"static_file_dir": "../static",
3+
"export_dir": "./receiving",
4+
"cache_dir": "../cache",
5+
"start_date": "2020-02-11",
6+
"end_date": "2020-04-30",
7+
"ght_key": "{{ google_health_api_key }}"
8+
}

ansible/vars.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
22
runtime_user: "indicators"
3+
jenkins_user: "jenkins"
34
jenkins_artifact_dir: "/var/lib/jenkins/artifacts"
45
indicators_runtime_dir: "/home/{{ runtime_user }}/runtime"
5-
package: "{{ indicator }}.tar.gz" # This is passed in the Ansible invocation.
6+
package: "{{ indicator }}.tar.gz" # {{ indicator }} is passed in from the Jenkins shell script wrapper.
67
python_version: "3.8.2"
78
pyenv_python_path: "/home/{{ runtime_user }}/.pyenv/versions/{{ python_version }}/bin/python"
89

jenkins/google_health-jenkins-build.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ python -m venv env
1919
source env/bin/activate
2020
pip install ../_delphi_utils_python/.
2121
pip install .
22+
23+
# Ansible!
24+
# We need to call some extra Ansible here to handle placing a special params.json
25+
# template so that our tests can complete. The below calls a small playbook that
26+
# runs locally on the build (Jenkins) server to place the file.
27+
ansible-playbook google_health-build.yaml \
28+
--extra-vars "indicator=${local_indicator} workspace=${WORKSPACE}" -i localhost,

0 commit comments

Comments
 (0)