2020-02-26 00:45:40 +01:00
|
|
|
---
|
|
|
|
kind: pipeline
|
|
|
|
name: lint
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: yaml lint
|
|
|
|
image: cytopia/yamllint
|
|
|
|
commands:
|
|
|
|
- yamllint .
|
|
|
|
|
|
|
|
- name: docker lint
|
|
|
|
image: hadolint/hadolint
|
|
|
|
commands:
|
|
|
|
- hadolint Dockerfile # ignore pinning version in pip
|
|
|
|
|
|
|
|
- name: w3c validator
|
|
|
|
image: validator/validator:latest
|
|
|
|
commands:
|
|
|
|
- vnu static/*.html
|
|
|
|
|
|
|
|
- name: markdown lint
|
|
|
|
image: pipelinecomponents/markdownlint:latest
|
|
|
|
commands:
|
|
|
|
- mdl --style all --warnings .
|
|
|
|
|
|
|
|
---
|
|
|
|
kind: pipeline
|
|
|
|
name: unit tests
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: unit test
|
|
|
|
image: python:slim
|
|
|
|
commands:
|
|
|
|
- pip install -r requirements.txt
|
|
|
|
- pip install pylint
|
|
|
|
- pylint beer/*.py tests/*.py
|
|
|
|
- python -m pytest tests
|
|
|
|
|
|
|
|
depends_on:
|
|
|
|
- lint
|
|
|
|
|
2020-02-15 16:11:36 +01:00
|
|
|
---
|
|
|
|
kind: pipeline
|
|
|
|
name: build
|
|
|
|
|
|
|
|
steps:
|
2020-02-15 00:42:17 +01:00
|
|
|
- name: build image
|
2020-02-17 22:09:48 +01:00
|
|
|
image: plugins/docker
|
|
|
|
settings:
|
|
|
|
repo: kleph/beer
|
2020-02-25 01:46:56 +01:00
|
|
|
tags: ${DRONE_COMMIT_SHA:0:8}
|
2020-02-17 22:09:48 +01:00
|
|
|
username:
|
2020-02-15 12:48:36 +01:00
|
|
|
from_secret: dockerhub_username
|
2020-02-17 22:09:48 +01:00
|
|
|
password:
|
2020-02-15 12:48:36 +01:00
|
|
|
from_secret: dockerhub_password
|
2020-02-15 17:02:19 +01:00
|
|
|
|
2020-02-26 00:45:40 +01:00
|
|
|
depends_on:
|
|
|
|
- unit tests
|
2020-02-25 02:03:01 +01:00
|
|
|
|
2020-02-15 17:40:58 +01:00
|
|
|
---
|
2020-03-02 23:08:26 +01:00
|
|
|
deploy_commands_alias:
|
|
|
|
- &deploy_commands
|
|
|
|
commands:
|
|
|
|
- echo "== pre deploy ($${LEVEL}) status:"
|
|
|
|
- kubectl get pods --namespace=beer
|
|
|
|
- kubectl get deployments --namespace=beer
|
|
|
|
- sed "s/__LEVEL__/$${LEVEL}/g" kube/beer-deployment.yaml > kube/beer-deployment-$${LEVEL}.yaml
|
|
|
|
- sed "s/__NAMESPACE__/$${NAMESPACE}/g" kube/beer-deployment-$${LEVEL}.yaml > kube/beer-deployment-$${NAMESPACE}-$${LEVEL}.yaml
|
|
|
|
- sed "s/__IMAGE_TAG__/$${IMAGE_TAG}/g" kube/beer-deployment-$${NAMESPACE}-$${LEVEL}.yaml > kube/beer-deployment-$${NAMESPACE}-$${LEVEL}2.yaml
|
|
|
|
- echo "applying"
|
|
|
|
- kubectl apply -f kube/beer-deployment-$${NAMESPACE}-$${LEVEL}2.yaml --namespace=beer
|
|
|
|
- echo "== post deploy ($${LEVEL}) status:"
|
|
|
|
- kubectl get deployments --namespace=beer
|
|
|
|
- kubectl get pods --namespace=beer
|
|
|
|
|
2020-02-15 17:40:58 +01:00
|
|
|
kind: pipeline
|
2020-03-02 23:08:26 +01:00
|
|
|
name: deploy
|
2020-02-15 17:40:58 +01:00
|
|
|
|
|
|
|
steps:
|
2020-03-02 23:08:26 +01:00
|
|
|
- name: deploy staging
|
2020-02-17 22:56:48 +01:00
|
|
|
image: sinlead/drone-kubectl
|
|
|
|
settings:
|
|
|
|
kubernetes_server:
|
2020-02-15 17:40:58 +01:00
|
|
|
from_secret: kubectl_uri
|
2020-02-17 22:56:48 +01:00
|
|
|
kubernetes_cert:
|
|
|
|
from_secret: kubectl_cert
|
|
|
|
kubernetes_token:
|
|
|
|
from_secret: kubectl_token
|
2020-02-25 01:46:56 +01:00
|
|
|
environment:
|
|
|
|
IMAGE_TAG: ${DRONE_COMMIT_SHA:0:8}
|
2020-02-25 02:08:18 +01:00
|
|
|
NAMESPACE: beer
|
2020-03-01 01:28:04 +01:00
|
|
|
LEVEL: staging
|
2020-03-02 23:08:26 +01:00
|
|
|
<<: *deploy_commands
|
2020-03-01 01:28:04 +01:00
|
|
|
when:
|
|
|
|
branch:
|
|
|
|
exclude:
|
|
|
|
- master
|
2020-02-15 17:40:58 +01:00
|
|
|
|
2020-03-02 23:08:26 +01:00
|
|
|
- name: deploy live
|
2020-03-01 01:28:04 +01:00
|
|
|
image: sinlead/drone-kubectl
|
|
|
|
settings:
|
|
|
|
kubernetes_server:
|
|
|
|
from_secret: kubectl_uri
|
|
|
|
kubernetes_cert:
|
|
|
|
from_secret: kubectl_cert
|
|
|
|
kubernetes_token:
|
|
|
|
from_secret: kubectl_token
|
|
|
|
environment:
|
|
|
|
IMAGE_TAG: ${DRONE_COMMIT_SHA:0:8}
|
|
|
|
NAMESPACE: beer
|
|
|
|
LEVEL: prod
|
2020-03-02 23:08:26 +01:00
|
|
|
<<: *deploy_commands
|
2020-03-01 01:28:04 +01:00
|
|
|
when:
|
|
|
|
branch:
|
|
|
|
include:
|
|
|
|
- master
|
|
|
|
|
|
|
|
depends_on:
|
|
|
|
- build
|