Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ad4cd78
[rust] Init multipass crate & oxidize petname
levkropp Aug 11, 2025
6d2aac5
[rust] Separate modules into individual crates
levkropp Aug 21, 2025
1b51142
[rust] Handle petname tests in rust only
levkropp Aug 21, 2025
866b9f4
[rust] Move tests out of lib.rs to dedicated file
levkropp Aug 21, 2025
6f0015c
[rust] Separate crate includes from core cpp files
levkropp Aug 21, 2025
9783e52
[rust] Move petname txt files to petname crate
levkropp Aug 21, 2025
ac7b74f
[rust] Use corrosion for rust + cmake integration
levkropp Aug 21, 2025
00b9a06
[rust] Petname functions use Results, better tests
levkropp Aug 21, 2025
ad8931e
[rust] Add rust linting with rustfmt
levkropp Aug 21, 2025
60cf22e
[rust] Fix cxxbridge identifier handling on mac
levkropp Aug 21, 2025
4b3fc53
[rust] One crate to Rule Them All
levkropp Sep 11, 2025
61b4fe2
[tests] Stricter regex for petname daemon test
levkropp Sep 24, 2025
08e4545
[cmake] Clean corrosion & cargo files on clean
levkropp Sep 24, 2025
d4a5d47
[cmake] Define all_tests target and use it in CI
levkropp Sep 24, 2025
549e5ae
[cmake] Set rust profile based on cmake build type
levkropp Sep 26, 2025
59a721a
[ci] Add Rust coverage in ci with cargo-llvm-cov
levkropp Oct 2, 2025
f10bb53
[tests] Mock the name generator in C++
levkropp Oct 2, 2025
4b6c0ec
[tests] Register and run combined tests with ctest
levkropp Oct 7, 2025
081fd7f
[tests] Remove cargo test call from snapcraft.yaml
levkropp Oct 7, 2025
33e3cfd
[tests] Cover rust_petname_generator.cpp
levkropp Oct 7, 2025
bb6845a
[ci] Add crates folder to file change detect
levkropp Oct 8, 2025
b532061
[tests] More accurate petname test name
levkropp Oct 8, 2025
082e645
[docs] Add rustup.install back to windows guide
levkropp Oct 8, 2025
903b369
[rust] Build cxx bridge with c++20 flag
levkropp Oct 8, 2025
61066bc
[rust] Use function try for petname generator
levkropp Oct 8, 2025
3ead8d3
[tests] Mock name generator uses pragma once
levkropp Oct 8, 2025
4778636
[tests] Remove unused import in test_daemon.cpp
levkropp Oct 8, 2025
42c40c7
[tests] Assert petname words are not empty
levkropp Oct 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/dynamic-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ jobs:
- "CMakeLists.txt"
- "vcpkg-configuration.json"
- "vcpkg.json"
- "Cargo.toml"
- "Cargo.lock"
- "crates/**"
hooks:
- "git-hooks/**"

Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,21 @@ jobs:
echo "Run '3rd-party/flutter/bin/dart format' to fix formatting."
exit 1
fi

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt

- name: Run Rust format check
shell: bash
run: |
if [ -f "Cargo.toml" ]; then
if ! cargo fmt --all --check; then
echo -n "##[error] Rust code is not properly formatted. "
echo "Run 'cargo fmt --all' to fix formatting."
exit 1
fi
else
echo "No Cargo.toml found, skipping Rust format check"
fi
27 changes: 24 additions & 3 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,13 @@ jobs:
/snap/bin/lxc --project snapcraft exec $instance_name -- bash -c 'cat /proc/sys/kernel/core_pattern'
# Create the directory for the coredumps
/snap/bin/lxc --project snapcraft exec $instance_name -- bash -c 'mkdir -p /coredump'
# Enable coredumps by setting the core dump size to "unlimited", and run the tests.
# Enable coredumps by setting the core dump size to "unlimited", and run the unified test target.
/snap/bin/lxc --project snapcraft exec $instance_name -- bash -c "\
ulimit -c unlimited && \
source /root/.cargo/env && \
ulimit -c unlimited && \
env CTEST_OUTPUT_ON_FAILURE=1 \
LD_LIBRARY_PATH=/root/stage/usr/lib/x86_64-linux-gnu/:/root/stage/lib/:/root/parts/multipass/build/lib/ \
/root/parts/multipass/build/bin/multipass_tests"
ctest --test-dir /root/parts/multipass/build --output-on-failure"

- name: Measure coverage
id: measure-coverage
Expand Down Expand Up @@ -231,18 +232,38 @@ jobs:
/snap/bin/lxc --project snapcraft exec $instance_name -- \
sh -c "sudo sed -i \"s/use JSON::PP/use JSON::XS/\" \`which geninfo\`"

# Install cargo-llvm-cov for Rust coverage
/snap/bin/lxc --project snapcraft exec $instance_name -- bash -c "\
source /root/.cargo/env && \
cargo install cargo-llvm-cov"

# Create the directory for the coredumps
/snap/bin/lxc --project snapcraft exec $instance_name -- bash -c 'mkdir -p /coredump'

# Generate C++ coverage
/snap/bin/lxc --project snapcraft exec $instance_name -- bash -c "\
ulimit -c unlimited && \
env CTEST_OUTPUT_ON_FAILURE=1 \
cmake --build /root/parts/multipass/build --target covreport"

# Generate Rust coverage in lcov format
/snap/bin/lxc --project snapcraft exec $instance_name -- bash -c "\
source /root/.cargo/env && \
cargo llvm-cov --manifest-path /root/parts/multipass/src/Cargo.toml \
--lcov --output-path /root/parts/multipass/build/rust-coverage.lcov"

