EOX GitLab Instance

.gitlab-ci.yml 2.41 KB
Newer Older
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
6

Fabian Schindler's avatar
Fabian Schindler committed
7
8
variables:
  DOCKER_TLS_CERTDIR: ""
9
  SERVICE_NAME: "vs-harvester"
Fabian Schindler's avatar
Fabian Schindler committed
10

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

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

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

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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80


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

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

    - export BRANCH_NAME="auto-update-${SERVICE_NAME}-${CHART_VERSION}"
    - 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
    - ../yq_linux_amd64 eval "( .dependencies[] | select(.name == \"${SERVICE_NAME}\") | .version ) = \"${CHART_VERSION}\"" --inplace Chart.yaml
    - helm dependency update
    - git add charts/*
    - git commit --all -m "Bump ${SERVICE_NAME} to ${CHART_VERSION}"
    - git push --set-upstream origin "${BRANCH_NAME}"
  only:
    - tags