EOX GitLab Instance

.gitlab-ci.yml 2.47 KB
Newer Older
Nikola Jankovic's avatar
Nikola Jankovic committed
1
2
stages:
  - test
Nikola Jankovic's avatar
Nikola Jankovic committed
3
  - publish
Nikola Jankovic's avatar
Nikola Jankovic committed
4
  - chart
5
  - integration_test
Nikola Jankovic's avatar
Nikola Jankovic committed
6
7
8

variables:
  DOCKER_TLS_CERTDIR: ""
9
  SERVICE_NAME: "vs-scheduler"
Nikola Jankovic's avatar
Nikola Jankovic committed
10
11
12
13
14
15
16

test:
  image: python:3.8-slim
  stage: test
  script:
    - python3 setup.py install
    - pip3 install -r requirements-test.txt
Bernhard Mallinger's avatar
Bernhard Mallinger committed
17
    - pip3 install -r requirements-dev.txt
18
    - pytest --cov scheduler --cov-report term-missing
Bernhard Mallinger's avatar
Bernhard Mallinger committed
19
20
    - flake8
    - mypy .
Nikola Jankovic's avatar
Nikola Jankovic committed
21
  coverage: "/TOTAL.+ ([0-9]{1,3}%)/"
Nikola Jankovic's avatar
Nikola Jankovic committed
22

Nikola Jankovic's avatar
Nikola Jankovic committed
23
publish_latest:
Nikola Jankovic's avatar
Nikola Jankovic committed
24
25
26
  image: docker:20.10.8
  services:
    - docker:20.10.8-dind
Nikola Jankovic's avatar
Nikola Jankovic committed
27
  stage: publish
Nikola Jankovic's avatar
Nikola Jankovic committed
28
29
30
31
  script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
    - docker build -t $CI_REGISTRY_IMAGE .
    - docker push $CI_REGISTRY_IMAGE:latest
Nikola Jankovic's avatar
Nikola Jankovic committed
32
33
  only:
    - master
Nikola Jankovic's avatar
Nikola Jankovic committed
34

Nikola Jankovic's avatar
Nikola Jankovic committed
35
publish:
Nikola Jankovic's avatar
Nikola Jankovic committed
36
37
38
  image: docker:20.10.8
  services:
    - docker:20.10.8-dind
Nikola Jankovic's avatar
Nikola Jankovic committed
39
  stage: publish
Nikola Jankovic's avatar
Nikola Jankovic committed
40
41
  script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
Nikola Jankovic's avatar
Nikola Jankovic committed
42
43
    - docker build --cache-from $CI_REGISTRY_IMAGE:latest -t $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG .
    - docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
Nikola Jankovic's avatar
Nikola Jankovic committed
44
45
  only:
    - tags
Nikola Jankovic's avatar
Nikola Jankovic committed
46
47
48
49
50
51
52
53
54
55

helm:
  image: devth/helm:v3.6.3
  stage: chart
  script:
    # push Helm chart
    - "upload_filename=$(helm package ./chart | sed 's/^Successfully packaged chart and saved it to: \\(.*\\)/\\1/')"
    - curl -u $HELM_CHART_REPOSITORY_CREDENTIALS -v -X POST https://charts-public.hub.eox.at/api/charts --data-binary "@${upload_filename}"
  only:
    - tags
56
57
58
59
60
61
62
63
64
65

integration_test:
  image: devth/helm:v3.6.3
  stage: integration_test
  script:
    - wget -q https://github.com/mikefarah/yq/releases/download/v4.14.2/yq_linux_amd64.tar.gz -O - | tar xvfz - && chmod +x yq_linux_amd64
    # for testing:
    # - export SERVICE_NAME=postgresql
    # - export CI_COMMIT_TAG=10.12.1

66
67
    - export CHART_VERSION=$(./yq_linux_amd64 eval .version  chart/Chart.yaml)

68
69
70
71
72
73
74
    - export BRANCH_NAME="auto-update-${SERVICE_NAME}-${CI_COMMIT_TAG}"
    - git config --global user.email "gitlab@eox.at"
    - git config --global user.name "gitlab"
    - git clone https://${VS_DEPLOYMENT_GIT_REPOSITORY_CREDENTIALS}@gitlab.eox.at/vs/vs-deployment.git
    - cd vs-deployment
    - git switch -c "${BRANCH_NAME}"
    # bump version in Chart.yaml
75
    - ../yq_linux_amd64 eval "( .dependencies[] | select(.name == \"${SERVICE_NAME}\") | .version ) = \"${CHART_VERSION}\"" --inplace Chart.yaml
76
77
78
79
80
81
    - helm dependency update
    - git add charts/*
    - git commit --all -m "Bump ${SERVICE_NAME} to ${CI_COMMIT_TAG}"
    - git push --set-upstream origin "${BRANCH_NAME}"
  only:
    - tags