simplify ci
This commit is contained in:
@@ -1,28 +1,24 @@
|
|||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
- release
|
- release
|
||||||
|
default:
|
||||||
|
image: registry.gitlab.com/etke.cc/base/build
|
||||||
|
variables:
|
||||||
|
PLATFORMS: linux/arm64/v8,linux/amd64
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
stage: test
|
stage: test
|
||||||
image: registry.gitlab.com/etke.cc/base/build
|
|
||||||
script:
|
script:
|
||||||
- just lint
|
- just lint
|
||||||
|
|
||||||
unit:
|
unit:
|
||||||
stage: test
|
stage: test
|
||||||
image: registry.gitlab.com/etke.cc/base/build
|
|
||||||
script:
|
script:
|
||||||
- just test
|
- just test
|
||||||
|
|
||||||
docker:
|
docker:
|
||||||
stage: release
|
stage: release
|
||||||
only: ['main', 'tags']
|
only: ['main', 'tags']
|
||||||
services:
|
services: ['docker:dind']
|
||||||
- docker:dind
|
|
||||||
image: docker
|
|
||||||
before_script:
|
|
||||||
- apk --no-cache add git just --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
|
|
||||||
script:
|
script:
|
||||||
- just login docker
|
- just login docker
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|||||||
11
justfile
11
justfile
@@ -1,3 +1,4 @@
|
|||||||
|
platforms := env_var_or_default("PLATFORMS", "linux/amd64")
|
||||||
tag := if env_var_or_default("CI_COMMIT_TAG", "main") == "main" { "latest" } else { env_var_or_default("CI_COMMIT_TAG", "latest") }
|
tag := if env_var_or_default("CI_COMMIT_TAG", "main") == "main" { "latest" } else { env_var_or_default("CI_COMMIT_TAG", "latest") }
|
||||||
repo := trim_end_match(replace(replace_regex(env_var_or_default("CI_REPOSITORY_URL", `git remote get-url origin`), ".*@|", ""), ":", "/"), ".git")
|
repo := trim_end_match(replace(replace_regex(env_var_or_default("CI_REPOSITORY_URL", `git remote get-url origin`), ".*@|", ""), ":", "/"), ".git")
|
||||||
project := file_name(repo)
|
project := file_name(repo)
|
||||||
@@ -23,6 +24,14 @@ lint:
|
|||||||
lintfix:
|
lintfix:
|
||||||
golangci-lint run --fix ./...
|
golangci-lint run --fix ./...
|
||||||
|
|
||||||
|
# generate mocks
|
||||||
|
mocks:
|
||||||
|
@mockery --all --inpackage --testonly --exclude vendor
|
||||||
|
|
||||||
|
# run cpu or mem profiler UI
|
||||||
|
profile type:
|
||||||
|
go tool pprof -http 127.0.0.1:8000 .pprof/{{ type }}.prof
|
||||||
|
|
||||||
# run unit tests
|
# run unit tests
|
||||||
test:
|
test:
|
||||||
@go test -cover -coverprofile=cover.out -coverpkg=./... -covermode=set ./...
|
@go test -cover -coverprofile=cover.out -coverpkg=./... -covermode=set ./...
|
||||||
@@ -44,4 +53,4 @@ login:
|
|||||||
# docker build
|
# docker build
|
||||||
docker:
|
docker:
|
||||||
docker buildx create --use
|
docker buildx create --use
|
||||||
docker buildx build --pull --platform linux/arm64/v8,linux/amd64 --push -t {{ gitlab_image }} -t {{ etke_image }} .
|
docker buildx build --pull --platform {{ platforms }} --push -t {{ gitlab_image }} -t {{ etke_image }} .
|
||||||
|
|||||||
Reference in New Issue
Block a user