https://github.com/polyvariant/pitgull
Automatic housekeeping for your gitlab repositories.
https://github.com/polyvariant/pitgull
cats-effect dhall fs2 gitlab scala scala-steward sttp tapir
Last synced: 5 months ago
JSON representation
Automatic housekeeping for your gitlab repositories.
- Host: GitHub
- URL: https://github.com/polyvariant/pitgull
- Owner: polyvariant
- License: other
- Created: 2020-07-25T00:27:08.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-09-28T18:59:02.000Z (over 1 year ago)
- Last Synced: 2023-09-28T22:25:18.476Z (over 1 year ago)
- Topics: cats-effect, dhall, fs2, gitlab, scala, scala-steward, sttp, tapir
- Language: Scala
- Homepage:
- Size: 760 KB
- Stars: 14
- Watchers: 2
- Forks: 3
- Open Issues: 33
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Pitgull
[](http://www.apache.org/licenses/LICENSE-2.0.txt)

[](https://github.com/typelevel/cats)
## How it works
The core idea behind the project is very simple - create a tool for automatically applying merge requests created by [Scala Steward](https://github.com/scala-steward-org/scala-steward) on any [Gitlab](https://gitlab.com/) instance. Currently Pitgull is ortogonal from the bots, the merge requests are qualified by generic rules.
Pitgull works as a web service, listening for webhook events from Gitlab instance. Upon receiving a webhook, it reads related project's merge requests, finds one best candidate and tries to merge it. If all qualifying merge requests need to be updated, an attempt to rebase them onto the target branch will be made.
Once an MR is merged, Gitlab will trigger another webhook, creating a loop until Pitgull finds no qualifying merge request.
## Integrating with Pitgull
Along with Pitgull, we provide a `pitgull-bootstrap` command line utility. This program prepares your GitLab project for integration with Pitgull by deleting existing Scala Steward merge requests and setting up a webhook for triggering Pitgull.
```
CLI Arguments:
--url - your gitlab url like https://gitlab.com/
--token - your gitlab personal token, needs to have full access to project
--project - project ID, can be found on project main page
--bot - user name of Scala Steward bot user
--webhook - Pitgull target url like https://pitgull.example.com/webhook
```
### Why delete existing merge requests?Pitgull will only take action when it's triggered by a webhook. By deleting merge requests we make sure no Scala Steward MR gets unnoticed. If we'd only close them, Scala Steward wouldn't update them, so no webhook would be triggerd.
Additionally, if you have some legacy merge requests for single library, this program makes sure to clean them up. When Scala Steward notices that some dependency is out of date and MR is missing - it will recreate it, so no worries about skipping any updates.
## Development
### Useful commands/links
- https://gitlab.com/-/graphql-explorer - Gitlab API's GraphiQL
- `cat example.dhall | dhall-to-json` - normalize example and convert to JSON
- `http post :8080/webhook @path-to-file.json` - send fake webhook event from file### Related projects
We're using https://github.com/polyvariant/caliban-gitlab for some communication with Gitlab,
as well as https://github.com/softwaremill/tapir + https://github.com/softwaremill/sttp for the actions not available via the GraphQL API.### Docker
You're going to need docker and docker-compose (or podman/podman-compose, although it hasn't been confirmed to work here yet).
You can use the setup in the `docker` directory to run Scala Steward with [the test repository](https://gitlab.com/kubukoz/demo), or customize it to your needs.
Checkout https://github.com/scala-steward-org/scala-steward/blob/master/docs/running.md#running-scala-steward for more information.
You'll need to add a `pass.sh` file that prints your GitLab token to standard output when run (consult the Scala Steward docs to see how).After you're all set-up, run `docker-compose up` inside the `docker` directory (or `docker-compose -f docker/docker-compose.yml up` in the project directory).
## Releasing
Docker images are being pushed on every push to `main` and tags starting with `v`.