2023-09-09 05:43:58 +00:00
|
|
|
when:
|
|
|
|
- event: [pull_request]
|
|
|
|
- event: push
|
|
|
|
branch:
|
|
|
|
- ${CI_REPO_DEFAULT_BRANCH}
|
|
|
|
|
|
|
|
variables:
|
2024-04-30 08:16:55 +00:00
|
|
|
- &go_image 'golang:1.22'
|
2023-09-09 05:43:58 +00:00
|
|
|
|
|
|
|
services:
|
|
|
|
database:
|
2024-04-30 08:16:55 +00:00
|
|
|
image: postgres:14
|
|
|
|
pull: true
|
2023-09-09 05:43:58 +00:00
|
|
|
environment:
|
|
|
|
POSTGRES_DB: dcbot
|
|
|
|
POSTGRES_PASSWORD: dcbot
|
|
|
|
redis:
|
2023-10-30 08:28:14 +00:00
|
|
|
image: redis:7.2.2
|
2023-09-09 05:43:58 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
generate:
|
|
|
|
image: *go_image
|
|
|
|
pull: true
|
|
|
|
commands:
|
|
|
|
- make generate
|
2024-04-30 08:16:55 +00:00
|
|
|
- go mod vendor
|
2023-09-09 05:43:58 +00:00
|
|
|
|
|
|
|
test:
|
|
|
|
image: *go_image
|
2024-04-30 08:16:55 +00:00
|
|
|
depends_on:
|
|
|
|
- generate
|
2023-09-09 05:43:58 +00:00
|
|
|
pull: true
|
|
|
|
environment:
|
|
|
|
TESTS_DB_DSN: postgres://postgres:dcbot@database:5432/dcbot?sslmode=disable
|
|
|
|
TESTS_REDIS_CONNECTION_STRING: redis://:@redis:6379/0
|
|
|
|
commands:
|
2024-05-12 06:12:20 +00:00
|
|
|
- go test -parallel 2 -race -coverprofile=coverage.txt -covermode=atomic ./...
|
2023-09-09 05:43:58 +00:00
|
|
|
|
|
|
|
lint:
|
2024-04-30 08:16:55 +00:00
|
|
|
image: golangci/golangci-lint:v1.57
|
2023-09-09 05:43:58 +00:00
|
|
|
pull: true
|
2024-04-30 08:16:55 +00:00
|
|
|
depends_on:
|
|
|
|
- generate
|
2023-09-09 05:43:58 +00:00
|
|
|
commands:
|
|
|
|
- golangci-lint run
|
|
|
|
|
|
|
|
check-go-mod:
|
|
|
|
image: *go_image
|
2024-04-30 08:16:55 +00:00
|
|
|
depends_on:
|
|
|
|
- generate
|
2023-09-09 05:43:58 +00:00
|
|
|
pull: true
|
|
|
|
commands:
|
|
|
|
- go mod tidy
|
|
|
|
- git diff --exit-code go.mod
|
2023-09-09 06:51:56 +00:00
|
|
|
|
|
|
|
validate-migrations:
|
|
|
|
image: *go_image
|
2024-04-30 08:16:55 +00:00
|
|
|
depends_on:
|
|
|
|
- generate
|
2023-09-09 06:51:56 +00:00
|
|
|
pull: true
|
|
|
|
commands:
|
|
|
|
- make validate-migrations
|