Some hurdles of Github Actions 🐱‍👤
Tags: github, devops, testing
Published: 2020-01-10 14:54:39

  [Github Actions][github_actions] is the new kid around the block for workflow automation. DevOps guys are having the day for it, as it makes a heck of a lot easier for them to implement CI/CD 🔥 from the same place they host their project.

  Last month, I worked on setting up a workflow for building a deployment pipeline. The project that I’m part of, is a desktop application 🖥 built on *[Electron][electronjs]*.

You might be thinking 🤔, why build a desktop app on Github’s Actions? Because the build process is quite cumbersome and take a pretty big chunk of the developers precious time 😒. As we were already planning to build a CI/CD pipeline, we thought to give it a try with Github Actions 😁 (as we already host our project on Github privately).

**Disclaimer:** This post applies to Github’s Linux and Windows runners, as I have tested on those. Although Mac OS runner isn’t much different then the Linux runner. You can find more about them [HERE][github_actions_runner].

---

### Testing the workflow locally

![Gif installing software in commandline][test-gif]

  When I'm trying out something new 🐱‍🏍, the first thing I try is to set up a local environment to test it out 🧗‍♂️. Can it be done for Github Actions? The answer is not definitive 🤔. We can use our own Docker Image as a custom runner, and test it locally on that local Docker Image. We can’t create the exact environment to mock the workflow, at least I couldn’t find any solution.

---

### Complex processes

![Gif Complex Process][complex-gif]

  Setting up a YAML configuration for projects that already use some kind of framework, or has a rich set of build tools is really easy ✌. But when we are writing configuration for an application where the build 🏭 requires multiple process, with sources from different languages and frameworks, it kinda becomes messy to keep track of the process flow. Sure you can divide the processes into **“Jobs”** but that has its own pitfall 👎, which I’ll talk about later in this post.

---

### Actions from Marketplace

![Github Marketplace][marketplace-gif]

  On the Github Marketplace, there are quite a lot of [actions][marketplace-actions] written by other developers 👩‍💻. These actions can be written in two ways, using **Docker configuration** or using **JavaScript**. While **JavaScript actions** run on all platforms, actions written in **Docker configuration** can only run on Linux. So, we might find some action that cuts down your task into half, but still can’t use it, only because we are using Non-Linux runner.

---

### Data persistence on a workflow

![Data Persistance][storage-gif]

  In a complex build 🏭 process, you may want to pass some information from one job to another, to build a flow. The only way to pass data in-between jobs, is to use [Github Artifacts][github-artifacts]. They aren’t cheap either. You can’t delete an artifact manually 😲. GitHub stores artifacts for *90 days for pushes and pull requests*. Storing artifacts uses storage space on GitHub. Also, for private repositories like ours, there is a fixed amount of “Free Minutes” and “Storage” after which it will start billing 💵. One good thing is that files uploaded as artifacts are compressed as “zip”. So, if you are uploading log files or reports, you may not need to think about the storage, at least 😌.

---

### Limited flexibility for Actions

![Limited Flexibility][flexibility-gif]

  One particular problem I faced 🤨 while using an action from marketplace is that, we can’t set `working-directory` when executing them. That means, those actions must always be executed from the root directory 😬. This won’t matter if we are building a single project. But if it’s a [monorepo][monorepo], then the actions won’t work if it doesn’t accept the directory path as parameter. In my case, the action accepted a directory path, so I was saved somehow 😌.

That’s it for today folks. See you, when I see you 🐱‍👤.

Cover Image Credit: [kaleidico](https://unsplash.com/@kaleidico)

[github_actions]: https://github.com/features/actions
[electronjs]: https://electronjs.org/
[github_actions_runner]: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/virtual-environments-for-github-hosted-runners
[marketplace-actions]: https://github.com/marketplace?type=actions
[github-artifacts]: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/persisting-workflow-data-using-artifacts
[monorepo]: https://en.wikipedia.org/wiki/Monorepo
[test-gif]: https://i.imgur.com/TzeAw5B.gif
[complex-gif]: https://complex-res.cloudinary.com/image/upload/c_limit,fl_progressive,q_80,w_1100/xqfljrzvoslzgmtaapp4
[marketplace-gif]: https://67.media.tumblr.com/a50c8c395cb9ff4b872f69faf2ed658f/tumblr_nxzhnzV9Rx1qdqyxho2_500.gif
[storage-gif]: http://s3.amazonaws.com/draw.heroku.com/77bf1eb754b580d7b5d126a6b9396fa2922001d6.gif
[flexibility-gif]: http://www.reactiongifs.com/wp-content/uploads/2012/09/smh-kid.gif