CI/CD Automation
miniROS-rs uses a simple and effective CI/CD pipeline to automate testing and releases.
Overview
The system consists of two main workflows:
- CI Pipeline - Runs tests on every push/PR
- Release Pipeline - Publishes packages when tags are created
Continuous Integration
The CI workflow (.github/workflows/ci.yml
) runs:
- Code Quality:
cargo fmt
andcargo clippy
- Rust Tests:
cargo test --all-features
- Python Package: Build and basic import test
Triggers
- Push to
main
ordevelop
branch - Pull requests to
main
ordevelop
branch
Release Process
Automatic Release
Create a git tag to trigger a release:
git tag v1.2.3
git push origin v1.2.3
This will:
- Run tests
- Build Rust crate and Python wheels
- Publish to crates.io and PyPI (if tokens are set)
- Create GitHub release with artifacts
Manual Release
Alternatively, manually trigger the release workflow in GitHub Actions:
- Go to Actions → Release
- Click Run workflow
- Enter the version number (e.g.,
1.2.3
)
Setup
Required Secrets
Add these secrets in your GitHub repository settings:
CRATES_IO_TOKEN
- For publishing to crates.ioPYPI_TOKEN
- For publishing to PyPI
Getting Tokens
crates.io token:
# Login to crates.io and go to Account Settings → API Tokens
# Create a new token with publish scope
PyPI token:
# Login to PyPI and go to Account Settings → API tokens
# Create a new token with upload scope
Workflow Files
CI Workflow
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Run tests
run: cargo test --all-features
Release Workflow
name: Release
on:
push:
tags: ['v*']
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Publish packages
run: |
cargo publish --token $CRATES_IO_TOKEN
maturin build --release --features python
twine upload dist/*.whl
Best Practices
- Test First: Always ensure tests pass before releasing
- Semantic Versioning: Use
v1.2.3
format for tags - Small Releases: Release frequently with small changes
- Documentation: Update docs with API changes
Troubleshooting
Release fails?
- Check that tokens are correctly set in repository secrets
- Ensure version number is unique (not already published)
- Verify tests pass locally first
Python build fails?
- Check that
pyproject.toml
is properly configured - Ensure maturin can find Rust source code
crates.io publish fails?
- Verify package name is unique
- Check that all required metadata is in
Cargo.toml
- Ensure no breaking changes without version bump