feat(ci/cd): add cache (#7)
continuous-integration/drone/push Build is passing Details

Reviewed-on: #7
This commit is contained in:
Dawid Wysokiński 2022-10-09 06:43:34 +00:00
parent 6c2c061b87
commit eae331cef1
1 changed files with 119 additions and 1 deletions

View File

@ -4,13 +4,49 @@ 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:dcbot@database:5432/dcbot?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
@ -32,12 +68,49 @@ 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:
@ -52,15 +125,60 @@ 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: run 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
- master
---
kind: signature
hmac: c5bccb8f6ef7e978d2218f0330feb1e01875c06cfc3e0d9dc60b9d1365a1741f
...