simplify ci

This commit is contained in:
Aine
2023-10-17 15:04:20 +03:00
parent b659ab8915
commit ea74eda6fc
2 changed files with 16 additions and 11 deletions

View File

@@ -1,28 +1,24 @@
stages:
- test
- release
default:
image: registry.gitlab.com/etke.cc/base/build
variables:
PLATFORMS: linux/arm64/v8,linux/amd64
lint:
stage: test
image: registry.gitlab.com/etke.cc/base/build
script:
- just lint
unit:
stage: test
image: registry.gitlab.com/etke.cc/base/build
script:
- just test
docker:
stage: release
only: ['main', 'tags']
services:
- docker:dind
image: docker
before_script:
- apk --no-cache add git just --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
services: ['docker:dind']
script:
- just login docker
tags:
- docker

View File

@@ -1,5 +1,6 @@
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") }
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)
gitlab_image := "registry." + repo + ":" + tag
etke_image := replace(gitlab_image, "gitlab.com", "etke.cc")
@@ -23,6 +24,14 @@ lint:
lintfix:
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
test:
@go test -cover -coverprofile=cover.out -coverpkg=./... -covermode=set ./...
@@ -44,4 +53,4 @@ login:
# docker build
docker:
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 }} .