Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
241 commits
Select commit Hold shift + click to select a range
685348e
revert 7day smooth to wip_
huisaddison Jun 2, 2020
18f1070
Jenkins test #1
korlaxxalrok Jun 5, 2020
daf9fb1
Jenkins test #2
korlaxxalrok Jun 5, 2020
2879c5e
Add Jenkins build directory
korlaxxalrok Jun 5, 2020
bd527de
Update test files
korlaxxalrok Jun 5, 2020
f3566b1
Add new test files
korlaxxalrok Jun 5, 2020
25f1abb
Update test script
korlaxxalrok Jun 5, 2020
0ec90f5
Fix path
korlaxxalrok Jun 5, 2020
0348363
Fix path
korlaxxalrok Jun 5, 2020
6dae5f6
py not python, come on
korlaxxalrok Jun 5, 2020
377abc3
Start in jhu dir
korlaxxalrok Jun 5, 2020
97a8c75
KISS: Compact tests into single shell script
korlaxxalrok Jun 5, 2020
691b6dd
Add Jenkins pipeline file
korlaxxalrok Jun 6, 2020
1f28084
Add post section
korlaxxalrok Jun 7, 2020
5c34c34
Jenkins test
korlaxxalrok Jun 7, 2020
c0dd7eb
Jenkins test
korlaxxalrok Jun 7, 2020
30c8cb5
Test Slack messaging
korlaxxalrok Jun 7, 2020
9bd5bca
Fix syntax
korlaxxalrok Jun 7, 2020
1ef8f3f
Test syntax
korlaxxalrok Jun 7, 2020
305921c
Test syntax
korlaxxalrok Jun 7, 2020
ccddf8f
Test syntax
korlaxxalrok Jun 7, 2020
dca8efd
Test syntax
korlaxxalrok Jun 7, 2020
1f51e80
Testing Slack notifications
korlaxxalrok Jun 7, 2020
c2abfd6
Testing Slack notifications
korlaxxalrok Jun 7, 2020
c989bbd
Can we send a message pre-stages?
korlaxxalrok Jun 7, 2020
115e875
Revert
korlaxxalrok Jun 7, 2020
44febee
update code for unassigned cases/deaths
Jun 8, 2020
fc05296
Test messaging
korlaxxalrok Jun 8, 2020
932b699
Test messaging
korlaxxalrok Jun 8, 2020
9656082
Test messaging
korlaxxalrok Jun 8, 2020
9f4d197
Test messaging
korlaxxalrok Jun 8, 2020
d71b374
Test messaging
korlaxxalrok Jun 8, 2020
00e6ac8
Test messaging
korlaxxalrok Jun 8, 2020
a2bd470
Test messaging
korlaxxalrok Jun 8, 2020
849a32e
update the dict for fake fips
Jun 8, 2020
f1f5cdd
Set population for fake fips as NAN
Jun 8, 2020
84bbfc6
update geo_id for megacounty
Jun 8, 2020
339eac5
update cache
Jun 9, 2020
c7cf8d7
Test new Slack notifications based on shared lib usage
korlaxxalrok Jun 9, 2020
4e22a27
Fix indent
korlaxxalrok Jun 9, 2020
8e8f72e
Fix spacing
korlaxxalrok Jun 9, 2020
94b9403
Update name of shard library to import
korlaxxalrok Jun 9, 2020
300df75
Fix reference syntax
korlaxxalrok Jun 9, 2020
23baf4c
Flail about semi-wildly
korlaxxalrok Jun 9, 2020
f745c46
Try passing single parameter
korlaxxalrok Jun 9, 2020
c0a5331
Try quoting params
korlaxxalrok Jun 9, 2020
912daef
Test new parameter
korlaxxalrok Jun 9, 2020
71a6097
Revert parameter
korlaxxalrok Jun 9, 2020
8c538e3
Cut 7-day avg signal name
Jun 9, 2020
e2d8254
Cut 7-day avg signal name
Jun 9, 2020
d417598
Test
korlaxxalrok Jun 9, 2020
c430020
Test
korlaxxalrok Jun 9, 2020
9d0ac0e
Try wrapping in a script block
korlaxxalrok Jun 9, 2020
65bd484
Add branch specifiers for stages, bit of clean up
korlaxxalrok Jun 9, 2020
f5696bd
Fix brackets, add safer variable syntax for Bash scripts
korlaxxalrok Jun 9, 2020
6de390c
Test when conditional
korlaxxalrok Jun 9, 2020
33b9352
Fix steps
korlaxxalrok Jun 9, 2020
c5d020c
Fix script permissions
korlaxxalrok Jun 9, 2020
030d38a
update naming for megacounty
Jun 10, 2020
f66b43e
modify test cases for megacounty aggregation
Jun 10, 2020
49be65d
delete whitespace
Jun 10, 2020
7ee404c
delete whitespace
Jun 10, 2020
4bd3035
Comment out
korlaxxalrok Jun 10, 2020
141ffb3
Change script execution syntax
korlaxxalrok Jun 10, 2020
a206fdb
Run scripts explicitly with bash
korlaxxalrok Jun 10, 2020
7968536
Revert to sh
korlaxxalrok Jun 10, 2020
d789dae
Revert to sh (properly)
korlaxxalrok Jun 10, 2020
9f28492
Source bash profile at beginning of script
korlaxxalrok Jun 10, 2020
d259dc3
Add unit tests and code coverage check
korlaxxalrok Jun 10, 2020
8c6cd17
Add master branch to build and test stages
korlaxxalrok Jun 10, 2020
545fd4f
Test deployment stage
korlaxxalrok Jun 10, 2020
8767d44
Test env variables output
korlaxxalrok Jun 10, 2020
d264753
Test env variables output
korlaxxalrok Jun 10, 2020
e51fcb0
Add error handling, some formatting changes
korlaxxalrok Jun 10, 2020
c48ea0c
Don't fail bash on unset variables
korlaxxalrok Jun 10, 2020
82ba3d6
Add Ansible skeleton, add package script
korlaxxalrok Jun 10, 2020
7457d8c
Update location to store package
korlaxxalrok Jun 10, 2020
13ec45e
Add executable permission
korlaxxalrok Jun 10, 2020
4570fdd
Change directory for package
korlaxxalrok Jun 10, 2020
82a0bde
Revert to original location
korlaxxalrok Jun 10, 2020
e3951b1
Use a custom artifact location
korlaxxalrok Jun 10, 2020
1989f1a
Fix bad variable
korlaxxalrok Jun 10, 2020
25162d0
Update jhu/tests/test_geo.py
jingjtang Jun 11, 2020
0dae169
Update jhu/tests/test_geo.py
jingjtang Jun 11, 2020
64790fb
Update jhu/tests/test_geo.py
jingjtang Jun 11, 2020
00357ec
Add some Ansible bits, rename some other bits
korlaxxalrok Jun 11, 2020
435f63d
disable 7dav_ signals temporarily
Jun 11, 2020
d187ebc
disable 7dav_ signal
Jun 11, 2020
131b88b
cut 7day avg signal name
Jun 11, 2020
003ac0c
delete df_mega for msa and hrr
Jun 11, 2020
b911d8d
revert test cases for msa and hrr
Jun 11, 2020
99c3860
resolve conflicts
Jun 11, 2020
eabe624
resolve conflicts
Jun 11, 2020
b67269b
re-activate 7dav_ signal
Jun 11, 2020
a93fc9e
Update ansible deploy, vars, and shell script deploy
korlaxxalrok Jun 11, 2020
34d28ce
Try putting in /tmp first
korlaxxalrok Jun 11, 2020
7740e8b
Fix path
korlaxxalrok Jun 11, 2020
5f25016
Well, that won't actually make Ansible do anything
korlaxxalrok Jun 11, 2020
b9680d7
Remove runtime host from vars, add inventory file
korlaxxalrok Jun 11, 2020
63c3e0e
Reference new inventory file
korlaxxalrok Jun 11, 2020
02c3bae
Update destination dir variable name
korlaxxalrok Jun 11, 2020
f7cb1f1
Make our intent clearer
korlaxxalrok Jun 11, 2020
f5d07bd
Specify remote user in Ansible config
korlaxxalrok Jun 12, 2020
2f21fc1
Fix variable name
korlaxxalrok Jun 12, 2020
50f9e95
change naming for wip signal
Jun 12, 2020
ba3e416
Fix package path
korlaxxalrok Jun 12, 2020
22c5850
Update variable names
korlaxxalrok Jun 12, 2020
77b0dd6
Mostly cosmetic changes
korlaxxalrok Jun 12, 2020
cf85ec4
Add variable comment, add nascent thought
korlaxxalrok Jun 12, 2020
9c094a9
Add branch pattern match, variable and bashiness to determine which s…
korlaxxalrok Jun 12, 2020
b4939c1
Try a groovy way to extract the indicator name from the branch name
korlaxxalrok Jun 12, 2020
17bc0df
Oops, missed one
korlaxxalrok Jun 12, 2020
520bcdc
Try string replacement
korlaxxalrok Jun 12, 2020
1993baa
Try a different string replacement method
korlaxxalrok Jun 12, 2020
977ab4d
Fix function name
korlaxxalrok Jun 12, 2020
aae321b
Properly reference environment variable
korlaxxalrok Jun 12, 2020
6189f63
Pass indicator from shell script as extra-vars in Ansible invocation
korlaxxalrok Jun 12, 2020
3de2e5e
Remove var reference
korlaxxalrok Jun 12, 2020
1a33eb6
Quote as string
korlaxxalrok Jun 12, 2020
69e0ec7
Remove mode as it is a documentation error
korlaxxalrok Jun 12, 2020
73aaff4
Add mutation step for venv python bin symlink, other small necessities
korlaxxalrok Jun 12, 2020
ac7524f
Fix src and dest
korlaxxalrok Jun 12, 2020
0c26ee1
Update runtime dir, add useful comment
korlaxxalrok Jun 12, 2020
79393fb
Test placing prod config file
korlaxxalrok Jun 12, 2020
a77ea7b
Fix prod filename
korlaxxalrok Jun 12, 2020
e77a523
Rename Ansible deploy file, add comment
korlaxxalrok Jun 12, 2020
4ad7651
Try to use indicator env variable from pipeline
korlaxxalrok Jun 14, 2020
ce7d55b
Add prod params file
korlaxxalrok Jun 14, 2020
121c646
Add variables to playbook, test a couple of things
korlaxxalrok Jun 14, 2020
519cf7a
Test writing to /tmp
korlaxxalrok Jun 14, 2020
9fd1f16
Rename files to be more generic, add local naming to variables used i…
korlaxxalrok Jun 14, 2020
1fd1283
Switch to indicators for ssh user
korlaxxalrok Jun 14, 2020
abc41a7
Don't become powerful to run this playbook
korlaxxalrok Jun 14, 2020
777b215
Only run against our runtime host from the inventory file
korlaxxalrok Jun 14, 2020
4957a67
Change receiving dir
korlaxxalrok Jun 15, 2020
1f08637
Add a bad directory name [test]
korlaxxalrok Jun 15, 2020
f147549
Merge pull request #78 from cmu-delphi/feature-jhu
korlaxxalrok Jun 15, 2020
20399fe
Fix bad directory
korlaxxalrok Jun 15, 2020
1ddaffa
Switch to build/test/package on PRs against the deploy branches
korlaxxalrok Jun 16, 2020
be65c6a
Add missing colon
korlaxxalrok Jun 16, 2020
2302936
Test breaking this file location
korlaxxalrok Jun 16, 2020
813a1e8
Change to target paramter
korlaxxalrok Jun 16, 2020
a193fce
Hmm, maybe the glob is not matching
korlaxxalrok Jun 16, 2020
7ed680f
Switch to using CHANGE_TARGET env variable to determine the indicator
korlaxxalrok Jun 17, 2020
346bc29
Add one more change to the PR branch
korlaxxalrok Jun 17, 2020
a5d0a23
Merge pull request #80 from cmu-delphi/test-fix-jhu
korlaxxalrok Jun 17, 2020
d97db26
Try using CHANGE_BRANCH env variable to find indicator
korlaxxalrok Jun 17, 2020
e7d0ed2
Use CHANGE_TARGET
korlaxxalrok Jun 17, 2020
cf09e82
Merge pull request #83 from cmu-delphi/test-fix-jhu
korlaxxalrok Jun 17, 2020
de8d2e3
Lets just get our env
korlaxxalrok Jun 17, 2020
e296204
Missed bracket
korlaxxalrok Jun 17, 2020
6489931
Use branch_name
korlaxxalrok Jun 17, 2020
fbe4968
Remove conditional for testing
korlaxxalrok Jun 17, 2020
5235aed
Trival change to test flow
korlaxxalrok Jun 17, 2020
aba0328
Merge pull request #84 from cmu-delphi/test-pr-flow-deploy-jhu
korlaxxalrok Jun 17, 2020
d67e492
Add environment block conditional to get the indicator name
korlaxxalrok Jun 17, 2020
3803574
Fix errant syntax
korlaxxalrok Jun 17, 2020
afbf5b8
Wrap in script block
korlaxxalrok Jun 17, 2020
981d53f
Put environment into its own stage
korlaxxalrok Jun 17, 2020
bb034fd
Add test step
korlaxxalrok Jun 17, 2020
91fa16c
Remove environment block
korlaxxalrok Jun 17, 2020
37519b2
Try to use helper function in environment block
korlaxxalrok Jun 17, 2020
1cd6eb6
Add missing quotes
korlaxxalrok Jun 17, 2020
3bda7ff
Try wrapping in script block
korlaxxalrok Jun 17, 2020
7e5b1e7
Use environment stage
korlaxxalrok Jun 17, 2020
2167aed
Fix function call
korlaxxalrok Jun 17, 2020
a06fd8d
Check for function return
korlaxxalrok Jun 17, 2020
c327e11
Move to env
korlaxxalrok Jun 17, 2020
d508a71
Call function
korlaxxalrok Jun 17, 2020
175f8da
Test for env var
korlaxxalrok Jun 17, 2020
7b35ae8
Test if statement in stage
korlaxxalrok Jun 17, 2020
a322861
Is it the exists function?
korlaxxalrok Jun 17, 2020
da5db52
Hmmm
korlaxxalrok Jun 17, 2020
8379ae6
Nope
korlaxxalrok Jun 17, 2020
0f1ea59
Try this
korlaxxalrok Jun 17, 2020
d89b8b8
Can we use this in the environment block now?
korlaxxalrok Jun 17, 2020
8d94b87
Can we use this in the environment block now (for real)?
korlaxxalrok Jun 17, 2020
c896027
Call function
korlaxxalrok Jun 17, 2020
962d73a
Try in stage
korlaxxalrok Jun 17, 2020
001b718
Try the conditional here
korlaxxalrok Jun 17, 2020
0d2dac8
Move to stage
korlaxxalrok Jun 17, 2020
a290bad
Is it an env variable?
korlaxxalrok Jun 17, 2020
04cfb66
Initialize Jenkinsfile
korlaxxalrok Jun 17, 2020
c2ff3b0
Add conditional to environment stage
korlaxxalrok Jun 17, 2020
4becfd0
Fix structure
korlaxxalrok Jun 17, 2020
9a93981
debug: print env
korlaxxalrok Jun 17, 2020
08922cc
Check for CHANGE_TARGET first
korlaxxalrok Jun 17, 2020
f350137
Fix space
korlaxxalrok Jun 17, 2020
f6303aa
debug: echo indicator
korlaxxalrok Jun 17, 2020
44d2f8a
Switch back to declaring the inidicator in the scripts and calling th…
korlaxxalrok Jun 17, 2020
2707c42
Add explicit indicator name to scripts to work around environment var…
korlaxxalrok Jun 17, 2020
0766a24
Fix interpolated string placement
korlaxxalrok Jun 17, 2020
98da541
Fix tar invocation
korlaxxalrok Jun 17, 2020
818ccaa
This is a PR to test for Jenkins PR flow. (#85)
korlaxxalrok Jun 17, 2020
3b70a8e
debug: print env
korlaxxalrok Jun 17, 2020
4152762
Remove debug
korlaxxalrok Jun 17, 2020
e15a56d
Can we use branch?
korlaxxalrok Jun 17, 2020
6701577
Fix merge conflict
korlaxxalrok Jun 17, 2020
110e5ad
Trivial change to test PR workflow
korlaxxalrok Jun 17, 2020
2710e20
Merge pull request #87 from cmu-delphi/bgc-test-fix-jhu-config
korlaxxalrok Jun 17, 2020
7860b46
Test PR workflow (#90)
korlaxxalrok Jun 18, 2020
af79f28
Test PR flow (#91)
korlaxxalrok Jun 18, 2020
ee4ea2e
Test PR flow (#92)
korlaxxalrok Jun 18, 2020
d5379c0
Test PR flow (#93)
korlaxxalrok Jun 18, 2020
90f35a7
Test PR flow (#95)
korlaxxalrok Jun 18, 2020
cc203c6
resolve conflicts
Jun 19, 2020
82ca468
Add missing bracket
korlaxxalrok Jun 19, 2020
70a5407
Add indicators ansible-vault encryption password location
korlaxxalrok Jun 19, 2020
684c116
Add location of ansible-vault password
korlaxxalrok Jun 19, 2020
96959fe
Test encrypting prod params file
korlaxxalrok Jun 19, 2020
edce5d1
Decrypt params file
korlaxxalrok Jun 19, 2020
5931e21
Merge pull request #68 from cmu-delphi/jingjing/jhu_with_unassigned
krivard Jun 19, 2020
480ce66
fixed errors in test_smooth
Jun 19, 2020
72c2f73
fixed errors
Jun 19, 2020
1ed824a
recover smoothed signals
Jun 19, 2020
9dc64f1
add .gitignore
Jun 19, 2020
62bc7b3
add gitignore
Jun 19, 2020
64be094
add gitignore
Jun 19, 2020
a7ff6c4
Use receiving directory on runtime host
korlaxxalrok Jun 22, 2020
30017df
Add Ansible-specific entries to ignore
korlaxxalrok Jun 22, 2020
b54d316
Add top-level readme
korlaxxalrok Jun 22, 2020
f2f137b
Update DETAILS.md
jingjtang Jun 22, 2020
dc2c6f7
Add much text to readme
korlaxxalrok Jun 22, 2020
d98a58b
Update README.md
korlaxxalrok Jun 23, 2020
c8902e0
Update README.md
korlaxxalrok Jun 23, 2020
bcfefc7
Update README.md
korlaxxalrok Jun 23, 2020
cf638f5
Update README.md
korlaxxalrok Jun 23, 2020
9eab4b6
Update README.md
korlaxxalrok Jun 23, 2020
3176d4b
Apply suggestions from code review
korlaxxalrok Jun 23, 2020
18f1d23
Fix a wee bit of punctuation
korlaxxalrok Jun 23, 2020
e25084b
Switch back to local directory for csv output
korlaxxalrok Jun 23, 2020
2b7cc96
Merge pull request #105 from cmu-delphi/run-jhu
korlaxxalrok Jun 23, 2020
88bcc7d
Merge pull request #101 from cmu-delphi/prodction-prep-deploy-jhu
korlaxxalrok Jun 24, 2020
2db36c3
Update params with production ingestion dir
korlaxxalrok Jun 24, 2020
daf00ca
Merge pull request #107 from cmu-delphi/prodction-prep-deploy-jhu
korlaxxalrok Jun 24, 2020
9082f84
update filenames for 7dav_ signals
Jun 25, 2020
439f5f0
add gitignore
Jun 25, 2020
1e5389d
update unittest
Jun 25, 2020
50af562
Merge pull request #110 from cmu-delphi/run-jhu
jingjtang Jun 26, 2020
80d9d75
Remove unneeded ght cache files
korlaxxalrok Jun 30, 2020
b5b9934
Merge branch 'main' into fix-merge-conflict-jhu-deploy
korlaxxalrok Jun 30, 2020
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
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,8 @@ venv.bak/

# mypy
.mypy_cache/

# Ansible
.retry
.indicators-ansible-vault-pass
indicators-ansible-vault-pass
83 changes: 83 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!groovy

// import shared library: https://github.com/cmu-delphi/jenkins-shared-library
@Library('jenkins-shared-library') _

pipeline {

agent any

stages {

stage ("Environment") {
when {
anyOf {
branch "deploy-*";
changeRequest target: "deploy-*", comparator: "GLOB"
}
}
steps {
script {
// Get the indicator name from the pipeline env.
if ( env.CHANGE_TARGET ) {
INDICATOR = env.CHANGE_TARGET.replaceAll("deploy-", "")
}
else if ( env.BRANCH_NAME ) {
INDICATOR = env.BRANCH_NAME.replaceAll("deploy-", "")
}
else {
INDICATOR = ""
}
}
}
}

stage('Build') {
when {
changeRequest target: "deploy-*", comparator: "GLOB"
}
steps {
sh "jenkins/${INDICATOR}-jenkins-build.sh"
}
}

stage('Test') {
when {
changeRequest target: "deploy-*", comparator: "GLOB"
}
steps {
sh "jenkins/${INDICATOR}-jenkins-test.sh"
}
}

stage('Package') {
when {
changeRequest target: "deploy-*", comparator: "GLOB"
}
steps {
sh "jenkins/${INDICATOR}-jenkins-package.sh"
}
}

stage('Deploy') {
when {
branch "deploy-*"
}
steps {
sh "jenkins/${INDICATOR}-jenkins-deploy.sh"
}
}
}

post {
always {
script {
/*
Use slackNotifier.groovy from shared library and provide current
build result as parameter.
*/
slackNotifier(currentBuild.currentResult)
}
}
}
}
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Covidcast Indicators

Pipeline code and supporting libraries for the **Real-time COVID-19 Indicators** used in the Delphi Group's [**COVIDcast** map](https://covidcast.cmu.edu).

## The indicators

Each subdirectory contained here that is named after an indicator has specific documentation. Please review as necessary!

## General workflow for indicators creation and deployment

**tl;dr**

- Create your new indicator branch from `main`.
- Build it using the appropriate template, following the guidelines in the included README.md and REVIEW.md files.
- Make some stuff!
- When your stuff works, push your `dev-*` branch to remote for review.
- Consult with a platform engineer for the remaining production setup needs. They will create a branch called `deploy-*` for your indicator.
- Initiate a pull request against this new branch.
- If your peers like it and Jenkins approves, deploy your changes by merging the PR.
- Rejoice!

### Starting out

The `main` branch should contain up-to-date code and supporting libraries. This should be your starting point when creating a new indicator.

```shell
# Hint
#
git checkout main
git checkout -b dev-my-feature-branch
```

### Creating your indicator

Create a directory for your new indicator by making a copy of `_template_r` or `_template_python` depending on the programming language you intend to use. The template copies of `README.md` and `REVIEW.md` include the minimum requirements for code structure, documentation, linting, testing, and method of configuration. Beyond that, we don't have any established restrictions on implementation; you can look at other existing indicators see some examples of code layout, organization, and general approach.

- Consult your peers with questions! :handshake:

Once you have something that runs locally and passes tests you set up your remote branch eventual review and production deployment.

```shell
# Hint
#
git push -u origin dev-my-feature-branch
```

### Setting up for review and deployment

Once you have your branch set up you should get in touch with a platform engineer to pair up on the remaining production needs. These include:

- Creating the corresponding `deploy-*` branch in the repo.
- Adding the necessary Jenkins scripts for your indicator.
- Preparing the runtime host with any Automation configuration necessities.
- Reviewing the workflow to make sure it meets the general guidelines and will run as expected on the runtime host.

Once all the last mile configuration is in place you can create a pull request against the correct `deploy-*` branch to initiate the CI/CD pipeline which will build, test, and package your indicator for deployment.

If everything looks ok, platform engineering has validated the last mile, and the pull request is accepted, you can merge the PR. Deployment will start automatically.

Hopefully it'll be a full on :tada:, after that :crossed_fingers:

If not, circle back and try again.

## Production overview

### Running production code

Currently, the production indicators all live and run on the venerable and perennially useful Delphi primary server (also known generically as "the runtime host").

- This is a virtual machine running RHEL 7.5 and living in CMU's Campus Cloud vSphere-based infrastructure environemnt.

### Delivering an indicator to the production environment

We use a branch-based git workflow coupled with [Jenkins](https://www.jenkins.io/) and [Ansible](https://www.ansible.com/) to build, test, package, and deploy each indicator individually to the runtime host.

- Jenkins dutifully manages the whole process for us by executing several "stages" in the context of a [CI/CD pipeline](https://dzone.com/articles/learn-how-to-setup-a-cicd-pipeline-from-scratch). Each stage does something unique, building on the previous stage. The stages are:
- Environment - Sets up some environment-specific needs that the other stages depend on.
- Build - Create the Python venv on the Jenkins host.
- Test - Run linting and unit tests.
- Package - Tar and gzip the built environment.
- Deploy - Trigger an Ansible playbook to place the built package onto the runtime host, place any necessary production configuration, and adjust the runtime envirnemnt (if necessary).

There are several additional Jenkins-specific files that will need to be created for each indicator, as well as some configuration additions to the runtime host. It will be important to pair with a platform engineer to prepare the necessary production environment needs, test the workflow, validate on production, and ultimately sign off on a production release.
26 changes: 26 additions & 0 deletions ansible/ansible-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- hosts: runtime_host
vars_files:
- vars.yaml
tasks:
- name: Copy and unarchive the package into the indicators runtime host directory.
unarchive:
src: "{{ jenkins_artifact_dir }}/{{ package }}"
dest: "{{ indicators_runtime_dir }}"
owner: "{{ runtime_user }}"
group: "{{ runtime_user }}"

- name: Mutate Python bin path used in venv.
file:
src: "{{ pyenv_python_path }}"
dest: "{{ indicators_runtime_dir }}/{{ indicator }}/env/bin/python"
owner: "{{ runtime_user }}"
group: "{{ runtime_user }}"
state: link

- name: Set production params file.
copy:
src: files/{{ indicator }}-params-prod.json
dest: "{{ indicators_runtime_dir }}/{{ indicator }}/params.json"
owner: "{{ runtime_user }}"
group: "{{ runtime_user }}"
8 changes: 8 additions & 0 deletions ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[defaults]
remote_user = indicators
vault_password_file = ~/.indicators-ansible-vault-pass
ansible_managed = This file is managed by Ansible.%n
Template: {file}
Date: %Y-%m-%d %H:%M:%S
User: {uid}
Host: {host}
7 changes: 7 additions & 0 deletions ansible/files/jhu-params-prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"export_start_date": "2020-02-20",
"static_file_dir": "./static",
"export_dir": "/common/covidcast/receiving/jhu-csse/",
"cache_dir": "./cache",
"base_url": "https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_{metric}_US.csv"
}
2 changes: 2 additions & 0 deletions ansible/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[runtime_host]
delphi-master-prod-01.delphi.cmu.edu
7 changes: 7 additions & 0 deletions ansible/vars.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
runtime_user: "indicators"
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.
python_version: "3.8.2"
pyenv_python_path: "/home/{{ runtime_user }}/.pyenv/versions/{{ python_version }}/bin/python"
133 changes: 0 additions & 133 deletions google_health/cache/Data_500_anosmia_ms.csv

This file was deleted.

Loading