1
0
Fork 0
This repository has been archived on 2025-09-02. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
mareshq-yggdrasil/.gitlab-ci.yml

84 lines
2.5 KiB
YAML

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
- helm template ./deploy --values deploy/values.test.yaml
build:httpserver:
stage: build
variables:
IMAGE: $CI_REGISTRY_IMAGE/httpserver
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 yggdrasil --use
- docker buildx build --provenance=false --platform linux/amd64,linux/arm64 -t $IMAGE:$TAG -f build/package/httpserver/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 yggdrasil --use
- docker buildx build --provenance=false --platform linux/amd64,linux/arm64 -t $IMAGE:$TAG -f build/package/migrations/Dockerfile --push .
- docker manifest inspect $IMAGE:$TAG
deploy:staging:
stage: deploy
image: ghcr.io/vojtechmares/toolkit:latest
rules:
- if: $CI_COMMIT_BRANCH == "main"
variables:
TAG: $CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA
NAMESPACE: yggdrasil-staging
GIT_DEPTH: 1 # shallow clone
environment:
name: staging
url: https://staging.yggdrasil.vmdevel.cz
script:
- >
helm upgrade --install --namespace $NAMESPACE --create-namespace \
api ./deploy \
--values deploy/values.staging.yaml \
--set image.tag=$TAG \
--set migrations.image.tag=$TAG \
--set imageCredentials.username=$REGISTRY_USERNAME \
--set imageCredentials.password=$REGISTRY_PASSWORD \
--set config.database.url=$DATABASE_URL