Skip to content
Snippets Groups Projects
.gitlab-ci.yml 7.67 KiB
image: golang:1.19

stages:
  - prepare
  - test
  - build
  - deploy
  - test-build
  - release

variables:
  GOPATH: "$CI_PROJECT_DIR/.gopath"
  GOFLAGS: -mod=readonly
  OPENAPI_JSON: ./public/api.json

.release-rules: &release-rules
  # rule to run job on a tag-reference which has the form number.number.number (semantic versioning)
  # or number.number.number-text (semantic versioning + release-name)
  # and where a Dockerfile exists
  - if: $CI_COMMIT_TAG =~ /^\d+[.]\d+[.]\d+$/ || $CI_COMMIT_TAG =~ /^\d+[.]\d+[.]\d+[-]\S+$/
    exists:
      - Dockerfile

cache:
  paths:
    - .gopath/
    - ui/assets_vfsdata.go
  key: default
  policy: pull

prepare:
  stage: prepare
  cache:
    policy: pull-push
  script:
    - mkdir -p .gopath
    - export GOPATH="$CI_PROJECT_DIR/.gopath"
    - go generate ./ui
    - go vet ./...

test-all-but-store:
  stage: test
  script:
    - go test -v -cover $(go list ./... | grep -v tank/store)

test-store-postgres:
  stage: test
  services:
    - postgres:14
  variables:
    POSTGRES_DB: "tank"
    POSTGRES_USER: "tank"
    POSTGRES_PASSWORD: "aura"
    AURA_TANK_TEST_DB_TYPE: "postgres"
    AURA_TANK_TEST_DB_HOST: "postgres"
  script:
    - go run contrib/waitfor-tcp.go postgres:5432 30
    - go test -v -cover ./store

build:
  stage: build
  script:
    # we should actually use `make build` here, see #30
    - go build -ldflags "-extldflags '-static'" -tags netgo -o $CI_PROJECT_DIR/tank ./cmd/tank
    ## sqlite needs cgo... :(
    ##- go build -o $CI_PROJECT_DIR/tank ./cmd/tank
  only:
    - master
  artifacts:
    paths: