An example of using Bitbucket Pipelines for a Rust project
The project centers around matching patterns in a noisy signal against a dictionary of known words from an alien language. To demonstrate the capabilities of Bitbucket Pipelines the project includes the following aspects:
- a library in the src/ directory that is documented and contains the following types of tests:
- integration tests in the tests/ directory
- an example in the examples/ directory
Bitbucket Pipelines is used to
- Build the project
- Format the source code
- Run unit tests
- Test the project library's documentation
- Run integration tests
- Run benchmark tests
- Publish the project's API documentation
- Upload the project to the crates.io registry
- Deploy the web service to AWS (TODO)
- Cache build dependencies to speed up future Pipelines
The instructions for the build are contained in bitbucket-pipelines.yml. The build uses buildpack-deps-rust as the base image. The image includes a nightly version of the Rust toolchain along with the rustfmt utility.
Here are details of each step.
Update Rust toolchain
rustup utility is used to update to the latest nightly version of the Rust toolchain.
Setup git with read/write access
This is required for pushing up code formatting changes and pushing the generated API docs to the Bitbucket-hosted static website.
A quick check to make sure the code compiles.
Format the source code
If formatting changes are made, they are automatically commited and pushed back up. The build is killed, and another build starts up.
Run unit tests
Unit tests are contained in a tests module in the same file as the library code they are testing.
Run documentation tests
Documentation examples are tested.
Run integration tests
Integration tests in the test directory are run.
Run benchmark tests
Benchmarks are contained in a tests module in the same file as the library code they are testing.
Build the project's documentation
Upload to crates.io
crates.io is a public repository for Rust libraries. It is used to find dependencies listed in Cargo.toml. Here is this projects crates.io page.
TODO: bump version, git tag