ci(rust): integrate Rust unit testing and linting into CI pipeline
This MR sets up unit testing/linting for the Rust components of the gitalisk project. It sets up the necessary infrastructure to run tests, linting, and formatting checks for our Rust code, both locally for developers and within our GitLab CI pipeline.
Related Issues
What's Changed
-
CI/CD Pipeline for Rust: New jobs have been added to
.gitlab-ci.yml
to automatically test, lint, and check formatting for all Rust code on each merge request. This includes:-
rust-unit-tests
: A job to runcargo test
. -
lint:rust-fmt-check
: Ensures code adheres torustfmt
standards. -
lint:rust-lint-check
: Usesclippy
to enforce code quality. The CI configuration uses a cache for Cargo dependencies to speed up subsequent pipeline runs.
-
-
Developer Workflow Enhancements:
-
lefthook.yml
is now configured with pre-push hooks to run tests, formatting, and lint checks before code is pushed. This helps catch issues locally before they reach the main branch. - A
rust-toolchain.toml
file has been added to pin the Rust version tostable
and ensure all developers use the same toolchain withrustfmt
andclippy
.
-
-
Code Refinements: Some of the existing Rust code has been refactored for better practices, including improved error handling and removal of some unused code. The
tempfile
dependency was added to support test creation.
Technical Details
Test and CI Setup
The new testing infrastructure is based on standard Rust tooling. Here's a look at the key configurations:
CI Pipeline Job:
.rust-job-template:
image: ${GITLAB_DEPENDENCY_PROXY}rust:latest
cache:
key:
files: [Cargo.toml, Cargo.lock]
paths: [.cargo/*, target/debug/*]
Pre-push Hook:
pre-push:
parallel: true
commands:
rust_test:
run: cargo test -- --nocapture
Edited by Michael Angelo Rivera