feat: pr watcher for Grove
Description
Adds PR watching support to Grove for edx-platform forks.
When the command is invoked it will check the provided EDX_PLATFORM_FORKS
and GITHUB_USERNAMES
for any open or closed pull requests.
- If the pull request is open
- Trigger the creation of a new instance if it doesn't exist in the grove-template fork
- Otherwise trigger the update pipeline
- If the pull request is closed
- run the destroy pipeline if it's still running (by checking if the namespace exists).
Some assumptions and notes:
- Instances names are of the format
pr-{pr-number}-{fork-hash}
so that operators can watch more than one fork and not have collisions - The settings block is unchanged from Ocim's
- The code in
github.py
is almost a direct copy of Ocim's. - When an instance is created/updated a
PR_WATCHER
key is added togrove.yml
to keep track of what was last deployed. - Due to time constraints, only a few integration tests are added.
- The PR watcher CRON is set to run once per hour. It is not enabled on the test environment.
Testing instructions
Test the create:
I've created a test edx-platform fork https://github.com/keithgg/edx-platform and added keithgg
and gabor-boros
to the list of allowed users.
- Create a PR against that repo and be sure to add a
Settings
block (even if empty). - Run the function:
curl --insecure -u admin:pass https://openfaas.kgcluster.opencraft.hosting/function/pr-watcher
- You will see the pipeline running to create your instance on https://gitlab.com/opencraft/devstacks/keith/grove-do/-/pipelines
- Example: https://gitlab.com/opencraft/devstacks/keith/grove-do/-/pipelines/703939976
Test the update
- Make a change to your PR and run the curl command again.
- The update pipeline for your PR will be triggered.
Test the destroy
- Close your PR
- The destroy pipeline for your PR should be triggered
- Example: https://gitlab.com/opencraft/devstacks/keith/grove-do/-/pipelines/703913703
Checklist
If any of the items below is not applicable, do not remove them, but put a check in it.
-
All providers include the new feature/change -
All affected providers can provision new clusters -
Unit tests are added/updated -
Documentation is added/updated -
The TOOLS_CONTAINER_IMAGE_VERSION
in ci_vars.yml is updated -
The grove-template repository is updated
Edited by Keith Grootboom