|
| 1 | +# Covidcast Indicators |
| 2 | + |
| 3 | +Pipeline code and supporting libraries for the **Real-time COVID-19 Indicators** used in the Delphi Group's [**COVIDcast** map](https://covidcast.cmu.edu). |
| 4 | + |
| 5 | +## The indicators |
| 6 | + |
| 7 | +Each subdirectory contained here that is named after an indicator has specific documentation. Please review as necessary! |
| 8 | + |
| 9 | +## General workflow for indicators creation and deployment |
| 10 | + |
| 11 | +**tl;dr** |
| 12 | + |
| 13 | +- Create your new indicator branch from `main`. |
| 14 | +- Build it using the appropriate template, following the guidelines in the included README.md and REVIEW.md files. |
| 15 | +- Make some stuff! |
| 16 | +- When your stuff works, push your `dev-*` branch to remote for review. |
| 17 | +- Consult with a platform engineer for the remaining production setup needs. They will create a branch called `deploy-*` for your indicator. |
| 18 | +- Initiate a pull request against this new branch. |
| 19 | +- If your peers like it and Jenkins approves, deploy your changes by merging the PR. |
| 20 | +- Rejoice! |
| 21 | + |
| 22 | +### Starting out |
| 23 | + |
| 24 | +The `main` branch should contain up-to-date code and supporting libraries. This should be your starting point when creating a new indicator. |
| 25 | + |
| 26 | +```shell |
| 27 | +# Hint |
| 28 | +# |
| 29 | +git checkout main |
| 30 | +git checkout -b dev-my-feature-branch |
| 31 | +``` |
| 32 | + |
| 33 | +### Creating your indicator |
| 34 | + |
| 35 | +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. |
| 36 | + |
| 37 | +- Consult your peers with questions! :handshake: |
| 38 | + |
| 39 | +Once you have something that runs locally and passes tests you set up your remote branch eventual review and production deployment. |
| 40 | + |
| 41 | +```shell |
| 42 | +# Hint |
| 43 | +# |
| 44 | +git push -u origin dev-my-feature-branch |
| 45 | +``` |
| 46 | + |
| 47 | +### Setting up for review and deployment |
| 48 | + |
| 49 | +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: |
| 50 | + |
| 51 | +- Creating the corresponding `deploy-*` branch in the repo. |
| 52 | +- Adding the necessary Jenkins scripts for your indicator. |
| 53 | +- Preparing the runtime host with any Automation configuration necessities. |
| 54 | +- Reviewing the workflow to make sure it meets the general guidelines and will run as expected on the runtime host. |
| 55 | + |
| 56 | +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. |
| 57 | + |
| 58 | +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. |
| 59 | + |
| 60 | +Hopefully it'll be a full on :tada:, after that :crossed_fingers: |
| 61 | + |
| 62 | +If not, circle back and try again. |
| 63 | + |
| 64 | +## Production overview |
| 65 | + |
| 66 | +### Running production code |
| 67 | + |
| 68 | +Currently, the production indicators all live and run on the venerable and perennially useful Delphi primary server (also known generically as "the runtime host"). |
| 69 | + |
| 70 | +- This is a virtual machine running RHEL 7.5 and living in CMU's Campus Cloud vSphere-based infrastructure environemnt. |
| 71 | + |
| 72 | +### Delivering an indicator to the production environment |
| 73 | + |
| 74 | +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. |
| 75 | + |
| 76 | +- 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: |
| 77 | + - Environment - Sets up some environment-specific needs that the other stages depend on. |
| 78 | + - Build - Create the Python venv on the Jenkins host. |
| 79 | + - Test - Run linting and unit tests. |
| 80 | + - Package - Tar and gzip the built environment. |
| 81 | + - 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). |
| 82 | + |
| 83 | +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. |
0 commit comments