.gitlab-ci.yml 2.02 KB
Newer Older
Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
1
stages:
2
3
4
  - build
  - test
  - deploy
Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
5
6
7
8
9

# Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-a-service
services:
10
  - docker:18-dind
Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
11
12
13
14
15
16
17
18
19
20

variables:
  POSTGRES_DB: postgres

# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
  paths:
  - ~/.cache/pip/

21
build-backend:
22
23
24
25
26
27
28
  image: docker:latest
  stage: build
  script:
    - sh ci/build/build_backend.sh
  tags:
    - k8s

29
build-frontend:
30
31
32
33
  image: docker:latest
  stage: build
  script:
    - sh ci/build/build_frontend.sh
34
  variables:
35
    VUE_APP_TITLE: "MetageneDB"
36
37
  tags:
    - k8s
Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
38
39

test-backend:
40
41
  image: $CI_REGISTRY_IMAGE/backend:${CI_COMMIT_REF_NAME}
  services:
42
    - postgres:12.2-alpine
43
    - redis:alpine
44
  stage: test
Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
45
  variables:
46
47
48
49
    DATABASE_HOST: postgres
    POSTGRES_USER: postgres
    POSTGRES_DB: postgres
    POSTGRES_PASSWORD: ""
Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
50
    DJANGO_SETTINGS_MODULE: "metagenedb.settings-gitlab-ci"
51
52
    REDIS_HOST: "localhost"
    CACHE_TTL: "0"
Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
53
  script:
54
    - apt-get install -y postgresql-client
55
56
    - cd backend
    - pipenv install --dev --system --deploy
Kenzo-Hugo Hillion's avatar
Kenzo-Hugo Hillion committed
57
    - flake8 --max-line-length 120
58
    # - until pg_isready -h ${DATABASE_HOST}; do echo waiting; sleep 2; done;
59
    # - pytest --cov .
60

61
deploy-dev:
62
63
64
65
66
  stage: deploy
  image: registry-gitlab.pasteur.fr/dsi-tools/docker-images:docker_kubernetes_image
  variables:
    NAMESPACE: ${CI_PROJECT_NAME}-dev
  environment:
67
    name: k8sdev-01-${CI_PROJECT_NAME}-dev
68
    url: https://${CI_PROJECT_NAME}-dev.pasteur.cloud
69
70
71
72
  script:
    - sh ci/deploy/deploy.sh
  tags:
    - k8s
73
74
75
76
  only:
    refs:
      - dev

77
78
79
80
81
82
deploy-prod:
  stage: deploy
  image: registry-gitlab.pasteur.fr/dsi-tools/docker-images:docker_kubernetes_image
  variables:
    NAMESPACE: ${CI_PROJECT_NAME}
  environment:
83
    name: k8sprod-02-${CI_PROJECT_NAME}
84
85
86
87
88
89
90
91
    url: https://${CI_PROJECT_NAME}.pasteur.cloud
  script:
    - sh ci/deploy/deploy.sh
  tags:
    - k8s
  only:
    refs:
      - master