chore(ci/cd): add cache (#94)
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: twhelp/core#94
This commit is contained in:
Dawid Wysokiński 2022-10-05 06:45:22 +00:00
parent 50bbd34b79
commit 3ca323eb82
2 changed files with 116 additions and 3 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: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
@ -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,11 +125,51 @@ type: docker
name: golangci-lint
steps:
- name: run golangci-lint
- 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:
@ -133,7 +246,7 @@ type: docker
name: deploy
steps:
- name: deploy k8s
- name: deploy-k8s
image: alpine/k8s:1.25.0
environment:
KUBECONFIG:

View File

@ -6,6 +6,6 @@ repos:
stages: [commit-msg]
additional_dependencies: ['@commitlint/config-conventional']
- repo: https://github.com/golangci/golangci-lint
rev: v1.49.0
rev: v1.50.0
hooks:
- id: golangci-lint