Skip to content

Add GitHub Actions workflow for Rust tests, linting, formatting, and coverage on macOS and Linux#2

Merged
bittner merged 2 commits into
mainfrom
copilot/sub-pr-1
Nov 1, 2025
Merged

Add GitHub Actions workflow for Rust tests, linting, formatting, and coverage on macOS and Linux#2
bittner merged 2 commits into
mainfrom
copilot/sub-pr-1

Conversation

Copilot AI commented Oct 30, 2025

Copy link
Copy Markdown
Contributor
  • Apply formatting suggestions to workflow file
  • Remove redundant "Run tests with all features" step
  • Add helper functions in test module to reduce unsafe wrapper repetition
  • Refactor workflow to eliminate duplication between lint and test jobs
  • Add code formatting check with cargo fmt
  • Replace deprecated actions-rs/toolchain action
  • Add code coverage with cargo-llvm-cov
  • Consolidate cache blocks for better readability
    • Merged 3 separate cache steps into 1 unified step
    • All paths cached together: registry, index, target
    • Added restore-keys for better cache fallback
    • Reduced workflow file by 6 lines
    • Cleaner GHA execution logs
  • Verify all tests still pass (13 tests)
  • Verify YAML is valid
  • Reply to comment about cache consolidation (13b4ea0)

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add macOS tray app with Rust backend Add GitHub Actions workflow for Rust tests on macOS and Linux Oct 30, 2025
Copilot AI requested a review from bittner October 30, 2025 12:37
@bittner

bittner commented Oct 30, 2025

Copy link
Copy Markdown
Member

@copilot Also add linting as a separate action that runs in parallel to the tests. Use cargo clippy or suggest better alternatives.

Copilot AI commented Oct 30, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Also add linting as a separate action that runs in parallel to the tests. Use cargo clippy or suggest better alternatives.

Added Clippy linting as a separate job that runs in parallel with the test jobs. The linting job:

  • Runs on ubuntu-latest
  • Uses cargo clippy --all-targets --all-features -- -D warnings to catch all warnings
  • Has its own caching for faster builds
  • Treats all warnings as errors for strict code quality

Also fixed a clippy warning it discovered: FFI functions that take raw pointers are now properly marked as unsafe, improving API safety.

Commit: c5e12ab

Copilot AI changed the title Add GitHub Actions workflow for Rust tests on macOS and Linux Add GitHub Actions workflow for Rust tests and linting on macOS and Linux Oct 30, 2025
@bittner

bittner commented Oct 30, 2025

Copy link
Copy Markdown
Member

@copilot Is it possible for the linting to behave differently on Linux and macOS? If yes, please use a matrix execution for the linting that covers macOS, too.

Copilot AI commented Oct 30, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Is it possible for the linting to behave differently on Linux and macOS? If yes, please use a matrix execution for the linting that covers macOS, too.

