|
| 1 | +.. _updating_services: |
| 2 | + |
| 3 | +Updating an Octue service |
| 4 | +========================= |
| 5 | + |
| 6 | +This page describes how to update an existing, deployed Octue service - in other words, how to deploy a new Octue |
| 7 | +service revision. |
| 8 | + |
| 9 | +We assume that: |
| 10 | + |
| 11 | +- Your service's repository is on GitHub and you have push access to it |
| 12 | +- Octue's `standard deployment GitHub Actions workflow <https://github.com/octue/workflows/blob/main/.github/workflows/deploy-cloud-run-service.yml>`_ |
| 13 | + is set up in the repository and being used to deploy the service to Google Cloud Run on merge of a pull request into |
| 14 | + the ``main`` branch (see an example `here <https://github.com/octue/example-service-cloud-run/blob/main/.github/workflows/cd.yaml>`_) |
| 15 | +- A release workflow is set up that will tag and release the new service revision on GitHub (see an example |
| 16 | + `here <https://github.com/octue/example-service-cloud-run/blob/main/.github/workflows/release.yml>`_) |
| 17 | + |
| 18 | +Instructions |
| 19 | +------------- |
| 20 | + |
| 21 | +1. Check out and pull the ``main`` branch to make sure you're up to date with the latest changes |
| 22 | + |
| 23 | + .. code-block:: shell |
| 24 | +
|
| 25 | + git checkout main |
| 26 | + git pull |
| 27 | +
|
| 28 | +2. Install your service locally so you can run the tests and your development environment can lint the code etc.: |
| 29 | + |
| 30 | + .. code-block:: shell |
| 31 | +
|
| 32 | + poetry install |
| 33 | +
|
| 34 | +3. Set up `pre-commit <https://pre-commit.com/>`_ to enforce code quality: |
| 35 | + |
| 36 | + .. code-block:: shell |
| 37 | +
|
| 38 | + pre-commit install && pre-commit install -t commit-msg |
| 39 | +
|
| 40 | +4. Check out a new branch so you can work independently of any other work on the code happening at the same time |
| 41 | + |
| 42 | + .. code-block:: shell |
| 43 | +
|
| 44 | + git checkout -b my-new-feature |
| 45 | +
|
| 46 | +5. Add and make changes to your app's code as needed, committing each self-contained change. Use the `Conventional |
| 47 | + Commits <https://www.conventionalcommits.org/en/v1.0.0/>`_ commit message format so the new version for your service |
| 48 | + can be automatically calculated. |
| 49 | + |
| 50 | + .. code-block:: shell |
| 51 | +
|
| 52 | + git add a-new-file another-new-file |
| 53 | + git commit -m "Your commit message" |
| 54 | + ...repeat... |
| 55 | +
|
| 56 | + Push your commits frequently so your work is backed up on GitHub |
| 57 | + |
| 58 | + .. code-block:: shell |
| 59 | +
|
| 60 | + git push |
| 61 | +
|
| 62 | +6. Write any new tests you need to verify your code works and update any old tests as needed |
| 63 | + |
| 64 | +7. Run the tests locally using ``pytest`` and fix anything that makes them fail |
| 65 | + |
| 66 | + .. image:: images/updating_services/pytest.png |
| 67 | + |
| 68 | +8. Update the `semantic version <https://semver.org/>`_ of your app. This communicates to anyone updating from a |
| 69 | + previous version of the service whether they can use it as before or if there might be changes they need to make to |
| 70 | + their own code or data first. |
| 71 | + |
| 72 | + - ``poetry version patch`` for a bug fix or small non-code change |
| 73 | + - ``poetry version minor`` for a new feature |
| 74 | + - ``poetry version major`` for a breaking change |
| 75 | + |
| 76 | + Don't forget to commit this change, too. |
| 77 | + |
| 78 | +9. When you're ready to review the changes, head to GitHub and open a pull request of your branch into ``main``. This |
| 79 | + makes it easy for you and anyone else to see what's changed. Check the "Files Changed" tab to make sure everything's |
| 80 | + there and consistent (it's easy to forget to push a commit). Ask your colleagues to review the code if required. |
| 81 | + |
| 82 | + .. image:: images/updating_services/diff.png |
| 83 | + |
| 84 | +10. When you're ready to release the new version of your service, check that the GitHub checks have passed. These ensure |
| 85 | + code quality, that the tests pass, and that the new version number is correct. |
| 86 | + |
| 87 | + .. image:: images/updating_services/checks.png |
| 88 | + |
| 89 | +11. Merge the pull request into ``main``. This will run the deployment workflow (usually called ``cd`` - continuous |
| 90 | + deployment), making the new version of the service available to everyone. |
| 91 | + |
| 92 | +12. Check that the deployment workflow has run successfully (this can take a few minutes). You can check the progress in |
| 93 | + the "Actions" tab of the GitHub repository |
| 94 | + |
| 95 | + .. image:: images/updating_services/deployment.png |
0 commit comments