mirror of https://github.com/dirtbags/moth.git
62 lines
1.3 KiB
YAML
62 lines
1.3 KiB
YAML
stages:
|
|
- test
|
|
- build
|
|
- push
|
|
|
|
Run unit tests:
|
|
stage: test
|
|
image: &goimage golang:1.21
|
|
only:
|
|
refs:
|
|
- main
|
|
- tags
|
|
- merge_requests
|
|
script:
|
|
- go test -coverprofile=coverage.txt -covermode=atomic -race ./...
|
|
- go tool cover -html=coverage.txt -o coverage.html
|
|
- go tool cover -func coverage.txt
|
|
coverage: /\(statements\)(?:\s+)?(\d+(?:\.\d+)?%)/
|
|
artifacts:
|
|
paths:
|
|
- coverage.html
|
|
- coverage.txt
|
|
Generage coverage XML:
|
|
stage: test
|
|
image: *goimage
|
|
needs: ["Run unit tests"]
|
|
script:
|
|
- go get github.com/boumenot/gocover-cobertura
|
|
- go run github.com/boumenot/gocover-cobertura < coverage.txt > coverage.xml
|
|
only:
|
|
refs:
|
|
- main
|
|
- tags
|
|
- merge_requests
|
|
artifacts:
|
|
reports:
|
|
coverage_report:
|
|
coverage_format: cobertura
|
|
path: coverage.xml
|
|
|
|
winbuild:
|
|
stage: build
|
|
image: *goimage
|
|
needs: ["Run unit tests"]
|
|
script:
|
|
- GOOS=windows GOARCH=amd64 go build ./cmd/mothd
|
|
artifacts:
|
|
paths:
|
|
- mothd.exe
|
|
- theme/*
|
|
|
|
push:
|
|
stage: push
|
|
needs: ["Run unit tests"]
|
|
rules:
|
|
- if: $CI_COMMIT_TAG
|
|
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
|
script:
|
|
- mkdir ~/.docker
|
|
- echo "$DOCKER_AUTH_CONFIG" | tee ~/.docker/config.json | md5sum
|
|
- sh build/ci/ci.sh publish
|