mirror of
https://github.com/harness/drone.git
synced 2025-05-07 11:40:12 +08:00
71 lines
886 B
Go
71 lines
886 B
Go
package interpreter
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
|
|
"github.com/drone/drone/yaml"
|
|
)
|
|
|
|
func TestInterpreter(t *testing.T) {
|
|
|
|
conf, err := yaml.ParseString(sampleYaml)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
pipeline := Load(conf)
|
|
|
|
for {
|
|
select {
|
|
case <-pipeline.Done():
|
|
fmt.Println("GOT DONE")
|
|
return
|
|
|
|
case <-pipeline.Next():
|
|
pipeline.Exec()
|
|
}
|
|
}
|
|
}
|
|
|
|
var sampleYaml = `
|
|
image: hello-world
|
|
build:
|
|
context: .
|
|
dockerfile: Dockerfile
|
|
|
|
workspace:
|
|
path: src/github.com/octocat/hello-world
|
|
base: /go
|
|
|
|
pipeline:
|
|
test:
|
|
image: golang
|
|
commands:
|
|
- go install
|
|
- go test
|
|
build:
|
|
image: golang
|
|
commands:
|
|
- go build
|
|
when:
|
|
event: push
|
|
notify:
|
|
image: slack
|
|
channel: dev
|
|
when:
|
|
event: failure
|
|
|
|
services:
|
|
database:
|
|
image: mysql
|
|
|
|
networks:
|
|
custom:
|
|
driver: overlay
|
|
|
|
volumes:
|
|
custom:
|
|
driver: blockbridge
|
|
`
|