Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
GitLab CI - Rust setup
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
@LukeMathWalker

This comment has been minimized.

Copy link
Owner Author

@LukeMathWalker LukeMathWalker commented Jun 7, 2020

Courtesy of Alan Faloon.

@ColmanHumphrey

This comment has been minimized.

Copy link

@ColmanHumphrey ColmanHumphrey commented Oct 2, 2020

This is very short and neat compared to the github actions version, which I assume is because the actions version has many more bells and whistles (scheduling, toolchain specification etc). Does anyone know how would a feature-matched gitlab-ci yaml file compare?

@LukeMathWalker

This comment has been minimized.

Copy link
Owner Author

@LukeMathWalker LukeMathWalker commented Oct 2, 2020

The big difference with the GitHub actions version is caching and parallelism - I am not a GitLab user, but I'd be happy to host a more optimised version if provided.

@searsaw

This comment has been minimized.

Copy link

@searsaw searsaw commented Dec 29, 2020

This could, and probably should, be broken into separate steps instead of everything being done in a single step. At least attempt to parallelize things that could be done at the same time.

@LukeMathWalker

This comment has been minimized.

Copy link
Owner Author

@LukeMathWalker LukeMathWalker commented Dec 29, 2020

If anybody who knows GitLab CI wants to pitch in with a more optimised setup I am happy to edit the gist 😁

@devonh

This comment has been minimized.

Copy link

@devonh devonh commented Feb 6, 2021

Hey! To parallelize things you could update this to something like the following:

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 rustfmt
    - cargo fmt -- --check
    - rustup component add clippy
    - cargo clippy -- -D warnings

audit-code:
  stage: test
  script:
    - cargo install cargo-audit
    - cargo audit
@LukeMathWalker

This comment has been minimized.

Copy link
Owner Author

@LukeMathWalker LukeMathWalker commented Feb 6, 2021

Thanks - updated @devonh!

@Valmirius

This comment has been minimized.

Copy link

@Valmirius Valmirius commented Jul 17, 2021

What else needs to be added to the Gitlab version to account for SQLX's compile time checks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment