Skip to content

Use mold for building tests#6436

Merged
timvisee merged 1 commit intodevfrom
use-mold-unit-test-building
Apr 28, 2025
Merged

Use mold for building tests#6436
timvisee merged 1 commit intodevfrom
use-mold-unit-test-building

Conversation

@agourlay
Copy link
Copy Markdown
Member

@agourlay agourlay commented Apr 25, 2025

This step often fails for Linux with

Run cargo build --tests --workspace --locked
  cargo build --tests --workspace --locked
  shell: /usr/bin/bash -e {0}
  env:
    CARGO_TERM_COLOR: always
    CARGO_HOME: /home/runner/.cargo
    CARGO_INCREMENTAL: 0
    CACHE_ON_FAILURE: false
    Updating crates.io index
   Compiling memory v0.0.0 (/home/runner/work/qdrant/qdrant/lib/common/memory)
   Compiling common v0.0.0 (/home/runner/work/qdrant/qdrant/lib/common/common)
   Compiling io v0.0.0 (/home/runner/work/qdrant/qdrant/lib/common/io)
   Compiling dataset v0.0.0 (/home/runner/work/qdrant/qdrant/lib/common/dataset)
   Compiling quantization v0.1.0 (/home/runner/work/qdrant/qdrant/lib/quantization)
   Compiling segment v0.6.0 (/home/runner/work/qdrant/qdrant/lib/segment)
   Compiling gpu v0.1.0 (/home/runner/work/qdrant/qdrant/lib/gpu)
   Compiling macros v0.1.0 (/home/runner/work/qdrant/qdrant/lib/macros)
   Compiling issues v0.0.0 (/home/runner/work/qdrant/qdrant/lib/common/issues)
   Compiling cancel v0.0.0 (/home/runner/work/qdrant/qdrant/lib/common/cancel)
   Compiling gridstore v0.1.0 (/home/runner/work/qdrant/qdrant/lib/gridstore)
   Compiling api v1.14.0 (/home/runner/work/qdrant/qdrant/lib/api)
   Compiling sparse v0.1.0 (/home/runner/work/qdrant/qdrant/lib/sparse)
   Compiling collection v0.4.2 (/home/runner/work/qdrant/qdrant/lib/collection)
   Compiling storage v0.2.0 (/home/runner/work/qdrant/qdrant/lib/storage)
   Compiling qdrant v1.14.0 (/home/runner/work/qdrant/qdrant)
Error: Process completed with exit code 143.

This PR uses mold for linking as it fixed the same issue on Crasher qdrant/crasher#17

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 25, 2025

📝 Walkthrough

Walkthrough

The GitHub Actions workflow for Rust projects has been updated to include the installation and configuration of the mold linker on Linux environments, specifically when running on the ubuntu-latest runner. The workflow now uses the rui314/setup-mold@v1 action to install mold. Following this, a conditional step executes a shell script on Ubuntu runners to create a .cargo/config.toml file. This file configures the Rust toolchain to use clang as the linker and specifies the use of mold via the -fuse-ld=/usr/local/bin/mold flag for the x86_64-unknown-linux-gnu target. No other modifications were made to the workflow steps related to building or testing the project. There were no changes to public or exported declarations in the codebase.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b4a5254 and 8fee70c.

📒 Files selected for processing (1)
  • .github/workflows/rust.yml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: test-snapshot-operations-s3-minio
  • GitHub Check: test-shard-snapshot-api-s3-minio
  • GitHub Check: test-low-resources
  • GitHub Check: Basic TLS/HTTPS tests
  • GitHub Check: test-consistency
  • GitHub Check: rust-tests (macos-latest)
  • GitHub Check: test-consensus-compose
  • GitHub Check: rust-tests (windows-latest)
  • GitHub Check: integration-tests-consensus
  • GitHub Check: rust-tests (ubuntu-latest)
  • GitHub Check: integration-tests
  • GitHub Check: lint
  • GitHub Check: storage-compat-test

Comment on lines +28 to +29
- name: Install mold
uses: rui314/setup-mold@v1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Condition the mold installation to Linux only

The setup-mold action currently runs on all runners (macOS/Windows included), but it only supports Linux. This will cause the workflow to fail on non-Linux OSes. Add a step-level filter to restrict installation to Ubuntu:

-    - name: Install mold
-      uses: rui314/setup-mold@v1
+    - name: Install mold (Linux only)
+      if: matrix.os == 'ubuntu-latest'
+      uses: rui314/setup-mold@v1
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Install mold
uses: rui314/setup-mold@v1
- name: Install mold (Linux only)
if: matrix.os == 'ubuntu-latest'
uses: rui314/setup-mold@v1

Comment on lines +31 to +38
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
mkdir .cargo
echo "[target.x86_64-unknown-linux-gnu]" >> .cargo/config.toml
echo "linker = \"clang\"" >> .cargo/config.toml
echo "rustflags = [\"-C\", \"link-arg=-fuse-ld=/usr/local/bin/mold\"]" >> .cargo/config.toml
fi
shell: bash
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Simplify mold configuration and directory handling

Rather than embedding the OS check in the script, move it to the step level. Also use mkdir -p to avoid errors if .cargo already exists, and switch to a here-document for clearer, atomic file writes:

-    - name: Enable mold on Linux
-      run: |
-        if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
-          mkdir .cargo
-          echo "[target.x86_64-unknown-linux-gnu]" >> .cargo/config.toml
-          echo "linker = \"clang\"" >> .cargo/config.toml
-          echo "rustflags = [\"-C\", \"link-arg=-fuse-ld=/usr/local/bin/mold\"]" >> .cargo/config.toml
-        fi
-      shell: bash
+    - name: Configure mold linker (Linux only)
+      if: matrix.os == 'ubuntu-latest'
+      run: |
+        mkdir -p .cargo
+        cat << 'EOF' > .cargo/config.toml
+        [target.x86_64-unknown-linux-gnu]
+        linker = "clang"
+        rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/mold"]
+        EOF
+      shell: bash
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run: |
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
mkdir .cargo
echo "[target.x86_64-unknown-linux-gnu]" >> .cargo/config.toml
echo "linker = \"clang\"" >> .cargo/config.toml
echo "rustflags = [\"-C\", \"link-arg=-fuse-ld=/usr/local/bin/mold\"]" >> .cargo/config.toml
fi
shell: bash
- name: Configure mold linker (Linux only)
if: matrix.os == 'ubuntu-latest'
run: |
mkdir -p .cargo
cat << 'EOF' > .cargo/config.toml
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/mold"]
EOF
shell: bash

@timvisee
Copy link
Copy Markdown
Member

🤞

@agourlay
Copy link
Copy Markdown
Member Author

agourlay commented Apr 25, 2025

acceptance criteria: 10 consecutive green runs for Rust tests / rust-tests (ubuntu-latest)

@agourlay
Copy link
Copy Markdown
Member Author

proof

@timvisee
Copy link
Copy Markdown
Member

proof

Fantastic! Nice one! 🎈

@timvisee timvisee merged commit ce39fa3 into dev Apr 28, 2025
17 checks passed
@timvisee timvisee deleted the use-mold-unit-test-building branch April 28, 2025 10:34
generall pushed a commit that referenced this pull request May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants