.gitlab-ci.yml 3.01 KB
Newer Older
1 2
variables:
  IMAGE_NAME: funkwhale/funkwhale
Agate's avatar
Agate committed
3
  IMAGE: $IMAGE_NAME:$CI_COMMIT_REF_NAME
4
  IMAGE_LATEST: $IMAGE_NAME:latest
5
  PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache"
6 7


Agate's avatar
Attempt  
Agate committed
8 9
stages:
  - test
Agate's avatar
Agate committed
10
  - build
11
  - deploy
Agate's avatar
Agate committed
12 13

test_api:
Agate's avatar
Agate committed
14 15
  services:
    - postgres:9.4
Agate's avatar
Agate committed
16
    - redis:3
Agate's avatar
Agate committed
17
  stage: test
18 19
  image: funkwhale/funkwhale:latest
  cache:
Agate's avatar
Agate committed
20
    key: "$CI_PROJECT_ID__pip_cache"
21 22
    paths:
      - "$PIP_CACHE_DIR"
23
  variables:
24
    DJANGO_ALLOWED_HOSTS: "localhost"
Agate's avatar
Agate committed
25
    DATABASE_URL: "postgresql://postgres@postgres/postgres"
26
    FUNKWHALE_URL: "https://funkwhale.ci"
27
    CACHEOPS_ENABLED: "false"
Agate's avatar
Agate committed
28
    DJANGO_SETTINGS_MODULE: config.settings.local
29

Agate's avatar
Agate committed
30
  before_script:
31
    - cd api
Agate's avatar
Agate committed
32 33
    - pip install -r requirements/base.txt
    - pip install -r requirements/local.txt
34
    - pip install -r requirements/test.txt
Agate's avatar
Agate committed
35
  script:
Agate's avatar
Agate committed
36
    - pytest --cov=funkwhale_api tests/
37 38 39 40 41 42 43 44 45 46 47 48 49
  tags:
    - docker


test_front:
  stage: test
  image: node:9
  before_script:
    - cd front

  script:
    - yarn install
    - yarn run unit
50
  cache:
Agate's avatar
Agate committed
51
    key: "$CI_PROJECT_ID__front_dependencies"
52
    paths:
53 54 55 56 57 58
      - front/node_modules
      - front/yarn.lock
  artifacts:
    name: "front_${CI_COMMIT_REF_NAME}"
    paths:
      - front/dist/
Agate's avatar
Agate committed
59
  tags:
60
    - docker
Agate's avatar
Agate committed
61

62

Agate's avatar
Agate committed
63 64
build_front:
  stage: build
65
  image: node:9
Agate's avatar
Agate committed
66 67 68 69
  before_script:
    - cd front

  script:
70
    - yarn install
Agate's avatar
Agate committed
71 72
    - yarn run i18n-extract
    - yarn run i18n-compile
Agate's avatar
Agate committed
73 74 75
    # this is to ensure we don't have any errors in the output,
    # cf https://code.eliotberriot.com/funkwhale/funkwhale/issues/169
    - yarn run build | tee /dev/stderr | (! grep -i 'ERROR in')
Agate's avatar
Agate committed
76
  cache:
Agate's avatar
Agate committed
77
    key: "$CI_PROJECT_ID__front_dependencies"
Agate's avatar
Agate committed
78 79
    paths:
      - front/node_modules
80
      - front/yarn.lock
Agate's avatar
Agate committed
81 82 83 84 85
  artifacts:
    name: "front_${CI_COMMIT_REF_NAME}"
    paths:
      - front/dist/
  only:
86 87 88
    - tags@funkwhale/funkwhale
    - master@funkwhale/funkwhale
    - develop@funkwhale/funkwhale
Agate's avatar
Agate committed
89 90
  tags:
    - docker
91

92

Agate's avatar
Agate committed
93
pages:
Agate's avatar
Attempt  
Agate committed
94
  stage: test
Agate's avatar
Agate committed
95 96 97
  image: python:3.6
  variables:
    BUILD_PATH: "../public"
Agate's avatar
Agate committed
98 99 100 101
  before_script:
    - cd docs
  script:
    - pip install sphinx
Agate's avatar
Agate committed
102
    - ./build_docs.sh
Agate's avatar
Agate committed
103 104 105 106
  artifacts:
    paths:
      - public
  only:
107
    - develop@funkwhale/funkwhale
Agate's avatar
Agate committed
108 109
  tags:
    - docker
110

111
docker_develop:
Agate's avatar
Agate committed
112
  stage: deploy
113
  before_script:
Agate's avatar
Agate committed
114
    - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
Agate's avatar
Agate committed
115
    - cp -r front/dist api/frontend
116 117
    - cd api
  script:
118 119
    - docker build -t $IMAGE .
    - docker push $IMAGE
120
  only:
121
    - develop@funkwhale/funkwhale
122 123 124
  tags:
    - dind

125 126 127 128 129 130 131 132
build_api:
  # Simply publish a zip containing api/ directory
  stage: deploy
  image: busybox
  artifacts:
    name: "api_${CI_COMMIT_REF_NAME}"
    paths:
      - api
Agate's avatar
Agate committed
133
  script: echo Done!
134
  only:
135 136 137
    - tags@funkwhale/funkwhale
    - master@funkwhale/funkwhale
    - develop@funkwhale/funkwhale
138 139


140 141 142 143
docker_release:
  stage: deploy
  before_script:
    - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
Agate's avatar
Agate committed
144
    - cp -r front/dist api/frontend
145 146 147 148 149 150
    - cd api
  script:
    - docker build -t $IMAGE -t $IMAGE_LATEST .
    - docker push $IMAGE
    - docker push $IMAGE_LATEST
  only:
151
    - tags@funkwhale/funkwhale
152 153
  tags:
    - dind