Last active
March 29, 2024 16:15
-
-
Save LukeMathWalker/d98fa8d0fc5394b347adf734ef0e85ec to your computer and use it in GitHub Desktop.
GitLab CI - Rust setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: "rust:latest" | |
default: | |
before_script: | |
- rustc --version | |
- cargo --version | |
stages: | |
- test | |
test-code: | |
stage: test | |
script: | |
- cargo test | |
- cargo install cargo-tarpaulin | |
- cargo tarpaulin --ignore-tests | |
lint-code: | |
stage: test | |
script: | |
- rustup component add clippy | |
- cargo clippy -- -D warnings | |
format-code: | |
stage: test | |
script: | |
- rustup component add rustfmt | |
- cargo fmt -- --check | |
audit-code: | |
stage: test | |
script: | |
- cargo install cargo-audit | |
- cargo audit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Arevjensen Gitlab CI runs in a docker container, in this case,
rust:latest
as specified at the top of the file here. As you've discovered the rust container doesn't include lld or clang by default.When doing it this way, you're installing these each and every time. I've gone ahead and bundled all the dependencies as of Chapter 1 into a single docker image.
If you'd like you can replace
image: "rust-latest"
withimage: "aestusvitae/rust-ci:latest"
and remove the installs (apt
,cargo install
,rustup component add
) from your CI scripts, and CI runs should be noticeably quicker.You can even build the image yourself if you're so inclined. (or if I fail to keep mine up to date) The Dockerfile is very simple.