1
0
Fork 0

ci: add .gitlab-ci.yml

This commit is contained in:
Vojtěch Mareš 2024-10-10 21:30:53 +02:00
parent cbaa5272ef
commit c6f6638416
Signed by: vojtech.mares
GPG key ID: C6827B976F17240D

61
.gitlab-ci.yml Normal file
View file

@ -0,0 +1,61 @@
default:
image: docker:git
stages:
- test
- build
- deploy
test:go:
stage: test
image: golang:alpine
variables:
GOPATH: $CI_PROJECT_DIR/.go
before_script:
- mkdir -p .go
script:
- go mod download
- go test ./... -v -coverprofile=coverage.txt -covermode count
- go get github.com/boumenot/gocover-cobertura
- go run github.com/boumenot/gocover-cobertura < coverage.txt > coverage.xml
cache:
paths:
- .go/pkg/mod/
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
test:helm:
stage: test
image: ghcr.io/vojtechmares/toolkit:latest
script:
- helm lint ./deploy/k8s
- helm template ./deploy/k8s --values deploy/k8s/values.test.yaml
build:api:
stage: build
variables:
IMAGE: $CI_REGISTRY_IMAGE/api
TAG: $CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
before_script:
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
- docker info
script:
- docker buildx create --name backoffice-api --use
- docker buildx build --provenance=false --platform linux/arm64 -t $IMAGE:$TAG -f build/package/api/Dockerfile --push .
- docker manifest inspect $IMAGE:$TAG
build:migrations:
stage: build
variables:
IMAGE: $CI_REGISTRY_IMAGE/migrations
TAG: $CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
before_script:
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
- docker info
script:
- docker buildx create --name backoffice-api --use
- docker buildx build --provenance=false --platform linux/arm64 -t $IMAGE:$TAG -f build/package/migrations/Dockerfile --push .
- docker manifest inspect $IMAGE:$TAG