Rustパイプラインの例
このガイドでは、Rustプロジェクトの継続的インテグレーションパイプラインの構成について説明します。Droneを初めて使用する場合は、最初にチュートリアルとビルド構成ガイドをお読みください。
ビルドとテスト
cargo build
コマンドとcargo test
コマンドを実行するパイプラインを示しています。これらのコマンドは、実行時にDockerHubからダウンロードされた錆びたDockerコンテナ内で実行されます。
kind: pipeline
type: kubernetes
name: default
steps:
- name: test
image: rust:1.30
commands:
- cargo build --verbose --all
- cargo test --verbose --all
パイプラインでは、任意のDockerレジストリから任意のDockerイメージを使用できることに注意してください。公式のrust画像を使用することも、自分で持参することもできます。
複数のバージョンをテストする
Droneのマルチパイプライン機能を使用して、Rustの複数のバージョンを同時にテストできます。これは、他の継続的インテグレーションシステムに見られるマトリックス機能と同等です。
kind: pipeline
type: kubernetes
name: rust-1-30
steps:
- name: test
image: rust:1.30
commands:
- cargo build --verbose --all
- cargo test --verbose --all
---
kind: pipeline
type: kubernetes
name: rust-1-29
steps:
- name: test
image: rust:1.29
commands:
- cargo build --verbose --all
- cargo test --verbose --all
この構文が冗長すぎる場合は、jsonnetを使用することをお勧めします。 jsonnetに慣れていない場合は、ガイドをお読みください。
local Pipeline(name, image) = {
kind: "pipeline",
type: "kubernetes",
name: name,
steps: [
{
name: "test",
image: image,
commands: [
"cargo build --verbose --all",
"cargo test --verbose --all"
]
}
]
};
[
Pipeline("rust-1-29", "rust:1.29"),
Pipeline("rust-1-30", "rust:1.30"),
]
複数のアーキテクチャをテストする
Droneのマルチパイプライン機能を使用して、複数のアーキテクチャとオペレーティングシステムでコードを同時にテストできます。
kind: pipeline
type: kubernetes
name: test-on-amd64
platform:
arch: amd64
steps:
- name: test
image: rust:1.30
commands:
- cargo build --verbose --all
- cargo test --verbose --all
---
kind: pipeline
type: kubernetes
name: test-on-arm64
platform:
arch: arm64
steps:
- name: test
image: rust:1.30
commands:
- cargo build --verbose --all
- cargo test --verbose --all
この構文が冗長すぎる場合は、jsonnetを使用することをお勧めします。 jsonnetに慣れていない場合は、ガイドをお読みください。