Proposing Flatpak CI builds and Adding script
Edit (May 28, 2022) : This description is probably not accurate anymore, considering the many changes this merge request went through.
Background
During Season of KDE 2022, I took up the task of improving Flatpak related stuff for KDE. One of the goals is to introduce Flatpak CI builds for KDE applications.
The intention of this merge request is to share my work with the CI sysadmin folks, get reviews and eventually, have this merged.
Short description
Currently, we have CI builds for FreeBSD and OpenSuse on most repositories that run on every merge request and push. But such an arrangement does not exist for Flatpak. With more and more KDE applications being published to Flathub, having Flatpak CI buids on KDE Invent will let project maintainers spot issues quicker and fix them before the Flatpak packaging team updates applications on Flathub, thus reducing surprises when packaging.
Solution
Add Flatpak CI :)
I would propose having Flatpak CI builds on every push and merge request, quite similar to the way we have it for other platforms right now.
I have worked on a small script that will build and install application. This script will be run as a part of GitLab Pipelines.
To start off, my script is housed on GitLab account for now. https://gitlab.com/flyingcakes/ci-script
The files of interest are deps-build-v2.yml
and deps-build-v2
which correspond to gitlab-templates/flatpak.yml
and flatpak-build.py
respectively in this merge request.
Getting this on KDE Invent
The inclusion will have to be done in three steps.
- First we will have to add the Flatpak container on the CI Images repo. The Dockerfile for my container is on my GitHub repository : flyingcakes85/fedora-flatpak-docker
- Next, we add the GitLab CI file to CI Utilities repo, i.e. this merge request
- Finally, applications that want to enable Flatpak CI builds will have to add a short snippet to their
.gitlab-ci.yml
file. (Described later in this merge request)
As an initial test run, I suggest we add the to a limited number of applications, to see how it fares in real world usage. During this time, I can update the script to get around any issues we discover. Later on when the script is mature enough, we can have it in wider selection of applications.
More about my script
This information is lifted off of the readme I put up on the GitLab repository. The preparation step in this merge request slightly differs from the one on my GitLab, but script logic is same.
Using
To use this in your KDE application, follow these steps
- Ensure the Flatpak manifest for your application is there on Flatpak KDE Applications repo. Manifests may be Remote app, JSON or YAML file.
- Add the following include in your application repository's
.gitlab-ci.yml
include: 'https://gitlab.com/flyingcakes/ci-script/-/raw/main/deps-build-v2.yml'
PS. This include link will refer to this repo once this merge request is accepted.
- Add this block in your application repository's
.gitlab-ci.yml
flatpak:
extends: '.flatpak'
variables:
FILE_NAME: org.kde.filename
MODULE_NAME: module
APP_ID: org.kde.appid
FILE_NAME
is to be set to the name of file of your application's manifest in Flatpak KDE Applications repo. Make sure to add the right extension. Eg.
FILE_NAME: org.kde.kdiff3.json
MODULE_NAME
is the name of your application's module in the manifest. Eg.
MODULE_NAME: kdiff3
APP_ID
is the name with which your application bundle will be created post successful build. Eg
APP_ID: org.kde.kdiff3
Deployments
To test this script, I have deployed it on these repositories
- KDiff3
- Link : https://gitlab.com/flyingcakes/kdiff
- Manifest type : JSON
- Job Run : https://gitlab.com/flyingcakes/kdiff/-/jobs/2303422756
- Kronometer
- Link : https://gitlab.com/flyingcakes/kronometer
- Manifest type : Remote Application
- Job Run : https://gitlab.com/flyingcakes/kronometer/-/jobs/2302628576
Working
- The entry point is in
gitlab-templates/flatpak.yml
. It starts a docker container and fetches the KDE CI utilities repository. - The python script takes over to build the application.
- First it checks if the manifest is a remote application. In that case, it updates
manifestfile
location accordingly. (We assume that the remote GITURL points to the application source code, so we don't fetch the repository again). If manifest is a JSON or YAML file, this step is skipped. - Next, the manifest is edited to use local directory as the build source. (rather than the git repository on website)
- Application is now built. After successful build, python script exits.
- Back in
gitlab-templates/flatpak.yml
, it prepares artifacts and uploads it. These artifacts can be downloaded by maintainers to test the application.
CC @ravier