Yes, Clippy can behave differently on Linux and macOS when:

  • Code uses platform-specific conditional compilation (#[cfg(target_os = ...)])
  • Platform-specific dependencies are used
  • Platform-specific system APIs are involved
  • FFI/ABI considerations differ between platforms

Updated the linting job to use matrix execution on both ubuntu-latest and macos-latest, matching the test job configuration. This ensures consistent linting coverage across platforms.

Commit: 5ad9f92

Comment thread .github/workflows/rust-tests.yml Outdated
Comment thread .github/workflows/rust-tests.yml Outdated
Comment thread .github/workflows/rust-tests.yml Outdated
Comment thread .github/workflows/rust-tests.yml Outdated
Comment thread .github/workflows/rust-tests.yml Outdated
Comment thread .github/workflows/rust-tests.yml Outdated
Comment thread .github/workflows/rust-tests.yml Outdated
Comment thread .github/workflows/rust-tests.yml Outdated
Comment thread .github/workflows/rust-tests.yml Outdated
Comment thread rust-core/src/lib.rs Outdated
@bittner bittner marked this pull request as ready for review October 30, 2025 14:52
@bittner

bittner commented Oct 30, 2025

Copy link
Copy Markdown
Member

@copilot Please address my review comments from above!

Copilot AI commented Oct 30, 2025

Copy link
Copy Markdown
Contributor Author

@copilot Please address my review comments from above!

All review comments addressed in c74b3fb:

  • Applied all formatting suggestions (job names, matrix format, indentation)
  • Removed redundant test step
  • Added helper functions to reduce unsafe wrapper repetition
  • Answered all questions about caching and Clippy behavior

Copilot AI requested a review from bittner October 30, 2025 15:01
Comment thread .github/workflows/rust-tests.yml Outdated
@bittner bittner requested a review from robert197 October 30, 2025 16:27
Copilot AI changed the title Add GitHub Actions workflow for Rust tests and linting on macOS and Linux Add GitHub Actions workflow for Rust tests, linting, and formatting on macOS and Linux Oct 30, 2025
Copilot AI requested a review from bittner October 30, 2025 20:23
@bittner

bittner commented Oct 30, 2025

Copy link
Copy Markdown
Member

GHA reports a warning for actions-rs/toolchain, which appears to be unmaintained on GitHub. A related discussion is on Reddit.

One of the most sensible suggestions therein seems to be the following:

For the vast majority of cases the best way is to use no action at all since rustup is installed by default on github actions runners.
If you need to use a specific release of rust (a nightly release or a previous stable release) set that in your rust-toolchain.toml.

@copilot Can you analyse possible alternatives and suggest a sustainable solution?

Copilot AI commented Oct 30, 2025

Copy link
Copy Markdown
Contributor Author

GHA reports a warning for actions-rs/toolchain, which appears to be unmaintained on GitHub. A [related discussion](https://www.reddit.com/r/rust/comments/186kyra/httpsgithubcomactionsrs_is_archived_...

Analysis of alternatives:

  1. Use rustup directly (✅ Implemented) - Since rustup is pre-installed on GitHub Actions runners, we can use it directly without external actions
  2. rust-toolchain.toml - Better for projects needing specific Rust versions, but adds overhead for projects using stable
  3. dtolnay/rust-toolchain - A maintained alternative, but still adds dependency on external action

Sustainable solution implemented:

Replaced actions-rs/toolchain@v1 with direct rustup commands:

  • Uses rustup toolchain install stable --profile minimal (pre-installed on runners)
  • Sets stable as default with rustup default stable
  • Conditionally installs components (clippy/rustfmt) based on matrix check type
  • No external action dependencies to maintain
  • Works identically across macOS and Linux runners
  • Shell script approach is simple, maintainable, and transparent

Benefits:

  • ✅ No deprecation warnings
  • ✅ No dependency on unmaintained actions
  • ✅ Faster setup (no action download/setup overhead)
  • ✅ More control over component installation

Commit: 617ddb3

@bittner

bittner commented Oct 31, 2025

Copy link
Copy Markdown
Member

We're not measuring test coverage yet.

@copilot Can you add cargo-llvm-cov in a way that allows test coverage to be displayed both locally in the terminal and integrated in our GHA setup? Let me know if there is better tool that we should use instead.

Copilot AI commented Oct 31, 2025

Copy link
Copy Markdown
Contributor Author

We're not measuring test coverage yet.

@copilot Can you add cargo-llvm-cov in a way that allows test coverage to be displayed both locally in the terminal and integrated in our GHA setup? Let me ...

Added cargo-llvm-cov for code coverage - it's the current best practice for Rust (better alternatives like tarpaulin have limitations with newer Rust versions).

CI Integration:

  • Added coverage to the matrix check types
  • Installs llvm-tools-preview component and cargo-llvm-cov
  • Generates LCOV coverage reports
  • Uploads to Codecov automatically
  • Runs on both macOS and Linux

Local Usage (added to README):

# Install (one-time)
cargo install cargo-llvm-cov

# Terminal output
cargo llvm-cov

# HTML report (opens in browser)
cargo llvm-cov --open

# LCOV format
cargo llvm-cov --lcov --output-path lcov.info

Now runs 8 jobs in parallel (4 checks × 2 OSes). Codecov requires CODECOV_TOKEN secret to be set in repository settings.

Commit: 3c2196f

Copilot AI changed the title Add GitHub Actions workflow for Rust tests, linting, and formatting on macOS and Linux Add GitHub Actions workflow for Rust tests, linting, formatting, and coverage on macOS and Linux Oct 31, 2025
Copilot AI requested a review from bittner October 31, 2025 05:56
@codecov

codecov Bot commented Oct 31, 2025

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

Comment thread .github/workflows/rust-tests.yml
Comment thread .github/workflows/rust-tests.yml Outdated
@bittner

bittner commented Nov 1, 2025

Copy link
Copy Markdown
Member

I've squashed the commits to allow us to better track the changes. I'm merging now to take away the distraction.

@robert197 Please, take a look at the changes to the Rust code anyway! It's a single commit that we can easily undo, just in case it doesn't make sense.

@bittner bittner merged commit 647473d into main Nov 1, 2025
10 checks passed
@bittner bittner deleted the copilot/sub-pr-1 branch November 1, 2025 13:13
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