Draft: Proposing Flatpak CI builds and Adding script
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.
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.
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 which correspond to
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.ymlfile. (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.
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
PS. This include link will refer to this repo once this merge request is accepted.
- Add this block in your application repository's
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.
MODULE_NAME is the name of your application's module in the manifest. Eg.
APP_ID is the name with which your application bundle will be created post successful build. Eg
To test this script, I have deployed it on these repositories
- Link : https://gitlab.com/flyingcakes/kdiff
- Manifest type : JSON
- Job Run : https://gitlab.com/flyingcakes/kdiff/-/jobs/2303422756
- Link : https://gitlab.com/flyingcakes/kronometer
- Manifest type : Remote Application
- Job Run : https://gitlab.com/flyingcakes/kronometer/-/jobs/2302628576
- 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
manifestfilelocation 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.