Browse Source

ci: Don't build unnecessary Flatpak modules when they are not needed

merge-requests/2003/merge
Kévin Commaille 11 months ago
parent
commit
d161a58424
No known key found for this signature in database
GPG Key ID: F26F4BE20A08255B
  1. 4
      .gitlab-ci/run_checks.yml
  2. 22
      .gitlab-ci/test.yml
  3. 16
      .gitlab-ci/utils.yml
  4. 10
      meson.build
  5. 1
      meson.options
  6. 8
      src/meson.build

4
.gitlab-ci/run_checks.yml

@ -1,5 +1,7 @@
# Configure and run code checks # Configure and run code checks
include: '.gitlab-ci/utils.yml'
# Custom checks and lints # Custom checks and lints
checks: checks:
stage: check stage: check
@ -9,6 +11,8 @@ checks:
# Lint the code # Lint the code
cargo-clippy: cargo-clippy:
extends:
- .remove_build_only_modules
stage: check stage: check
image: 'quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master' image: 'quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master'
tags: tags:

22
.gitlab-ci/test.yml

@ -1,5 +1,7 @@
# Tests after the app is built. # Tests after the app is built.
include: '.gitlab-ci/utils.yml'
# Validate the metainfo with Flathub's tool. # Validate the metainfo with Flathub's tool.
lint-metainfo: lint-metainfo:
stage: test stage: test
@ -17,17 +19,23 @@ lint-metainfo:
# Run the Rust tests. # Run the Rust tests.
rust-tests: rust-tests:
extends:
- .remove_build_only_modules
stage: test stage: test
image: 'quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master' image: 'quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master'
tags: tags:
- flatpak - flatpak
variables:
TMP_MANIFEST_PATH: "build-aux/org.gnome.Fractal.CiRust.json"
script: script:
# Add a module for nextest to the Flatpak manifest # Create a temporary file.
- jq --slurpfile nextest .gitlab-ci/nextest.module.json '.modules = [$nextest[], .modules[]]' ${MANIFEST_PATH} > ${TMP_MANIFEST_PATH} - TMP_FILE=$(mktemp)
- flatpak-builder --keep-build-dirs --user --disable-rofiles-fuse --stop-at=${FLATPAK_MODULE} flatpak_app --repo=repo ${BRANCH:+--default-branch=$BRANCH} ${TMP_MANIFEST_PATH} # Add a module for nextest to the Flatpak manifest and write it to the temporary file.
- echo "cargo-nextest nextest run --config-file ../.gitlab-ci/nextest.toml" | flatpak-builder --disable-rofiles-fuse --build-shell=${FLATPAK_MODULE} flatpak_app ${TMP_MANIFEST_PATH} - jq --slurpfile nextest .gitlab-ci/nextest.module.json '.modules = [$nextest[], .modules[]]' ${MANIFEST_PATH} > ${TMP_FILE}
# Replace the manifest with the temporary file.
- mv $TMP_FILE ${MANIFEST_PATH}
# Initialize the Flatpak sandbox.
- flatpak-builder --keep-build-dirs --user --disable-rofiles-fuse --stop-at=${FLATPAK_MODULE} flatpak_app --repo=repo ${BRANCH:+--default-branch=$BRANCH} ${MANIFEST_PATH}
# Run the tests.
- echo "cargo-nextest nextest run --config-file ../.gitlab-ci/nextest.toml" | flatpak-builder --disable-rofiles-fuse --build-shell=${FLATPAK_MODULE} flatpak_app ${MANIFEST_PATH}
dependencies: [] dependencies: []
artifacts: artifacts:
reports: reports:
@ -35,6 +43,8 @@ rust-tests:
# Test that there are no errors in the docs. # Test that there are no errors in the docs.
build-docs: build-docs:
extends:
- .remove_build_only_modules
stage: test stage: test
image: 'quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master' image: 'quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master'
tags: tags:

16
.gitlab-ci/utils.yml

@ -0,0 +1,16 @@
# Utilities to include in other jobs.
# Remove the Flatpak modules that are only necessary when building the app with meson.
.remove_build_only_modules:
variables:
# JSON array of the names of the Flatpak modules to remove.
MODULES_TO_REMOVE: '["grass", "glycin-loaders"]'
before_script:
# Create a temporary file.
- TMP_FILE=$(mktemp)
# Remove the modules in the manifest and write the output to the temporary file.
- jq --argjson modules_to_remove "${MODULES_TO_REMOVE}" 'del(.modules[] | select(IN(.name; $modules_to_remove | .[])))' ${MANIFEST_PATH} > $TMP_FILE
# Replace the manifest with the temporary file.
- mv $TMP_FILE ${MANIFEST_PATH}
# Use meson's build-env profile.
- sed -i "s|-Dprofile=development|-Dprofile=build-env|g" ${MANIFEST_PATH}

10
meson.build

@ -66,7 +66,12 @@ iconsdir = datadir / 'icons'
podir = meson.project_source_root() / 'po' podir = meson.project_source_root() / 'po'
gettext_package = meson.project_name() gettext_package = meson.project_name()
if get_option('profile') == 'development' # When the `build-env` profile is used, we only want to set up the build
# environment for the sandbox, we will not try to compile the app, so we can
# remove some build steps.
build_env_only = get_option('profile') == 'build-env'
if get_option('profile') == 'development' or build_env_only
profile = 'Devel' profile = 'Devel'
application_id += '.Devel' application_id += '.Devel'
elif get_option('profile') == 'hack' elif get_option('profile') == 'hack'
@ -94,8 +99,11 @@ if profile == 'Devel'
run_command('cp', '-f', 'hooks/pre-commit.hook', '.git/hooks/pre-commit') run_command('cp', '-f', 'hooks/pre-commit.hook', '.git/hooks/pre-commit')
endif endif
if not build_env_only
subdir('data') subdir('data')
subdir('po') subdir('po')
endif
subdir('src') subdir('src')
gnome.post_install( gnome.post_install(

1
meson.options

@ -6,6 +6,7 @@ option(
'beta', 'beta',
'development', 'development',
'hack', 'hack',
'build-env',
], ],
value: 'default', value: 'default',
description: 'The build profile for Fractal. One of "default", "beta", "development" or "hack".' description: 'The build profile for Fractal. One of "default", "beta", "development" or "hack".'

8
src/meson.build

@ -42,6 +42,12 @@ endif
cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ] cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ]
if build_env_only
depends = []
else
depends = [resources, ui_resources]
endif
custom_target( custom_target(
'cargo-build', 'cargo-build',
build_by_default: true, build_by_default: true,
@ -50,7 +56,7 @@ custom_target(
console: true, console: true,
install: true, install: true,
install_dir: bindir, install_dir: bindir,
depends: [resources, ui_resources], depends: depends,
command: [ command: [
'env', 'env',
cargo_env, cargo_env,

Loading…
Cancel
Save