Synchronizing targets

I realised last week that although I had gotten seemless onboarding working a while back, I had forgotten an important part. You see connecting up a user‘s repo to your server app is only half the battle, though crucial obviously. The other part that's just as important is what happens when a user goes back to their app settings and adds or removes repos from your app. That of course needs to work too.

I had completely forgotten about that and I had that sinking feeling when I clicked the buttons to add a repo, and saw that a bunch of errors appeared in my server logs. Luckily when I wrote the connect part I had envisioned I would need at some stage to do this and so, in the underbelly of the server business logic, I had implemented a syncTargets methodand and was using it for the initial connect. It creates all the necessary database records, all atomically, works a charm.

The tricky part was to add a new handler for this type of webhook that is received from Github when these events happen. It's slightly different to the usual webhooks because it's not linked to a particular repo, or in the parlance of my server app, which is attempting to remain agnostic, a particular target. It‘s an account level event, rather than a target level event. Ultimately what this meant for my server software was that it needed to do a bunch of stuff without making any calls to the Github API. The issue I had was the way I had architected it, there was the assumption that you always needed to make calls to the API, and so you needed to do all the authentication and rigmarole that comes with that.

So I spend the past couple of days really deep in debugging across many layers of the code. My vscode debugger launch configs were out of date, and so rather than get stuck fixing that, I decided to do it with old school console.log statements. So many log statements everywhere. I was drowning in them. To be honest either way I think it would have been kind of gnarly, because it was code I wrote a long while ago, and hadn't touched as it's been working without any issues at all, so it wasn't fresh in my mind. Anyhow I got through it, and as of last night, I got it working in the two main deployment scenarios. I now need to fix the broken unit tests, and then test across all the distros.

Right before I got side tracked on this, I had just written a runner for my smoke testing script, because as useful as the smoke test script is, there are so many different scenarios to test against at this point it had become really error prone doing it all manually. Hopefully with the new runner, that all becomes much easier. Eventually I think there will be a way to hook it into the production deploy, so nothing ever gets pushed to prod until all the unit and integrations tests pass, and also all the smoke tests pass. Full end to end testing. In the short term I will still be launching the runner manually, but it‘s still a huge improvement as it creates all the necessary jobs in the background, in the right order, and verifies they all complete in the right way.

Looking forward to completing this beta, which is beta.4. Then still another 2 betas before a release candidate.