gagent/.drone.yml

83 lines
2.8 KiB
YAML
Raw Normal View History

---
kind: pipeline
type: docker
name: validation
platform:
2021-03-31 06:17:43 +00:00
arch: amd64
clone:
depth: 1
volumes:
- name: dockersock
host:
path: /run/docker.sock
steps:
# - name: Notify Datadog That we are starting
# image: masci/drone-datadog
# settings:
# api_key:
# from_secret: Datadog
# events:
# - title: "Begin Build: ${DRONE_REPO}(${DRONE_BUILD_NUMBER})"
# text: ${DRONE_COMMIT_MESSAGE}(${DRONE_COMMIT_LINK})
# alert_type: "info"
# host: ${DRONE_SYSTEM_HOSTNAME}
- name: Validate code base and dependencies
2021-05-21 19:28:23 -07:00
# image: golang:1.16-alpine3.13
image: dragonheim/golang:1.16.4
volumes:
- name: dockersock
path: /var/run/docker.sock
environment:
TRIVY_QUIET: true
TRIVY_LIGHT: true
TRIVY_FORMAT: table
TRIVY_IGNORE_UNFIXED: true
TRIVY_NO_PROGRESS: true
commands:
2021-05-22 06:10:35 -07:00
### Populate temporary container with tools / files we will need for building and testing
- apk add --no-cache zeromq-dev zeromq
2021-05-22 06:10:35 -07:00
# - curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin v0.18.2
2021-05-22 06:10:35 -07:00
### Format the go code. Go does not care about it, but it helps to ensure everything is formated the same.
- go fmt ./...
2021-05-22 06:10:35 -07:00
### Perform a basic lint of the code, we do this after formatting, just in case there are edge cases with the formatting.
- go vet ./...
2021-05-22 06:10:35 -07:00
### Run a security check and warn us about lower level vulnerabilities
- trivy fs --exit-code 0 --severity UNKNOWN,LOW,MEDIUM .
2021-05-22 06:10:35 -07:00
### Re-run the scan, but this time looking for higher level vulnerabilities that we want to block for.
- trivy fs --skip-update --exit-code 1 --severity CRITICAL,HIGH .
2021-05-22 06:10:35 -07:00
### Perform unit tests
# - @TODO I really don't know how to do unit tests. Will need to figure this out eventually.
### Build test container.
# - docker buildx build --platform linux/arm/v7,linux/amd64,linux/arm64 --progress plain -t ${DRONE_REPO}:${DRONE_COMMIT} .
- docker buildx build --platform linux/amd64 --progress plain -t ${DRONE_REPO}:${DRONE_COMMIT} -f docker/Dockerfile .
### Run a security check and warn us about lower level vulnerabilities
- trivy image --skip-update --exit-code 0 --severity UNKNOWN,LOW,MEDIUM,HIGH ${DRONE_REPO}:${DRONE_COMMIT}
### Re-run the scan, but this time looking for critical vulnerabilities that we want to block for.
- trivy image --skip-update --exit-code 1 --severity CRITICAL ${DRONE_REPO}:${DRONE_COMMIT}
- name: Notify Datadog
2021-05-22 06:10:35 -07:00
image: masci/drone-datadog
settings:
api_key:
from_secret: Datadog
events:
- title: "Build failure on amd64"
text: "Build ${DRONE_BUILD_NUMBER}"
alert_type: "error"
when:
status:
- failure