Perforce Swarm Review Automation
Where it started
As my team began setting up a working review pipeline using Perforce Swarm (P4 Code Review) I saw an issue. Communication became a hassle and spanning too many applications and as such it harmed the teams work process. And so I set to find a solution that would allow for a connection between our most familiar communication outlet (Discord) and P4 Swarm.
Where it stands
The current form of the Perforce Swarm review automation is a Discord bot, hosted on an AWS Ubuntu server that I set up during my off-university time. It utilizes Swarm's "Workflow" and "Test" features to send POST requests to a webhook endpoint on a domain I own, which routes to my server via Cloudflare Tunnel.
When the bot receives information about a new review it uses Perforce's REST API to get more information on the review before opening a new forum thread in the team's channel. The bot will tag all the reviewers assigned and will copy over the description and create a checklist for the definitions of done. With all the necessary data (user mapping, review data, server information) are saved and organized in PostgreSQLdatabases.
A tool for others
After making sure that the pipeline works for my team, I added support for multiple guilds (servers), adding a guild config table to the SQL databases for Swarm credentials, channels, settings. I had to refactor the code substantially, adding guild ID to each database table to isolate each team's data. The webhook endpoint changed to a per-server route (/swarm/<guild_id>).
I added a role-based system, where team leads can manage user mappings and review lifecycle (approving, closing), while regular users get read-only access. For easy setup I added an interactive wizard that walks a new team through configuration step by step, so onboarding another team takes minutes, not code changes.
The code for this project can be found in my personal Github page and is written almost entirely in Python.