|
| 1 | +# Contributing to COVIDcast indicator pipelines |
| 2 | + |
| 3 | +## Branches |
| 4 | + |
| 5 | +* `main` |
| 6 | + |
| 7 | +The primary/authoritative branch of this repository is called `main`, and contains up-to-date code and supporting libraries. This should be your starting point when creating a new indicator. It is protected so that only reviewed pull requests can be merged in. |
| 8 | + |
| 9 | +* `deploy-*` |
| 10 | + |
| 11 | +Each automated pipeline has a corresponding branch which automatically deploys to a runtime host which runs the pipeline at a designated time each day. New features and bugfixes are merged into this branch using a pull request, so that our CI system can run the lint and test cycles and make sure the package will run correctly on the runtime host. If an indicator does not have a branch named after it starting with `deploy-`, that means the indicator has not yet been automated, and has a designated human keeper who is responsible for making sure the indicator runs each day -- whether that is manually or using a scheduler like cron is the keeper's choice. |
| 12 | + |
| 13 | +* everything else |
| 14 | + |
| 15 | +All other branches are development branches. We don't enforce a naming policy. |
| 16 | + |
| 17 | +## Issues |
| 18 | + |
| 19 | +Issues are the main communication point when it comes to bugfixes, new features, or other possible changes. The repository has several issue templates that help to structure issues. |
| 20 | + |
| 21 | +If you ensure that each issue deals with a single topic (ie a single new proposed data source, or a single data quality problem), we'll all be less likely to drop subordinate tasks on the floor, but we also recognize that a lot of the people filing issues in this repository are new to large project management and not used to focusing their thoughts in this way. It's okay, we'll all learn and get better together. |
| 22 | + |
| 23 | +Admins will assign issues to one or more people based on balancing expediency, expertise, and team robustness. It may be faster for one person to fix something, but we can reduce the risk of having too many single points of failure if two people work on it together. |
| 24 | + |
| 25 | +## Project Boards |
| 26 | + |
| 27 | +The Delphi Engineering team uses project boards to structure its weekly calls and track active tasks. |
| 28 | + |
| 29 | +Immediate work is tracked on [Release Planning](https://github.com/cmu-delphi/covidcast-indicators/projects/2) |
| 30 | + |
| 31 | +Long-term work and modeling collaborations are tracked on [Refactoring](https://github.com/cmu-delphi/covidcast-indicators/projects/3) |
| 32 | + |
| 33 | + |
| 34 | +## General workflow for indicators creation and deployment |
| 35 | + |
| 36 | +So, how does one go about developing a pipeline for a new data source? |
| 37 | + |
| 38 | +**tl;dr** |
| 39 | + |
| 40 | +1. Create your new indicator branch from `main`. |
| 41 | +2. Build it using the appropriate template, following the guidelines in the included README.md and REVIEW.md files. |
| 42 | +3. Make some stuff! |
| 43 | +4. When your stuff works, push your `dev-*` branch to remote for review. |
| 44 | +5. Consult with a platform engineer for the remaining production setup needs. They will create a branch called `deploy-*` for your indicator. |
| 45 | +6. Initiate a pull request against this new branch. |
| 46 | +7. Following [the source documentation template](https://github.com/cmu-delphi/delphi-epidata/blob/main/docs/api/covidcast-signals/_source-template.md), create public API documentation for the source. You can submit this as a pull request against the delphi-epidata repository. |
| 47 | +8. If your peers like the code, the documentation is ready, and Jenkins approves, deploy your changes by merging the PR. |
| 48 | +9. An admin will propagate your successful changes to `main`. |
| 49 | +10. Rejoice! |
| 50 | + |
| 51 | +### Starting out |
| 52 | + |
| 53 | +The `main` branch should contain up-to-date code and supporting libraries. This should be your starting point when creating a new indicator. |
| 54 | + |
| 55 | +```shell |
| 56 | +# Hint |
| 57 | +# |
| 58 | +git checkout main |
| 59 | +git checkout -b dev-my-feature-branch |
| 60 | +``` |
| 61 | + |
| 62 | +### Creating your indicator |
| 63 | + |
| 64 | +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. |
| 65 | + |
| 66 | +- Consult your peers with questions! :handshake: |
| 67 | + |
| 68 | +Once you have something that runs locally and passes tests you set up your remote branch eventual review and production deployment. |
| 69 | + |
| 70 | +```shell |
| 71 | +# Hint |
| 72 | +# |
| 73 | +git push -u origin dev-my-feature-branch |
| 74 | +``` |
| 75 | + |
| 76 | +You can then draft public API documentation for people who would fetch this |
| 77 | +data from the API. Public API documentation is kept in the delphi-epidata |
| 78 | +repository, and there is a [template Markdown |
| 79 | +file](https://github.com/cmu-delphi/delphi-epidata/blob/main/docs/api/covidcast-signals/_source-template.md) |
| 80 | +that outlines the features that need to be documented. You can create a pull |
| 81 | +request to add a new file to `docs/api/covidcast-signals/` for your source. Our |
| 82 | +goal is to have public API documentation for the data at the same time as it |
| 83 | +becomes available to the public. |
| 84 | + |
| 85 | +### Setting up for review and deployment |
| 86 | + |
| 87 | +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: |
| 88 | + |
| 89 | +- Creating the corresponding `deploy-*` branch in the repo. |
| 90 | +- Adding the necessary Jenkins scripts for your indicator. |
| 91 | +- Preparing the runtime host with any Automation configuration necessities. |
| 92 | +- Reviewing the workflow to make sure it meets the general guidelines and will run as expected on the runtime host. |
| 93 | + |
| 94 | +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. |
| 95 | + |
| 96 | +If everything looks ok, you've drafted source documentation, platform engineering has validated the last mile, and the pull request is accepted, you can merge the PR. Deployment will start automatically. |
| 97 | + |
| 98 | +Hopefully it'll be a full on :tada:, after that :crossed_fingers: |
| 99 | + |
| 100 | +If not, circle back and try again. |
| 101 | + |
| 102 | +## Production overview |
| 103 | + |
| 104 | +### Running production code |
| 105 | + |
| 106 | +Currently, the production indicators all live and run on the venerable and perennially useful Delphi primary server (also known generically as "the runtime host"). |
| 107 | + |
| 108 | +### Delivering an indicator to the production environment |
| 109 | + |
| 110 | +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. |
| 111 | + |
| 112 | +- 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: |
| 113 | + - Environment - Sets up some environment-specific needs that the other stages depend on. |
| 114 | + - Build - Create the Python venv on the Jenkins host. |
| 115 | + - Test - Run linting and unit tests. |
| 116 | + - Package - Tar and gzip the built environment. |
| 117 | + - 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). |
| 118 | + |
| 119 | +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