# Merge C++ and Rust coverage reports
/snap/bin/lxc --project snapcraft exec $instance_name -- bash -c "\
lcov -a /root/parts/multipass/build/coverage.cleaned \
-a /root/parts/multipass/build/rust-coverage.lcov \
-o /root/parts/multipass/build/combined-coverage.info"

- name: Upload coverage
if: ${{ matrix.build-type == 'Coverage' }}
uses: codecov/codecov-action@v5
with:
directory: ${{ steps.coverage-setup.outputs.build }}
files: ./combined-coverage.info
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Expand Down
35 changes: 30 additions & 5 deletions .github/workflows/windows-macos.yml
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unit tests?

Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ jobs:
pixman \
pkg-config \
python \
wget
wget \
rustup-init

- name: Install dependencies from pip
if: ${{ runner.os == 'macOS' }}
Expand All @@ -154,7 +155,7 @@ jobs:
if: ${{ runner.os == 'Windows' }}
uses: crazy-max/ghaction-chocolatey@v3
with:
args: install --yes wget unzip
args: install --yes wget unzip rustup.install

- name: Set up vcpkg
id: setup-vcpkg
Expand Down Expand Up @@ -255,6 +256,31 @@ jobs:
if: ${{ runner.os == 'Windows' }}
uses: ilammy/msvc-dev-cmd@v1

- name: Initialize Rust toolchain
shell: bash
run: |
if [[ "${{ runner.os }}" == "Windows" ]]; then
# On Windows, rustup.install from chocolatey should be available
if command -v rustup >/dev/null 2>&1; then
rustup default stable
rustup update
else
echo "Error: rustup not found. Please ensure it is installed and in the PATH."
exit 1
fi
elif [[ "${{ runner.os }}" == "macOS" ]]; then
# On macOS, initialize rustup-init
if command -v rustup-init >/dev/null 2>&1; then
rustup-init -y --default-toolchain stable
source ~/.cargo/env
else
echo "Error: rustup-init not found. Please ensure it is installed and in the PATH."
exit 1
fi
fi
# Add cargo bin to PATH for subsequent steps
echo "$HOME/.cargo/bin" >> $GITHUB_PATH

- name: Configure
run: >
${{ env.ARCH_WRAPPER }}
Expand All @@ -276,9 +302,8 @@ jobs:
run: ccache --show-stats --zero-stats

- name: Test
working-directory: ${{ env.BUILD_DIR }}
run: |
${{ env.ARCH_WRAPPER }} bin/multipass_tests
run: |\
${{ env.ARCH_WRAPPER }} ctest --test-dir ${{ env.BUILD_DIR }} --output-on-failure

- name: Package
id: cmake-package
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ packaging/windows/custom-actions/x64/*

# Python artifacts
*.pyc


# Added by cargo

/target
4 changes: 4 additions & 0 deletions BUILD.linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ sudo apt install devscripts equivs
mk-build-deps -s sudo -i
```

### Rust toolchain

Multipass requires Rust for building. Install the Rust toolchain from: https://rustup.rs/

## Building

First, go into the repository root and get all the submodules:
Expand Down
4 changes: 4 additions & 0 deletions BUILD.macOS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ means to obtain these dependencies is with Homebrew <https://brew.sh/>.

brew install cmake openssl@3

### Rust toolchain

Multipass requires Rust for building. Install the Rust toolchain from: https://rustup.rs/

Building
---------------------------------------

Expand Down
6 changes: 5 additions & 1 deletion BUILD.windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ choco install cmake ninja qemu openssl git wget unzip -yfd
```

```[pwsh]
choco install visualstudio2022buildtools visualstudio2022-workload-vctools -yfd
choco install visualstudio2022buildtools visualstudio2022-workload-vctools rustup.install -yfd
```

NOTE: visualcpp-build-tools is only the installer package. For this reason, choco cannot detect any
Expand All @@ -43,6 +43,10 @@ For Windows 11:
1. Go to "Developer Settings"
2. Enable "Developer mode"

### Rust toolchain

Multipass requires Rust for building. You can install it via Chocolatey (included in the command above) or from: https://rustup.rs/

### Qt6

To install Qt6, use `aqt`. First install it with chocolatey:
Expand Down
37 changes: 37 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,29 @@ find_package(gRPC CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
# targets: fmt::fmt, fmt::fmt-header-only

# Corrosion for Rust + CMake integration
include(FetchContent)

FetchContent_Declare(
Corrosion
GIT_REPOSITORY https://github.com/corrosion-rs/corrosion.git
GIT_TAG v0.5 # Use stable version
)
FetchContent_MakeAvailable(Corrosion)

# Register Rust build directories for cleaning
set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES
"${CMAKE_BINARY_DIR}/cargo"
"${CMAKE_BINARY_DIR}/corrosion"
)

# Add custom target to also run cargo clean when needed
add_custom_target(clean-rust
COMMAND cargo clean --manifest-path ${CMAKE_SOURCE_DIR}/Cargo.toml
COMMENT "Cleaning Cargo workspace artifacts"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)

# Needs to be here before we set further compilation options
add_subdirectory(3rd-party)

Expand Down Expand Up @@ -391,6 +414,20 @@ add_subdirectory(src)
if(MULTIPASS_ENABLE_TESTS)
enable_testing()
add_subdirectory(tests)

# Add convenience targets for running tests
add_custom_target(test-all
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all_tests
COMMENT "Running all tests (C++ and Rust) via convenience target"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)

# Add alias for compatibility
add_custom_target(check
COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all_tests
COMMENT "Running all tests (alias for test-all)"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endif()

include(packaging/cpack.cmake OPTIONAL)
Loading