In a moment of wild excitement for CI changes at my workplace, I decided to fix up the CI/CD for the repository I use for Enlightenment live packages.

Introduction

A long time ago, I used Travis. After the countless changes they have gone trough, my setup was not working any more. So I decided to move to GitHub Actions.

Gentoo provides a series of tools to check and validate ebuilds. The most common one, used until recently, is Repoman.

Repoman has been deprecated in 2022 (See commit c2c0b163b73c53d8aa65ed6403bdf8f116ef45b8). Before that, it the was used to verify that an overlay had no errors. So at the beginning, I went with this tool. After a first implementation with Repoman, I started implementing checks with pkgcheck. More to come in a week or two.

Design

The idea was to set up have a Docker image with Gentoo already set up. So that every time a change is pushed to the remote, we can sin it up, install repoman and run it.

CI%20flow

Gentoo Docker Image

So, a basic Gentoo docker image is present here: Docker image It is very simple. I thought of adding repoman here as well, but I wanted to have more control over the latest versions. So, in the end, I opted for installing the packages when running the GitHub action.

 FROM gentoo/portage:latest as portage
 # based on stage3 image
 FROM gentoo/stage3:latest

 # copy the entire portage volume in
 COPY --from=portage /var/db/repos/gentoo /var/db/repos/gentoo

GitHub Action

Writing a GitHub action is quite straightforward. Plenty of documentation available on this topic.

You specify the input you want to accept and the command you want to run.

The only thing worth nothing is that I wanted to make sure the image I am building for this action can actually run.

So, I specified some action to take when working on my action ( :

> cat .github/workflows/ci.yml

name: 'CI check'
on: [push, pull_request]
jobs:
     shellcheck:
         name: 'Shellcheck'
         runs-on: ubuntu-latest
         steps:
             - name: 'Check out the code'
               uses: actions/checkout@v1
             - name: 'Run Shellcheck'
               uses: azohra/shell-linter@v0.6.0
               with:
                 exclude-paths: "LICENSE,Dockerfile"
     docker_checker:
         name: 'Docker Sanity checker'
         runs-on: ubuntu-latest
         steps:
             - name: 'Check out the code'
               uses: actions/checkout@v1

             - name: 'Build docker image'
               uses: docker/build-push-action@v2
               with:
                 tags: repoman-repo-qa:latest
                 push: false

             - name: 'Run command inside the docker container'
               env:
                   INPUT_GENTOO_REPO: /tmp
                   INPUT_PORTAGE_VERSION: latest
                   INPUT_PROFILE: latest
                   INPUT_PATH: /tmp
                   INPUT_REPOMAN_ARGS: -p
               uses: addnab/docker-run-action@v3
               with:
                 image: repoman-repo-qa:latest
                 options: --env INPUT_REPOMAN_ARGS=-p --env INPUT_GENTOO_REPO=/usr/portage --env INPUT_PORTAGE_VERSION=latest --env INPUT_PROFILE=latest --env INPUT_PATH=/tmp
                 run: repoman --version

So, there is the code of the GitHub action: GitHub action

Implementation

In any gentoo overlay repository, the only change you need to make in order to automatically run repoman against your overlay is to add one file

.github/workflows/repoman.yml

name: 'QA check with repoman'
on: [push, pull_request]
jobs:
    repoman:
        runs-on: ubuntu-latest
        steps:
            - uses: actions/checkout@v2
            - uses: rafspiny/repoman-repo-qa@v2.1

You can see one example here: https://github.com/rafspiny/enlightenment-live/blob/master/.github/workflows/repoman.yml

Next Post Previous Post