ssube/prometheus-sql-adapter

View on GitHub
.gitlab-ci.yml

Summary

Maintainability
Test Coverage
include:
  - local: /.gitlab/tools.yml
  - local: /.gitlab/test.yml

stages:
  - status-pre
  - test
  - image
  - status-post

# image jobs
build-image-postgres-10-branch:
  extends:
    - .build-docker
  stage: image
  except:
    - tags
  script:
    - make build-image
  variables:
    IMAGE_ARGS: --push
    IMAGE_ARCH: postgres-10

build-image-postgres-10-tag:
  extends:
    - .build-docker
  stage: image
  only:
    - tags
  script:
    - make build-image
  variables:
    IMAGE_ARGS: --push
    IMAGE_ARCH: postgres-10

build-image-postgres-11-branch:
  extends:
    - .build-docker
  stage: image
  except:
    - tags
  script:
    - make build-image
  variables:
    IMAGE_ARGS: --push
    IMAGE_ARCH: postgres-11

build-image-postgres-11-tag:
  extends:
    - .build-docker
  stage: image
  only:
    - tags
  script:
    - make build-image
  variables:
    IMAGE_ARGS: --push
    IMAGE_ARCH: postgres-11

build-image-psql-10-branch:
  extends:
    - .build-docker
  stage: image
  except:
    - tags
  script:
    - make build-image
  variables:
    IMAGE_ARGS: --push
    IMAGE_ARCH: psql-10

build-image-psql-10-tag:
  extends:
    - .build-docker
  stage: image
  only:
    - tags
  script:
    - make build-image
  variables:
    IMAGE_ARGS: --push
    IMAGE_ARCH: psql-10

build-image-psql-11-branch:
  extends:
    - .build-docker
  stage: image
  except:
    - tags
  script:
    - make build-image
  variables:
    IMAGE_ARGS: --push
    IMAGE_ARCH: psql-11

build-image-psql-11-tag:
  extends:
    - .build-docker
  stage: image
  only:
    - tags
  script:
    - make build-image
  variables:
    IMAGE_ARGS: --push
    IMAGE_ARCH: psql-11

# test jobs
test-go:
  extends:
    - .build-go
  stage: test
  script:
    - mkdir out
    - go test -coverprofile=out/cover.out ./...
    - go tool cover -html=out/cover.out -o=out/cover.html
    - go tool cover -func=out/cover.out
  artifacts:
    expire_in: 1 week
    paths:
      - out/cover.*

bench-go:
  extends:
    - test-go
  when: manual
  allow_failure: true
  script:
    - mkdir out
    - go test -bench=. -benchtime=5s -coverprofile=out/cover.out ./...
    - go tool cover -html=out/cover.out -o=out/cover.html

test-schema-compat-pg10:
  extends:
    - .test-pgtap-10
    - .test-schema-compat
  variables:
    PG_MAJOR: "10"

test-schema-compat-pg11:
  extends:
    - .test-pgtap-11
    - .test-schema-compat
  variables:
    PG_MAJOR: "11"

test-schema-promsql-pg10:
  extends:
    - .test-pgtap-10
    - .test-schema-promsql
  variables:
    PG_MAJOR: "10"

test-schema-promsql-pg11:
  extends:
    - .test-pgtap-11
    - .test-schema-promsql
  variables:
    PG_MAJOR: "11"

test-schema-pgprom-pg10:
  extends:
    - .test-pgtap-10
    - .test-schema-pgprom
  variables:
    PG_MAJOR: "10"

test-schema-pgprom-pg11:
  extends:
    - .test-pgtap-11
    - .test-schema-pgprom
  variables:
    PG_MAJOR: "11"

# commit status
climate-pending:
  stage: status-pre
  extends:
    - .build-climate

  script:
    - cc-test-reporter before-build

climate-success:
  stage: status-post
  extends:
    - .build-climate

  dependencies:
    - test-go
  script:
    # cc is overly picky about paths, so fix them up
    - |
      cat out/cover.out | sed "s+github.com\\/ssube\\/prometheus-sql-adapter+${PWD}+" > c.out
    - make upload-climate

codecov-success:
  stage: status-post
  extends:
    - .build-codecov
  when: on_success
  dependencies:
    - test-go
  script:
    - make upload-codecov

# github jobs
github-pending:
  stage: status-pre
  extends:
    - .build-curl
  script:
    - ./scripts/github-status.sh pending

github-failure:
  stage: status-post
  extends:
    - .build-curl
  when: on_failure
  script:
    - ./scripts/github-status.sh failure

github-success:
  stage: status-post
  extends:
    - .build-curl
  when: on_success
  script:
    - ./scripts/github-status.sh success