Skip to content

Finalize production config for google_health deployment #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ansible/ansible-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
when: file.stat.exists

- name: Set production params template.
copy:
template:
src: templates/{{ indicator }}-params-prod.json.j2
dest: "{{ indicators_runtime_dir }}/{{ indicator }}/params.json"
owner: "{{ runtime_user }}"
Expand Down
15 changes: 15 additions & 0 deletions ansible/google_health-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
- hosts: localhost
connection: local
vars_files:
- vars.yaml
- vault.yaml
tasks:
- name: Set test params template.
template:
src: templates/{{ indicator }}-params-test.json.j2
dest: "{{ workspace }}/{{ indicator }}/tests/params.json"
owner: "{{ jenkins_user }}"
group: "{{ jenkins_user }}"
mode: "0644"
delegate_to: localhost
2 changes: 1 addition & 1 deletion ansible/templates/google_health-params-prod.json.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"static_file_dir": "./static",
"export_dir": "./receiving",
"export_dir": "/common/covidcast/receiving/ght",
"cache_dir": "./cache",
"start_date": "2020-02-01",
"end_date": "",
Expand Down
8 changes: 8 additions & 0 deletions ansible/templates/google_health-params-test.json.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"static_file_dir": "../static",
"export_dir": "./receiving",
"cache_dir": "../cache",
"start_date": "2020-02-11",
"end_date": "2020-04-30",
"ght_key": "{{ google_health_api_key }}"
}
3 changes: 2 additions & 1 deletion ansible/vars.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
---
runtime_user: "indicators"
jenkins_user: "jenkins"
jenkins_artifact_dir: "/var/lib/jenkins/artifacts"
indicators_runtime_dir: "/home/{{ runtime_user }}/runtime"
package: "{{ indicator }}.tar.gz" # This is passed in the Ansible invocation.
package: "{{ indicator }}.tar.gz" # {{ indicator }} is passed in from the Jenkins shell script wrapper.
python_version: "3.8.2"
pyenv_python_path: "/home/{{ runtime_user }}/.pyenv/versions/{{ python_version }}/bin/python"

Expand Down
4 changes: 2 additions & 2 deletions google_health/tests/test_pull_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_class_state(self):
]

assert len(res["lines"][0]["points"]) == 2
assert [x for x in res["lines"][0]["points"][0].keys()] == ["date", "value"]
assert set([x for x in res["lines"][0]["points"][0].keys()]) == ["date", "value"]
assert res["lines"][0]["points"][0]["date"] == "May 05 2020"
assert res["lines"][0]["points"][1]["date"] == "May 06 2020"

Expand All @@ -55,7 +55,7 @@ def test_class_dma(self):
]

assert len(res["lines"][0]["points"]) == 2
assert [x for x in res["lines"][0]["points"][0].keys()] == ["date", "value"]
assert set([x for x in res["lines"][0]["points"][0].keys()]) == ["date", "value"]
assert res["lines"][0]["points"][0]["date"] == "May 05 2020"
assert res["lines"][0]["points"][1]["date"] == "May 06 2020"

Expand Down
21 changes: 0 additions & 21 deletions jenkins/google_health-jenkins-build copy.sh

This file was deleted.

31 changes: 31 additions & 0 deletions jenkins/google_health-jenkins-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
#
# JHU: Jenkins build
#

set -eo pipefail
source ~/.bash_profile

#
# Build
#

local_indicator="google_health"

cd "${WORKSPACE}/${local_indicator}" || exit

# Set up venv
python -m venv env
source env/bin/activate
pip install ../_delphi_utils_python/.
pip install .

# Ansible!
# We need to call some extra Ansible here to handle placing a special params.json
# template so that our tests can complete. The below calls a small playbook that
# runs locally on the build (Jenkins) server to place the file.

cd "${WORKSPACE}/ansible" || exit

ansible-playbook google_health-build.yaml \
--extra-vars "indicator=${local_indicator} workspace=${WORKSPACE}" -i localhost,
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Jenkins deploy
#

set -exo pipefail
set -eo pipefail
source ~/.bash_profile

#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Jenkins package
#

set -exo pipefail
set -eo pipefail
source ~/.bash_profile

#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# JHU: Jenkins test
#

set -exo pipefail
set -eo pipefail
source ~/.bash_profile

#
Expand Down