[Initiatives.wiki] Update DevOps with Flatpak
- From: Carlos Soriano <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [Initiatives.wiki] Update DevOps with Flatpak
- Date: Mon, 10 Dec 2018 13:58:10 +0000 (UTC)
commit 520e341bad6df5576b107ef50598fb375805bf17
Author: Carlos Soriano <csoriano1618 gmail com>
Date: Mon Dec 10 13:58:06 2018 +0000
Update DevOps with Flatpak
DevOps-with-Flatpak.md | 140 ++++++++++++-------------------------------------
1 file changed, 34 insertions(+), 106 deletions(-)
---
diff --git a/DevOps-with-Flatpak.md b/DevOps-with-Flatpak.md
index ce2626a..65e34ea 100644
--- a/DevOps-with-Flatpak.md
+++ b/DevOps-with-Flatpak.md
@@ -1,36 +1,38 @@
# Flatpak CI
-### Basic building with CI
+### Requirements
+- Meson. Feel free to adapt to Autotools or other build system, however we rely on Meson for the templates.
+- GtkApplication/GApplication based. So it's possible to have different app-ids.
-The main goal here is to make sure our CI runs for every commit and MR and the project is buildable using
the same base across GNOME, the Flatpak env.
+### Basic CI
-1. Create a .gitlab-ci.yml file in the git repository. This file will contain the instructions for CI.
-1. Add the template we provide
-1. Build with flatpak
-1. Run the tests, including those that require a display using the mock tool
[xvfb-run](http://manpages.ubuntu.com/manpages/xenial/man1/xvfb-run.1.html).
+The main goal here is to make sure our CI runs for every commit and MR and the project is buildable using
the same base across GNOME, the Flatpak env.
-For that, use the following template and replace the variables with the appropriate values.
+For that, use the following template and replace the variables with the appropriate variables for your
project.
```yaml
-stages:
-- test
+include: 'https://gitlab.gnome.org/GNOME/citemplates/raw/master/flatpak/flatpak_ci_initiative.yml'
+
+variables:
+ BUNDLE: "nautilus-dev.flatpak"
flatpak:
- stage: test
+ image: 'registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master'
variables:
MANIFEST_PATH: "build-aux/flatpak/org.gnome.NautilusDevel.yml"
- MESON_ARGS: "-Dprofile=Devel -Dtests=all"
+ MESON_ARGS: "-Dprofile=development"
FLATPAK_MODULE: "nautilus"
RUNTIME_REPO: "https://sdk.gnome.org/gnome-nightly.flatpakrepo"
APP_ID: "org.gnome.NautilusDevel"
extends: .flatpak
- only:
- - schedules
- - web
- - tags
```
+The template will do the following:
+1. Build with `meson build` inside a [nightly
Flatpak](registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master) environment.
+1. Install with `ninja install` in /app prefix.
+1. Run tests with `ninja test` with a
[xvfb-run](http://manpages.ubuntu.com/manpages/xenial/man1/xvfb-run.1.html) mocked display inside a Flatpak
environment. The mocked display has a resolution of 1024x768.
+
### Flatpak bundle for every MR and commit
-The main goal is to create flatpak bundles so people can install them.
+The main goal is to create Flatpak bundles so people can install and run them.
1. Create a Flatpak package/bundle and export it
1. Create a GitLab artifact to save the generated bundle for two days
@@ -46,120 +48,46 @@ Add the following to the CI file:
review:
stage: deploy
dependencies:
- - 'flatpak devel'
+ - 'flatpak'
extends: '.review'
stop_review:
stage: deploy
extends: '.stop_review'
-
-```
-And on the `stages` section, add a "review" stage. The result of the stage section will be:
-```yaml
-stages:
- - test
- - deploy
```
+The template will create a Flatpak bundle with `flatpak build-bundle` and the runtime pointing to the value
of RUNTIME_REPO variable. Once the deploy is done you will see a play button in the MR that will download the
generated Flatpak bundle.
### Saving build and test logs & cache builds
-If the CI fails, we need a way to retrieve the logs. For this we use the artifacts tool of GitLab too. We
add the following in the artifacts section:
-```yaml
-- _build/meson-logs/meson-log.txt
-- _build/meson-logs/testlog.txt
-```
-And we also want to be speed up builds, so we [cache](https://docs.gitlab.com/ce/ci/caching/) the Flatpak
build by adding a cache path.
-```yaml
-cache:
- paths:
- - .flatpak-builder/downloads
- - .flatpak-builder/git
-```
+If the CI fails, we need a way to retrieve the logs. For this we use the artifacts tool of GitLab too. The
provided template exports the meson-logs.txt and the testlog.txt files as part of the artifacts.
### Final gitlab-yaml file template
Here is the resulting template, but it is recommended to try doing it step-by-step.
```yaml
-stages:
-- test
-- review
+include: 'https://gitlab.gnome.org/GNOME/citemplates/raw/master/flatpak/flatpak_ci_initiative.yml'
variables:
- # Replace with your preferred file name of the resulting Flatpak bundle
- BUNDLE: "app-name.flatpak"
- GIT_SUBMODULE_STRATEGY: normal
+ BUNDLE: "nautilus-dev.flatpak"
flatpak:
- image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master
- stage: test
+ image: 'registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:master'
variables:
- # Replace with your manifest path
- MANIFEST_PATH: "build-aux/flatpak/org.gnome.AppName.json"
+ MANIFEST_PATH: "build-aux/flatpak/org.gnome.NautilusDevel.yml"
+ MESON_ARGS: "-Dprofile=development"
+ FLATPAK_MODULE: "nautilus"
RUNTIME_REPO: "https://sdk.gnome.org/gnome-nightly.flatpakrepo"
- # Replace with your application name, as written in the manifest
- FLATPAK_MODULE: "app-name"
- # Make sure to keep this in sync with the Flatpak manifest, all arguments
- # are passed except the config-args because we build it ourselves
- CONFIGURE_ARGS: "-Dtests=all"
- DBUS_ID: "org.gnome.AppName"
-
- script:
- - flatpak-builder --stop-at=${FLATPAK_MODULE} app ${MANIFEST_PATH}
- # Make sure to keep this in sync with the Flatpak manifest, all arguments
- # are passed except the config-args because we build it ourselves
- - flatpak build app meson --prefix=/app ${CONFIGURE_ARGS} _build
- - flatpak build app ninja -C _build install
- - flatpak-builder --finish-only --repo=repo app ${MANIFEST_PATH}
- # Run automatic tests inside the Flatpak env
- - xvfb-run -a -s "-screen 0 1024x768x24" flatpak build app ninja -C _build test
- # Generate a Flatpak bundle
- - flatpak build-bundle repo ${BUNDLE} --runtime-repo=${RUNTIME_REPO} ${DBUS_ID}
-
- artifacts:
- paths:
- - ${BUNDLE}
- - _build/meson-logs/meson-log.txt
- - _build/meson-logs/testlog.txt
- expire_in: 2 days
- cache:
- paths:
- - .flatpak-builder/downloads
- - .flatpak-builder/git
+ APP_ID: "org.gnome.NautilusDevel"
+ extends: .flatpak
review:
- stage: review
+ stage: deploy
dependencies:
- - flatpak
- script:
- - echo "Generating flatpak deployment"
- artifacts:
- paths:
- - ${BUNDLE}
- expire_in: 30 days
- environment:
- name: review/$CI_COMMIT_REF_NAME
- url: https://gitlab.gnome.org/$CI_PROJECT_PATH/-/jobs/$CI_JOB_ID/artifacts/raw/${BUNDLE}
- on_stop: stop_review
- except:
- - tags
- # don't run on stable branches
- - /^gnome-\d-\d\d$/
- # No need to run on the upstream master branch either
- - master@GNOME/project-url
+ - 'flatpak'
+ extends: '.review'
stop_review:
- stage: review
- script:
- - echo "Stopping flatpak deployment"
- when: manual
- environment:
- name: review/$CI_COMMIT_REF_NAME
- action: stop
- except:
- - tags
- # don't run on stable branches
- - /^gnome-\d-\d\d$/
- # No need to run on the upstream master branch either
- - master@GNOME/project-url
+ stage: deploy
+ extends: '.stop_review'
```
# Parallel installation
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]