I have some Postman collection that I want to run as integration test using drone. I am going to be using newman cli tool for Postman. How can I set up my rest API as a service in Drone?
My restful API is written in Go. I am already able to run unit test in drone. This is what my drone.yml looks like. I removed the publish and deploy pipelines for brevity.
kind: pipeline
type: kubernetes
name: Test
trigger:
event:
- push
node_selector:
type: cicd
steps:
- name: test
image: golang:1.14-alpine
pull: always
environment:
SSH_KEY:
from_secret: SSH_KEY
commands:
- |
apk add -U git
mkdir /root/.ssh
echo -n "$SSH_KEY" > /root/.ssh/id_rsa
chmod 600 /root/.ssh/id_rsa
export CGO_ENABLED=0
go generate ./...
go test ./...
go build ./...
Drone supports services [1] which are background containers that can be used for integration testing (mysql, redis, etc). You can also define services inline [2] in your pipeline steps to control order of operations and, such as your case, even use your own source code as a service.
Here is an example to demonstrate an inline service (replace with your Go program):