# This is a sample build configuration for Rust. # Check our guides at https://confluence.atlassian.com/x/5Q4SMw for more examples. # Only use spaces to indent your .yml configuration. # ----- # You can specify a custom docker image from Docker Hub as your build environment. image: rust:1.42 clone: depth: full definitions: caches: sonar: ~/.sonar/cache # Caching SonarCloud artifacts will speed up your build cargo: $HOME/.cargo cargo-target: target steps: - step: &clippy name: Static Code Analysis with Clippy caches: - cargo script: - rustup component add clippy - cargo clippy --all-targets --all-features -- -D warnings - step: &build name: Build caches: - cargo - cargo-target script: - cargo build -v - step: &test name: Test caches: - cargo - cargo-target script: - cargo test -v - step: &sonarcloud name: Build, test and analyze on SonarCloud caches: - sonar - cargo - cargo-target script: - pipe: sonarsource/sonarcloud-scan:1.0.1 - step: &check-quality-gate-sonarcloud name: Check the Quality Gate on SonarCloud caches: - sonar script: - pipe: sonarsource/sonarcloud-quality-gate:0.1.3 - step: &deployment name: Deploy to Crates deployment: Crates caches: - cargo - cargo-target trigger: manual script: - cargo login $CARGO_TOKEN - cargo publish pipelines: default: - step: *clippy - step: *build - step: *test branches: master: - step: *clippy - step: *build - step: *test - step: *sonarcloud - step: *check-quality-gate-sonarcloud - step: *deployment pull-requests: '**': - step: *clippy - step: *build - step: *test - step: *sonarcloud - step: *check-quality-gate-sonarcloud