Running a selfhosted Github runner on a PinePhone

Tuesday, October 19, 2021

The PinePhone

The PinePhone from Pine64 is a Linux mobile phone running mainstream kernel and open source software. It’s supported by many Linux distributions like Manjaro, UbuntuTouch, SailfishOS, PostmarketOS, Mobian many many more . It provides nice features like privacy switches and is extensible thanks to pogo pins on the back of the phone.

But the PinePhone is not a simple mobile phone : it’s a full-blown AARCH64 computer running on Linux! You can do whatever you want with your phone : install the OS of your choice, install any applications you like, use the terminal, SSH into it and basically use it as any other Linux computer!

So far, I’ve already had a lot of fun distro-hopping across many distributions (ArchLinux and Manjaro are still my favorites), testing both Phosh and KDE Plasma, and experimenting with the Convergence mode, allowing you to use your PinePhone like a desktop computer thanks to a USB-C hub (that provides HDMI output). I also use the phone to test companion apps for InfiniTime like Amazfish and Siglo .

Github Actions

Regarding InfiniTime, we are working on improving the CI (based on Github Actions), and one of our plans is to use the docker container we use to build the project inside the Github Action workflow . While reading about this, I noticed that Github supports self-hosted runners.

Let’s take an example : when a pull-request is created on the InfiniTime project, a build workflow is automatically started. It builds the code from the pull-request as a pre-check for the PR. It helps the contributors and the maintainer by detecting eventual compilation errors. It can also be used to run unit tests, for example.

By default, this build is executed in a virtual machine hosted by Github. Github allows free user to use its infrastructure for their workflow with some limitation (it’s limited by the number of minutes by month, for example). That’s fine for InfiniTime, the project is very far from reaching those limitations.

Anyway, Github also allows project maintainers to run the Github runner (the application that handles the whole workflow automatically) on their own computer, server, cloud instance,… It allows, for example, to overcome those limitations, run test on a specific hardware or infrastructure, build on specific architectures (like ARM and AARCH64).

And then I got the idea : it would be fun to run such a runner on the PinePhone! Why? because I can!

Running a self-hosted runner on the PinePhone…

… or any AARCH64, ARM or X86 computer, really! But it’s even more fun on the PinePhone, so let’s do it!

First, go into your project settings and then into the Action/Runner menu and click on the button New self hosted runner on the top right.

Create a new ARM64 Linux runner

Select Linux and ARM64, and then follow the instructions listed on that page. You simply have to run those commands in a terminal!

Github runner is running on the PinePhone

When your runner is running and waiting for a job, all you have to do is slightly modify your workflow YAML file to force the workflow to run on a selfhosted runner : change the runs-on entry from the current value (maybe ubuntu) to self-hosted:

Edit the workflow YML file

Then commit and push the changes. In InfiniTime, you have to create a pull request to actually trigger the workflow. Here’s mine : https://github.com/InfiniTimeOrg/InfiniTime/pull/762

Now comes the tricky part : the build runs natively on the system, and expects a few tools and libraries to be installed and available like an ARM toolchain, git, CMake,… I had to restart the workflow a few times to ensure that all the dependencies were correctly installed.

The pinephone running its first workflow

After a few trials and error, finally, the build succeeded!

How cool is that?!

That’s it, it works! You can use your favorite Linux mobile phone to build your favorite smartwatch firmware!

Is it a good idea? Maybe not! Is it fast? Absolutely not! Is it cool? Hell yeah!

Success!

Pine64devGitHubpinephone

JF

I am passionate about IT, (embedded) software development and open source technologies in general. I’m mainly working on the InfiniTime project, an open source firmware for the PineTime smartwatch from Pine64.

Let's plug an additional NIC on the Quartz64 !

Discovering the Pine64 LoRa gateway