This repository has been archived on 2024-04-06. You can view files and clone it, but cannot push or open issues or pull requests.
core-old/.drone.yml
Dawid Wysokiński 3ca323eb82
All checks were successful
continuous-integration/drone/push Build is passing
chore(ci/cd): add cache (#94)
Reviewed-on: twhelp/core#94
2022-10-05 06:45:22 +00:00

266 lines
6.5 KiB
YAML

---
kind: pipeline
type: docker
name: test
steps:
- name: restore-cache
image: meltwater/drone-cache:v1.3.0
environment:
AWS_ACCESS_KEY_ID:
from_secret: s3_access_key
AWS_SECRET_ACCESS_KEY:
from_secret: s3_secret_key
settings:
restore: true
cache_key: "{{ .Repo.Owner }}_{{ .Repo.Name }}_{{ checksum \"go.mod\" }}_{{ checksum \"go.sum\" }}_{{ arch }}_{{ os }}"
bucket: drone-cache
region: eu-central-1
path_style: true
endpoint: https://minio.dwysokinski.me
mount:
- .cache/test/go-mod
- .cache/test/go-build
- name: test
image: golang:1.19
environment:
TESTS_DB_DSN: postgres://postgres:twhelptest@database:5432/twhelptest?sslmode=disable
GOMODCACHE: /drone/src/.cache/test/go-mod
GOCACHE: /drone/src/.cache/test/go-build
commands:
- make generate
- go test -race -coverprofile=coverage.txt -covermode=atomic ./...
- name: rebuild-cache
image: meltwater/drone-cache:v1.3.0
environment:
AWS_ACCESS_KEY_ID:
from_secret: s3_access_key
AWS_SECRET_ACCESS_KEY:
from_secret: s3_secret_key
settings:
rebuild: true
cache_key: "{{ .Repo.Owner }}_{{ .Repo.Name }}_{{ checksum \"go.mod\" }}_{{ checksum \"go.sum\" }}_{{ arch }}_{{ os }}"
bucket: drone-cache
region: eu-central-1
path_style: true
endpoint: https://minio.dwysokinski.me
mount:
- .cache/test/go-mod
- .cache/test/go-build
services:
- name: database
image: postgres:14.5
environment:
POSTGRES_DB: twhelptest
POSTGRES_PASSWORD: twhelptest
trigger:
event:
- push
- pull_request
branch:
- master
---
kind: pipeline
type: docker
name: check-go-mod
steps:
- name: restore-cache
image: meltwater/drone-cache:v1.3.0
environment:
AWS_ACCESS_KEY_ID:
from_secret: s3_access_key
AWS_SECRET_ACCESS_KEY:
from_secret: s3_secret_key
settings:
restore: true
cache_key: "{{ .Repo.Owner }}_{{ .Repo.Name }}_{{ checksum \"go.mod\" }}_{{ checksum \"go.sum\" }}_{{ arch }}_{{ os }}"
bucket: drone-cache
region: eu-central-1
path_style: true
endpoint: https://minio.dwysokinski.me
mount:
- .cache/gomod/go-mod
- .cache/gomod/go-build
- name: check go.mod
image: golang:1.19
environment:
GOMODCACHE: /drone/src/.cache/gomod/go-mod
GOCACHE: /drone/src/.cache/gomod/go-build
commands:
- make generate
- go mod tidy
- git diff --exit-code go.mod
- name: rebuild-cache
image: meltwater/drone-cache:v1.3.0
environment:
AWS_ACCESS_KEY_ID:
from_secret: s3_access_key
AWS_SECRET_ACCESS_KEY:
from_secret: s3_secret_key
settings:
rebuild: true
cache_key: "{{ .Repo.Owner }}_{{ .Repo.Name }}_{{ checksum \"go.mod\" }}_{{ checksum \"go.sum\" }}_{{ arch }}_{{ os }}"
bucket: drone-cache
region: eu-central-1
path_style: true
endpoint: https://minio.dwysokinski.me
mount:
- .cache/gomod/go-mod
- .cache/gomod/go-build
trigger:
event:
- push
- pull_request
branch:
- master
---
kind: pipeline
type: docker
name: golangci-lint
steps:
- name: restore-cache
image: meltwater/drone-cache:v1.3.0
environment:
AWS_ACCESS_KEY_ID:
from_secret: s3_access_key
AWS_SECRET_ACCESS_KEY:
from_secret: s3_secret_key
settings:
restore: true
cache_key: "{{ .Repo.Owner }}_{{ .Repo.Name }}_{{ checksum \"go.mod\" }}_{{ checksum \"go.sum\" }}_{{ arch }}_{{ os }}"
bucket: drone-cache
region: eu-central-1
path_style: true
endpoint: https://minio.dwysokinski.me
mount:
- .cache/lint/go-mod
- .cache/lint/go-build
- .cache/lint/golangci-lint
- name: golangci-lint
image: golangci/golangci-lint:v1.50
environment:
GOMODCACHE: /drone/src/.cache/lint/go-mod
GOCACHE: /drone/src/.cache/lint/go-build
GOLANGCI_LINT_CACHE: /drone/src/.cache/lint/golangci-lint
commands:
- make generate
- golangci-lint run
- name: rebuild-cache
image: meltwater/drone-cache:v1.3.0
environment:
AWS_ACCESS_KEY_ID:
from_secret: s3_access_key
AWS_SECRET_ACCESS_KEY:
from_secret: s3_secret_key
settings:
rebuild: true
cache_key: "{{ .Repo.Owner }}_{{ .Repo.Name }}_{{ checksum \"go.mod\" }}_{{ checksum \"go.sum\" }}_{{ arch }}_{{ os }}"
bucket: drone-cache
region: eu-central-1
path_style: true
endpoint: https://minio.dwysokinski.me
mount:
- .cache/lint/go-mod
- .cache/lint/go-build
- .cache/lint/golangci-lint
trigger:
event:
- push
- pull_request
branch:
- master
---
kind: pipeline
type: docker
name: linux-amd64
platform:
os: linux
arch: amd64
steps:
- name: publish
image: plugins/docker
settings:
username:
from_secret: docker_username
password:
from_secret: docker_password
registry: gitea.dwysokinski.me
repo: gitea.dwysokinski.me/twhelp-packages/core
auto_tag: true
auto_tag_suffix: linux-amd64
dockerfile: ./build/docker/twhelp/prod/Dockerfile
build_args_from_env: [DRONE_TAG]
trigger:
event:
- tag
---
kind: pipeline
type: docker
name: manifest
steps:
- name: manifest
image: plugins/manifest
settings:
auto_tag: "true"
ignore_missing: "true"
spec: ./build/docker/twhelp/prod/manifest.tmpl
username:
from_secret: docker_username
password:
from_secret: docker_password
- name: manifest-latest
image: plugins/manifest
settings:
tags: latest
ignore_missing: "true"
spec: ./build/docker/twhelp/prod/manifest.tmpl
username:
from_secret: docker_username
password:
from_secret: docker_password
trigger:
event:
- tag
depends_on:
- linux-amd64
---
kind: pipeline
type: docker
name: deploy
steps:
- name: deploy-k8s
image: alpine/k8s:1.25.0
environment:
KUBECONFIG:
from_secret: kubeconfig
commands:
- "mkdir ~/.kube && echo \"$KUBECONFIG\" > ~/.kube/twhelp"
- "cd ./k8s/overlays/prod && kustomize edit set image twhelp=gitea.dwysokinski.me/twhelp-packages/core:${DRONE_TAG##v} && cd ../../.."
- "kubectl --kubeconfig ~/.kube/twhelp -n twhelp delete jobs.batch twhelp-migrations-job || true"
- kustomize build ./k8s/overlays/prod | kubectl --kubeconfig ~/.kube/twhelp apply -n twhelp -f -
trigger:
event:
- tag
depends_on:
- manifest