Again and Again With the Again
October 15th, 2021We came into this week with our plan of action; my part was to set up the ten non-database microservices, complete with automated testing, permissions for the other team members, and branch protection to force testing prior to risking breaking changes. My stretch goal was to get some user API routes mocked up but research and the rote repetition of getting the repos set took up the week.
I already knew that I had ten microservices to set up, so my first step was to try and find as many ways to streamline this process as possible. Ideally I could set up a single repo and then copy it over and over, just needing to change the name before any determinate steps were taken. Unfortunately it turned out that while there is a lovely pathway for copying the code as I hoped, branch protections and user access had to be manually set up for each individual repo and those were going to be the major time sink anyway.
For anyone following along at home, the quick trick to clone a repo repeatedly is to check the ‘template repository’ box in the main settings screen, and then a big friendly green button will appear on the repo home page so that you may copy it to your heart’s content.
Since I sort of started at the ending there, I’ll continue working back to my start. Adding my teammates to each repo was easy but time consuming, as there is no way I could find to automate adding them. Theoretically we could have made an organization which would own all the project repositories, but we would then need to pay for an account as we are using pro features with our student accounts. I also had to check off my desired branch protection rules for each and every repository, which was the largest and most boring time sink in this whole thing. I also needed to make sure to put them in place AFTER I was done fixing lines from the template to the actual repo name so that I didn’t have to annoy my teammates with all the minor changes.
Since I only had the barest skeleton of code, I only needed to fix the README and a few lines on the Node package files to point at the specific repository instead of the template repo. Monotonous, but not as bad as needing to fix a bad assumption I made when copying all the repos: I elected to copy the main and dev branches I had set up, assuming settings and history would transfer. No. I had to manually set main as the upstream for each and every dev and force a push to overwrite the non-history with the new configuration. Again, not bad except for having to do it ten times; especially with messing up orders of operation and needing to wait for a teammate to approve a fix.
Monotony aside, the larger and more satisfying part of this whole experience was researching and actually configuring the template project. I started with the gateway, as it’s the only outside facing part of the microservice ecosystem and if nothing else exists it can still feature dummy API calls to pretend there’s more of a backend behind it. Not that I actually put in any of those dummy routes yet. I found in one of the tutorials I followed an excellent placeholder route that let me run a generic test to ensure my testing suite was actually running correctly, an about page pulling the repo name and version from the package JSON. From there, I was able to set up Mocha and Chai to compare the data in the about page to the package JSON and prove both that the data was being passed successfully and that the test was testing things. I also have Nock installed and ready to intercept calls to other APIs, but that’s a problem for future Robert for now.
I learned a lot this week and had a large share of frustrations, but overall I’m happy with what I got done and am looking forward to actually getting some routes going next week.