This commit is contained in:
2026-05-17 22:25:41 +03:00
parent 7345f498ca
commit 3a5810fae8

75
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,75 @@
# GitLab CI/CD пайплайн для Go (вариант 13)
# Автор: Коробов Ф
# Дата: 2026
stages:
- lint
- test
- build
variables:
GO_VERSION: "1.21"
CGO_ENABLED: "0"
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .cache/go-mod
lint:
stage: lint
image: golang:${GO_VERSION}
before_script:
- mkdir -p .cache/go-mod
- export GOPATH=$CI_PROJECT_DIR/.cache
- go mod download
script:
- echo "=== Lint: go vet ==="
- go vet ./...
allow_failure: false
only:
- main
- merge_requests
test:
stage: test
image: golang:${GO_VERSION}
before_script:
- mkdir -p .cache/go-mod
- export GOPATH=$CI_PROJECT_DIR/.cache
- go mod download
script:
- echo "=== Test: go test with coverage ==="
- go test -v -coverprofile=coverage.out ./...
- go tool cover -func=coverage.out
- go tool cover -html=coverage.out -o coverage.html
artifacts:
name: "coverage_report"
paths:
- coverage.out
- coverage.html
expire_in: 1 week
coverage: '/^total:\s+\(statements\)\s+(\d+\.\d+)%/'
only:
- main
- merge_requests
build:
stage: build
image: golang:${GO_VERSION}
before_script:
- mkdir -p .cache/go-mod
- export GOPATH=$CI_PROJECT_DIR/.cache
- go mod download
script:
- echo "=== Build: go build ==="
- go build -o app-variant-13 ./...
artifacts:
name: "binary_${CI_COMMIT_SHORT_SHA}"
paths:
- app-variant-13
expire_in: 1 hour
only:
- main
- tags