chihaya/.drone.yml

107 lines
2.5 KiB
YAML

---
kind: pipeline
name: compliance
type: docker
steps:
- name: gofmt
image: golangci/golangci-lint:v1.53.2-alpine
commands:
- golangci-lint run --color always --no-config --disable-all -E gofmt
depends_on: [ clone ]
- name: linter
image: golangci/golangci-lint:v1.53.2-alpine
commands:
- golangci-lint run --color always
depends_on: [ clone ]
trigger:
ref:
- refs/heads/master
- refs/pull/**
- refs/tags/**
event:
exclude:
- promote
---
kind: pipeline
name: tests
type: docker
services:
- name: mariadb
image: mariadb:10.11
pull: always
environment:
MYSQL_RANDOM_ROOT_PASSWORD: yes
MYSQL_DATABASE: chihaya_test
MYSQL_USER: drone
MYSQL_PASSWORD: w33lkn0wn
MYSQL_INITDB_SKIP_TZINFO: yes
steps:
- name: await
image: albinodrought/drone-wait-for-it
environment:
PLUGIN_HOST: mariadb
PLUGIN_PORT: 3306
- name: test
image: golang:1.20-alpine
pull: always
environment:
CGO_ENABLED: 0
GO111MODULE: on
DB_DSN: "drone:w33lkn0wn@(mariadb)/chihaya_test"
commands:
- apk add mariadb-client
- mysql -udrone -pw33lkn0wn -hmariadb chihaya_test < database/schema.sql
- go get -v -t -d ./...
- go test ./... -v -buildvcs=false -coverprofile=coverage.out
- name: coverage
image: golang:1.20-alpine
commands:
- go tool cover -func=coverage.out
trigger:
ref:
- refs/heads/master
- refs/pull/**
- refs/tags/**
event:
exclude:
- promote
---
kind: pipeline
name: docker
type: docker
platform:
arch: amd64
steps:
- name: fetch
image: alpine/git
commands:
- git fetch --tags
- name: build
image: plugins/docker
pull: always
privileged: true
environment:
DOCKER_REGISTRY:
from_secret: docker_registry
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
tags:
- "${DRONE_DEPLOY_TO}"
commands:
- export PLUGIN_REPO=$DOCKER_REGISTRY/chihaya
- /usr/local/bin/dockerd-entrypoint.sh /bin/drone-docker
trigger:
event:
- promote