diff --git a/.gitlab-ci/test.yml b/.gitlab-ci/test.yml index 28d2aecf..dc960afe 100644 --- a/.gitlab-ci/test.yml +++ b/.gitlab-ci/test.yml @@ -20,8 +20,6 @@ lint-metainfo: # Run the Rust tests. rust-tests: - extends: - - .remove_build_only_modules stage: test image: 'quay.io/gnome_infrastructure/gnome-runtime-images:gnome-master' tags: @@ -37,11 +35,11 @@ rust-tests: # 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} + - echo "meson compile src/cargo-test" | flatpak-builder --disable-rofiles-fuse --build-shell=${FLATPAK_MODULE} flatpak_app ${MANIFEST_PATH} dependencies: [] artifacts: reports: - junit: '.flatpak-builder/build/${FLATPAK_MODULE}/target/nextest/default/junit.xml' + junit: '.flatpak-builder/build/${FLATPAK_MODULE}/_flatpak_build/src/junit.xml' # Test that there are no errors in the docs. build-docs: @@ -62,8 +60,8 @@ build-docs: # Do not use the mold linker because it doesn't work with the rust-nightly extension at the moment - sed -i 's|-C link-arg=-fuse-ld=mold||g' ${MANIFEST_PATH} - flatpak-builder --keep-build-dirs --user --disable-rofiles-fuse --stop-at=${FLATPAK_MODULE} flatpak_app --repo=repo ${BRANCH:+--default-branch=$BRANCH} ${MANIFEST_PATH} - - echo "ninja src/doc" | flatpak-builder --disable-rofiles-fuse --build-shell=${FLATPAK_MODULE} flatpak_app ${MANIFEST_PATH} - - tar --auto-compress --create --file "${CI_PROJECT_DIR}/${CI_PROJECT_NAME}-docs.tar.gz" --directory ".flatpak-builder/build/${FLATPAK_MODULE}/_flatpak_build/cargo-target/doc" . + - echo "meson compile src/cargo-doc" | flatpak-builder --disable-rofiles-fuse --build-shell=${FLATPAK_MODULE} flatpak_app ${MANIFEST_PATH} + - tar --auto-compress --create --file "${CI_PROJECT_DIR}/${CI_PROJECT_NAME}-docs.tar.gz" --directory ".flatpak-builder/build/${FLATPAK_MODULE}/_flatpak_build/src/doc" . dependencies: [] artifacts: paths: diff --git a/meson.build b/meson.build index 62096485..18f2e8b7 100644 --- a/meson.build +++ b/meson.build @@ -3,7 +3,7 @@ project( 'rust', version: '13', license: 'GPL-3.0-or-later', - meson_version: '>= 1.2', + meson_version: '>= 1.4', ) fs = import('fs') @@ -112,6 +112,18 @@ if profile == 'Devel' run_command('cp', '-f', 'hooks/pre-commit.hook', '.git/hooks/pre-commit') endif +# Generate nextest config file +# We generate it dynamically to put the test report inside the build directory, +# like all other artefacts +nextest_store_dir = meson.project_build_root() / 'nextest' +nextest_data = configuration_data() +nextest_data.set_quoted('STORE_DIR', nextest_store_dir) +nextest_config = configure_file( + input: 'nextest.toml.in', + output: 'nextest.toml', + configuration: nextest_data, +) + if not build_env_only subdir('data') subdir('po') diff --git a/.gitlab-ci/nextest.toml b/nextest.toml.in similarity index 74% rename from .gitlab-ci/nextest.toml rename to nextest.toml.in index bdf488cd..e070eb3f 100644 --- a/.gitlab-ci/nextest.toml +++ b/nextest.toml.in @@ -1,3 +1,6 @@ +[store] +dir = @STORE_DIR@ + [profile.default] fail-fast = false diff --git a/src/meson.build b/src/meson.build index 16996404..42a321c9 100644 --- a/src/meson.build +++ b/src/meson.build @@ -87,9 +87,6 @@ run_command( # Cargo settings cargo_options = ['--manifest-path', meson.project_source_root() / 'Cargo.toml'] -target_dir = meson.project_build_root() / 'cargo-target' -cargo_options += ['--target-dir', target_dir] - if profile == 'Devel' rust_target = 'debug' message('Building in debug mode') @@ -99,7 +96,12 @@ else message('Building in release mode') endif -cargo_env = ['CARGO_HOME=' + meson.project_build_root() / 'cargo-home'] +cargo_target_dir = meson.project_build_root() / 'cargo-target' + +cargo_env = [ + 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home', + 'CARGO_TARGET_DIR=' + cargo_target_dir, +] if not build_env_only # Build binary with cargo @@ -120,7 +122,30 @@ if not build_env_only cargo_options, '&&', 'cp', - target_dir / rust_target / meson.project_name(), + cargo_target_dir / rust_target / meson.project_name(), + '@OUTPUT@', + ], + ) + + # Run Rust tests with cargo-nextest + custom_target( + 'cargo-test', + build_always_stale: true, + output: 'junit.xml', + console: true, + depends: [resources, ui_resources], + command: [ + 'env', + cargo_env, + 'cargo-nextest', + 'nextest', + 'run', + cargo_options, + '--config-file', + nextest_config.full_path(), + '&&', + 'cp', + nextest_store_dir / 'default/junit.xml', '@OUTPUT@', ], ) @@ -169,5 +194,10 @@ custom_target( cargo, 'doc', cargo_options + doc_deps + ['--no-deps', '-Zrustdoc-map'], + '&&', + 'cp', + '-r', + cargo_target_dir / 'doc', + '@OUTPUT@', ], )