Drone CI 中文文档

Example Swift Pipeline

This guide covers configuring continuous integration pipelines for Swift projects. If you’re new to Drone please read our Tutorial and build configuration guides first.

Build and Test

In the below example we demonstrate a pipeline that executes the project unit tests with the swift build and swift test commands. These commands are executed inside a Docker container, downloaded at runtime from DockerHub.

kind: pipeline
name: default

steps:
- name: test
  image: swift:4
  commands:
  - swift build
  - swift test

Please note that you can use any Docker image in your pipeline from any Docker registry. You can use the official swift images, or your can bring your own.

Test Multiple Versions

You can use Drone’s multi-pipeline feature to concurrently test against multiple versions of Swift. This is equivalent to matrix capabilities found in other continuous integration systems.

---
kind: pipeline
name: swift3

steps:
- name: test
  image: swift:3
  commands:
  - swift build
  - swift test

---
kind: pipeline
name: swift4

steps:
- name: test
  image: swift:4
  commands:
  - swift build
  - swift test

...

If you find this syntax too verbose we recommend using jsonnet. If you are unfamiliar with jsonnet please read our guide.

local Pipeline(version) = {
  kind: "pipeline",
  name: "swift"+version,
  steps: [
    {
      name: "test",
      image: "swift:"+version,
      commands: [
        "swift build",
        "swift test"
      ]
    }
  ]
};

[
  Pipeline("3"),
  Pipeline("4"),
]