<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sam Rayatnia on Medium]]></title>
        <description><![CDATA[Stories by Sam Rayatnia on Medium]]></description>
        <link>https://medium.com/@rayatnia?source=rss-6a81a59e56c8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MHhSQiMPUH-4kYFDotmwtA.jpeg</url>
            <title>Stories by Sam Rayatnia on Medium</title>
            <link>https://medium.com/@rayatnia?source=rss-6a81a59e56c8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 19:41:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rayatnia/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Autoscaler: A cheap way to scale your CI/CD]]></title>
            <link>https://medium.com/@rayatnia/autoscaler-a-cheap-way-to-scale-your-ci-cd-7ba8a15567e1?source=rss-6a81a59e56c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ba8a15567e1</guid>
            <category><![CDATA[continuous-delivery]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <dc:creator><![CDATA[Sam Rayatnia]]></dc:creator>
            <pubDate>Mon, 28 Sep 2026 07:27:03 GMT</pubDate>
            <atom:updated>2026-09-28T07:27:03.023Z</atom:updated>
            <content:encoded><![CDATA[<p>Every solution begins with a problem, and this one started with a surprisingly simple limitation: GitHub’s free tier only provides 2,000 minutes per month for running GitHub Actions on private repositories.</p><p>Like always, the challenge wasn’t writing better code; it was maintaining code quality while working within a hard execution budget. Every pipeline run became a trade-off between confidence and cost.</p><p>This post tells that story, shares the lessons learned along the way, and explains how that limitation ultimately led to the creation of <strong>Autoscaler</strong>.</p><p><strong>Note:</strong> If you’d rather skip straight to the feature list, it’s at the bottom of this post.</p><p><strong>Caution:</strong> If ARC (Actions Runner Controller) already works for you and the bill doesn’t bother you, this probably isn’t the blog post you’re looking for.</p><p><strong>p.s.</strong> There’s no innovation here; it’s just a pain solved.</p><h3>Why would anyone in their right mind reinvent the wheel?</h3><p>Like any other sane person, I have an irrational hatred for anything wasteful, inefficient, or low-quality.</p><p>The problem is that I code in my free time (no surprise there). And like any good developer, I test my code… by writing even more code.</p><p>My side project snowballed into more than seven microservices, four frontend and design-system modules, ten public SDKs, three infrastructure stacks, and a growing list of other components.</p><p>(I know, it sounds like an enterprise.)</p><p>The only problem? I’m not an enterprise.</p><p>What I had was an enterprise-sized CI workload on a hobbyist budget.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*p4HV7Ygmfz8I00cgWrIjtw.gif" /></figure><p>Every pull request triggers a build. Every change kicked off tests. Every SDK release meant another pipeline. GitHub’s 2,000 free minutes disappeared faster than I could write features. My record is burning through them in less than half a day.</p><p>And like every software engineer, when I hit a wall, I don’t simply turn around; I could build a helicopter to fly over it. Except this time, a ladder would do the trick.</p><p>My first thought was the obvious one: self-hosted runners don’t count against those 2,000 minutes, so why not register a few and let my Raspberry Pi 5 handle the workload?</p><p>It worked.</p><p>For about five minutes.</p><p>The Pi quickly reminded me that enthusiasm isn’t a substitute for CPU cores. So I moved to the “proper” solution: spin up AWS resources and deploy ARC. Then I saw the AWS bill.</p><p>I closed the dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*yZIiQx8Yxy5-Wt4ajsETgw.gif" /></figure><p>If you’re comfortable paying for the infrastructure, ARC is a great solution for several reasons, depending on your use cases. My goal wasn’t to shift the cost elsewhere; it was to avoid creating it in the first place.</p><p>When I projected the costs over a full year, I realised that GitHub-hosted runners would cost me at least $1,450. The self-hosted AWS option with ARC would be worse: I would not only have to maintain those resources but also pay at least $1,860.</p><p>That’s when a much simpler thought crossed my mind. I’m a hobbist, and I have at least five perfectly capable machines scattered around the house, sitting idle most of the day.</p><p>What if I put them to work?</p><h3>The dumb version came first.</h3><p>Before anything clever, I did what everyone does: I registered one runner container per repo and left it running in Docker Compose. (Well, don’t judge me yet; it seemed reasonable at the time.)</p><p>And yes, the Autoscaler in this system was me.</p><p>Two pull requests to the same repo meant the second one waited in line, unless I personally copy-pasted a compose block, renamed runner-frontend to runner-frontend-2, ran the registration script again, and promised myself I’d clean it up later.</p><p>By the fifth time I did that by hand, I finally asked the actual question:</p><p><strong>What am I doing with my life?</strong></p><p>Docker can start and stop containers! GitHub announces the exact moment a job gets queued. And my devices are on for most of the day anyway.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*7AnxDMZiGuDbc26N7MSQ5Q.gif" /></figure><p>So I wrote a small Go program (with the help of our trusty friend Claude Code), and called it Autoscaler.</p><h3>What it actually does (Finally)</h3><p>The core idea fits in one sentence: when GitHub says “a job is waiting,” spawn a fresh runner container; it does exactly one job and then destroys itself.</p><p>No idle runners. Nothing to babysit. When there’s no work, there are zero runner containers!</p><p><strong>Well, let’s talk business …</strong></p><p>It is worth noting that my Mac has no public address, so GitHub’s messages travel through a relay first. A safety net checks every thirty seconds for jobs whose messages got lost along the way. A reaper wanders through every five minutes, burying dead containers that refuse to admit they’re dead. And there’s a small dashboard, because of course there is.</p><p>That was the idea, and a rough version worked almost immediately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*gVBmu6ndikH_9tqwN8ccpA.jpeg" /></figure><p>Getting to a version I trusted enough to leave alone overnight was where the real lessons began.</p><h3>Lessons learned</h3><p><strong>Our day-to-day tooling is not as reliable as we think.</strong></p><p>Docker Desktop on macOS sometimes keeps reporting a container as running long after it has died. My runner counter believed Docker, decided the repo was at capacity, and refused to spawn anything. <strong>Forever.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*NtwJBl8mpFbFiVNtw7YyuQ.gif" /></figure><p>Now I ask each container directly instead of trusting the list.</p><p><strong>And the truth shall set you free.</strong></p><p>Two messages arriving together can expose a race condition. Two jobs were queued at the same moment; each handler read “there’s room for one more” and launched a runner. My “maximum three runners” guideline functioned more as a suggestion until verification and spawning merged into a single atomic step.</p><p><strong>Secrets have a way of getting out.</strong></p><p>My first version handed the GitHub token to Docker in the obvious way, which also happens to be the way that leaves it visible in process lists and shell history.</p><p>Forever. (Not really, but it sounds more dramatic.)</p><h3>Is that it?</h3><p><strong><em>Almost.</em></strong></p><p>My most-used feature isn’t the clever part. It’s the pause button. Before restarting Docker or deploying a new build, I pause, do what I want to do, and resume.</p><p>Please let’s not forget that <strong>good automation rarely needs you, but when it does, it should step aside gracefully.</strong></p><h3>Why should you care?</h3><p>We’ve all been there, running into a free limit, a quota, or a budget wall. It’s natural to think paying is the fix, but it’s worth asking: do you really need to spend anything at all?</p><p>Sometimes the answer really is “pay for ARC.” But sometimes the answer is some perfectly capable machines already sitting idle around your house, plus a weekend, plus the willingness to find out how many of your own assumptions were wrong.</p><p><strong>The code is public at </strong><a href="https://github.com/hrayatnia/autoscaler"><strong>github.com/hrayatnia/autoscaler</strong></a><strong>.</strong></p><h3>Appendix: Feature list</h3><ul><li><strong>Scale-to-zero, ephemeral runners:</strong> one fresh container per job; it does exactly one job and destroys itself. No runners idling between jobs.</li><li><strong>Webhook-driven, no public ingress:</strong> GitHub’s events arrive through a <a href="https://smee.io/">smee.io</a> relay over an outbound connection, so a home machine behind NAT works fine.</li><li><strong>Per-repo concurrency caps:</strong> one bursty repo can’t starve the others, and the cap actually holds under concurrent bursts.</li><li><strong>Reconcile loop:</strong> every 30 seconds, a safety net picks up queued jobs whose webhook never arrived.</li><li><strong>Ghost-runner reaping:</strong> every 5 minutes, dead containers and stale GitHub registrations get buried, even the ones Docker swears are still alive.</li><li><strong>Operator dashboard:</strong> a small local page with live state and a pause/resume button for maintenance windows.</li><li><strong>Security hardening:</strong> the GitHub token never appears in process lists or shell history, secrets are redacted from logs, and the dashboard is loopback-only.</li><li><strong>One Go binary:</strong> under 50 MB of RAM, MIT licensed.</li></ul><p><strong>Disclaimer:</strong> This is a self-managed, MIT-licensed solution, provided as-is with no warranty and no SLA. Software like this can expose your machine to compromise in many ways, including but not limited to: untrusted workflow code running on your hardware, a malicious pull request from a contributor you shouldn’t have trusted, or a poisoned third-party action pulled in as a dependency. Use it only for private repositories with contributors you trust. Never use it with a public repository where any stranger can open a pull request; GitHub itself warns against exactly this. If your threat model includes people you don’t trust pushing code, use GitHub-hosted runners (they’re free for public repositories). That’s what they’re for.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ba8a15567e1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A simple way to separate test types in iOS, Part 1]]></title>
            <link>https://medium.com/@rayatnia/a-simple-way-to-separate-test-types-in-ios-part-1-df92afbd843b?source=rss-6a81a59e56c8------2</link>
            <guid isPermaLink="false">https://medium.com/p/df92afbd843b</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[test-automation]]></category>
            <dc:creator><![CDATA[Sam Rayatnia]]></dc:creator>
            <pubDate>Fri, 02 Dec 2022 08:34:20 GMT</pubDate>
            <atom:updated>2022-12-02T08:34:20.702Z</atom:updated>
            <content:encoded><![CDATA[<p>testing software was always crucial in terms of reliability and expansion in business, and client services are no exception. in fact, testing client services has many aspects that you usually face only sometimes for business logic services. In this article, I will suggest a simple way to have a ready-to-go separation package for your test runner in iOS with swift. Please note that you shouldn&#39;t expect an advanced package for testing but just a convenient way to overcome multi-type test problems on daily bases.</p><h4><strong>Overview</strong></h4><p>to separate test types and modules in iOS; a couple of ways always are in use by developers. Either you can separate targets or define a flag (run-time or predefined flag) to make sure the border between your test strategies are well defined. Like every single other development problem, there&#39;re downsides and upsides to these solutions as well. Here are some pros and cons of each one of those.</p><p><strong>Multi-target test components</strong></p><p><strong><em>pros</em></strong><em>:</em></p><ul><li>Lesser build time due to fewer files and less dependency.</li><li>No more mess during development for file organization.</li><li>Easier usage through FastLane or any other automation tool.</li><li>A better dependency separation for test components.</li></ul><p><strong><em>Cons</em></strong><em>:</em></p><ul><li>A good possibility of repeating yourself in a single-module application.</li><li>High setup time for multi-component applications.</li><li>Too much effort goes into making it a standard.</li></ul><p><strong>Multi-flag testing strategy</strong></p><p><strong><em>pros:</em></strong></p><ul><li>Ready-to-go separation for test modules (with run-time flag).</li><li>Less possibility of repeating yourself in a single-module application.</li><li>Not that hard to make CI/CD friendly.</li></ul><p><strong><em>Cons:</em></strong></p><ul><li>Too many files to build for single-module applications.</li><li>it can get messy if the developer follows the correct group approach in single-module applications.</li><li>Too many modules will get imported into one target in single-module applications.</li></ul><p>And for sure, always, there&#39;s a hybrid solution for the problem to balance the pros and cons regarding the project structure.</p><h3><strong>Method</strong></h3><p>in part 1, we will go through the run-time approach to create a simple util module for test separation. The most common test components for client services are <strong>unit tests, UI tests, screenshot tests, chaos/monkey tests, and integration tests</strong>. We can define these test-type flags however we desire, but for the sake of article, I will make it an enum.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7ebf488fa7f1de90b219589630e7c86b/href">https://medium.com/media/7ebf488fa7f1de90b219589630e7c86b/href</a></iframe><p>To be more CI/CD friendly, we have to get those flags from a file or obtain them by processing environment variables. We must store flags to run multi-part components based on branch requirements. The easiest way to achieve such storage is by using a static variable.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f29d8cde57cb4d909a0d896c17c4b5cc/href">https://medium.com/media/f29d8cde57cb4d909a0d896c17c4b5cc/href</a></iframe><p>We need to have the flag as a property of our testing class to decide whether to skip or do the test.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50ade3b49786406a064bc35dbe76827f/href">https://medium.com/media/50ade3b49786406a064bc35dbe76827f/href</a></iframe><p>And by having the flag, we can distinguish our test classes.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ee70e5e374235251182772916f4023f9/href">https://medium.com/media/ee70e5e374235251182772916f4023f9/href</a></iframe><p>The rest of it is just the definition types you need.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42198b1001523aa282d2f92d874c8248/href">https://medium.com/media/42198b1001523aa282d2f92d874c8248/href</a></iframe><h3><strong>Conclusion</strong></h3><p>This article&#39;s following parts will discuss the multi-target approach and CI/CD configuration.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df92afbd843b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>