smarkets / marge-bot

A merge-bot for GitLab
BSD 3-Clause "New" or "Revised" License
701 stars 136 forks source link

Allow running marge-bot in CI pipelines or as a single CLI job #289

Closed nejch closed 3 years ago

nejch commented 3 years ago

This PR allows running marge-bot as a single job rather than looping indefinitely, so it can be managed via CI pipeline schedules instead of deploying it to your infrastructure.

See also renovate-bot's approach for something similar. https://docs.renovatebot.com/self-hosting/#gitlab-cicd-pipeline

I've added this as a simple flag since I wanted to keep codebase change to a minimum, although I was initially considering another console_scripts entrypoint. But I didn't want to change your approach to deployment too much (see also https://github.com/smarkets/marge-bot/issues/288) so I hope this is fine.

I also considered auto-detecting/defaulting to the GITLAB_CI and CI_SERVER_URL (for gitlab_url) env vars if marge detects it's in a CI environment, to get a bit closer to zero-config. But I also didn't want to break the existing response to required args. It's tempting though, let me know if you'd accept that :)

For an example run, see https://gitlab.com/nejch1/test-marge-bot-as-ci-service/-/jobs/1029017409.

qqshfox commented 3 years ago

I agree that we shouldn't break existing deployment. Thank you @nejch !