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