From f172e54b12f24de1052d77625bc1ea4668d420b0 Mon Sep 17 00:00:00 2001 From: Maxim Lebedev Date: Sun, 1 Aug 2021 22:18:19 +0500 Subject: [PATCH] :construction_worker: Improved GitLab CI/CD configuration --- .gitlab-ci.yml | 47 +++++++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dec44bc..f99d5c7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,39 +1,50 @@ +--- image: golang:alpine variables: - GO111MOD: "on" + REPO_NAME: gitlab.com/$CI_PROJECT_PATH CGO_ENABLED: "0" - GOOS: "linux" cache: key: ${CI_COMMIT_REF_SLUG} paths: - - /var/cache/apk - /go/pkg/mod + - /var/cache/apk + +before_script: + - mkdir -p $GOPATH/src/$(dirname $REPO_NAME) + - ln -svf $CI_PROJECT_DIR $GOPATH/src/$REPO_NAME + - cd $GOPATH/src/$REPO_NAME stages: - test - - review -before_script: - - apk add --no-cache git make - - go get github.com/golangci/golangci-lint/cmd/golangci-lint - - go install github.com/golangci/golangci-lint/cmd/golangci-lint - - make tidy - -unit_tests: +test: stage: test + before_script: + - go get gotest.tools/gotestsum script: - - make test + - gotestsum --junitfile report.xml --format testname + artifacts: + when: always + reports: + junit: report.xml -code_coverage: +cover: stage: test + before_script: + - go get github.com/t-yuki/gocover-cobertura script: - - make coverage - coverage: '/^coverage:\s(\d+(?:\.\d+)?%)/' + - go test -coverprofile=coverage.txt -covermode count $REPO_NAME/... + - gocover-cobertura < coverage.txt > coverage.xml + artifacts: + reports: + cobertura: coverage.xml -lint_code: - stage: review +lint: + stage: test + before_script: + - wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.41.1 script: - - make lint + - ./bin/golangci-lint run allow_failure: true