Ruby 파이프라인 예시 — Kubernetes
이 가이드는 Ruby 프로젝트를 위한 지속적 통합(CI) 파이프라인 설정 방법을 다뤄요. Drone이 처음이라면 먼저 튜토리얼과 빌드 설정 가이드를 읽어 주세요.
출처: Drone CI Docs
본문
빌드와 테스트 (Build and Test)
아래 예시는 bundle install과 rake 명령을 실행하는 파이프라인을 보여줘요. 이 명령들은 ruby Docker 컨테이너 안에서 실행되고, 컨테이너는 실행 시점에 DockerHub에서 내려받아요.
kind: pipeline
type: kubernetes
name: default
steps:
- name: test
image: ruby
commands:
- bundle install --jobs=3 --retry=3
- rake
어떤 Docker 레지스트리의 이미지든 파이프라인에서 사용할 수 있다는 점에 유의하세요. 공식 ruby 이미지를 쓸 수도 있고, 직접 만든 이미지를 쓸 수도 있어요.
의존성 (Dependencies)
파이프라인을 여러 스텝으로 나누기로 했다면 각 스텝이 프로젝트 의존성에 접근할 수 있도록 해야 해요. 의존성은 공유 워크스페이스 밖에 있는 /usr/local/bundle에 내려받아져요. 네임드 볼륨을 만들어 이 디렉터리를 모든 파이프라인 스텝과 공유하세요:
kind: pipeline
type: kubernetes
name: default
steps:
- name: install
image: ruby
volumes:
- name: bundle
path: /usr/local/bundle
commands:
- bundle install --jobs=3 --retry=3
- name: test
image: ruby
volumes:
- name: bundle
path: /usr/local/bundle
commands:
- rake
volumes:
- name: bundle
temp: {}
여러 버전 테스트 (Test Multiple Versions)
Drone의 멀티 파이프라인 기능을 사용해 여러 버전의 Ruby에 대해 동시에 테스트할 수 있어요. 다른 지속적 통합 시스템의 matrix 기능과 같은 역할을 해요.
---
kind: pipeline
type: kubernetes
name: ruby-2-4
steps:
- name: test
image: ruby:2.4
commands:
- bundle install --jobs=3 --retry=3
- rake
---
kind: pipeline
type: kubernetes
name: ruby-2-3
steps:
- name: test
image: ruby:2.3
commands:
- bundle install --jobs=3 --retry=3
- rake
...
이 문법이 너무 장황하다고 느껴지면 jsonnet 사용을 추천해요. jsonnet이 낯설다면 우리의 가이드를 읽어 주세요.
local Pipeline(name, image) = {
kind: "pipeline",
type: "kubernetes",
name: name,
steps: [
{
name: "test",
image: image,
commands: [
"bundle install --jobs=3 --retry=3",
"rake"
]
}
]
};
[
Pipeline("ruby23", "ruby:2.3"),
Pipeline("ruby24", "ruby:2.4"),
]
여러 아키텍처 테스트 (Test Multiple Architectures)
Drone의 멀티 파이프라인 기능을 사용해 여러 아키텍처와 운영체제에서 코드를 동시에 테스트할 수 있어요.
---
kind: pipeline
type: kubernetes
name: test-on-amd64
platform:
arch: amd64
steps:
- name: test
image: ruby
commands:
- bundle install --jobs=3 --retry=3
- rake
---
kind: pipeline
type: kubernetes
name: test-on-arm64
platform:
arch: arm64
steps:
- name: test
image: ruby
commands:
- bundle install --jobs=3 --retry=3
- rake
...
이 문법이 너무 장황하다고 느껴지면 jsonnet 사용을 추천해요. jsonnet이 낯설다면 우리의 가이드를 읽어 주세요.