.gitlab-ci.yml 3.16 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"
Agate's avatar
Agate committed
6
  PYTHONDONTWRITEBYTECODE: "true"
7 8


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

15 16 17
black:
  image: python:3.6
  stage: lint
Agate's avatar
Agate committed
18 19
  variables:
    GIT_STRATEGY: fetch
20 21 22
  before_script:
    - pip install black
  script:
23
    - black --check --diff api/
24

Agate's avatar
Agate committed
25 26 27 28 29 30 31 32
flake8:
  image: python:3.6
  stage: lint
  variables:
    GIT_STRATEGY: fetch
  before_script:
    - pip install flake8
  script:
33
    - flake8 -v api
Agate's avatar
Agate committed
34
  cache:
Agate's avatar
Agate committed
35
    key: "$CI_PROJECT_ID__flake8_pip_cache"
Agate's avatar
Agate committed
36 37
    paths:
      - "$PIP_CACHE_DIR"
38

Agate's avatar
Agate committed
39
test_api:
Agate's avatar
Agate committed
40 41
  services:
    - postgres:9.4
Agate's avatar
Agate committed
42
    - redis:3
Agate's avatar
Agate committed
43
  stage: test
44 45
  image: funkwhale/funkwhale:latest
  cache:
Agate's avatar
Agate committed
46
    key: "$CI_PROJECT_ID__pip_cache"
47 48
    paths:
      - "$PIP_CACHE_DIR"
49
  variables:
50
    DJANGO_ALLOWED_HOSTS: "localhost"
Agate's avatar
Agate committed
51
    DATABASE_URL: "postgresql://postgres@postgres/postgres"
52
    FUNKWHALE_URL: "https://funkwhale.ci"
53
    CACHEOPS_ENABLED: "false"
Agate's avatar
Agate committed
54
    DJANGO_SETTINGS_MODULE: config.settings.local
55

Agate's avatar
Agate committed
56
  before_script:
57
    - cd api
Agate's avatar
Agate committed
58 59
    - pip install -r requirements/base.txt
    - pip install -r requirements/local.txt
60
    - pip install -r requirements/test.txt
Agate's avatar
Agate committed
61
  script:
Agate's avatar
Agate committed
62
    - pytest --cov=funkwhale_api tests/
63 64 65 66 67 68 69 70 71 72 73 74 75
  tags:
    - docker


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

  script:
    - yarn install
    - yarn run unit
76
  cache:
Agate's avatar
Agate committed
77
    key: "$CI_PROJECT_ID__front_dependencies"
78
    paths:
79 80 81 82 83 84
      - front/node_modules
      - front/yarn.lock
  artifacts:
    name: "front_${CI_COMMIT_REF_NAME}"
    paths:
      - front/dist/
Agate's avatar
Agate committed
85
  tags:
86
    - docker
Agate's avatar
Agate committed
87

88

Agate's avatar
Agate committed
89 90
build_front:
  stage: build
91
  image: node:9
Agate's avatar
Agate committed
92 93 94 95
  before_script:
    - cd front

  script:
96
    - yarn install
Agate's avatar
Agate committed
97 98
    - yarn run i18n-extract
    - yarn run i18n-compile
Agate's avatar
Agate committed
99 100 101
    # 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
102
  cache:
Agate's avatar
Agate committed
103
    key: "$CI_PROJECT_ID__front_dependencies"
Agate's avatar
Agate committed
104 105
    paths:
      - front/node_modules
106
      - front/yarn.lock
Agate's avatar
Agate committed
107 108 109 110 111
  artifacts:
    name: "front_${CI_COMMIT_REF_NAME}"
    paths:
      - front/dist/
  only:
112 113 114
    - tags@funkwhale/funkwhale
    - master@funkwhale/funkwhale
    - develop@funkwhale/funkwhale
Agate's avatar
Agate committed
115 116
  tags:
    - docker
117

118

Agate's avatar
Agate committed
119
pages:
Agate's avatar
Attempt  
Agate committed
120
  stage: test
Agate's avatar
Agate committed
121 122 123
  image: python:3.6
  variables:
    BUILD_PATH: "../public"
Agate's avatar
Agate committed
124 125 126 127
  before_script:
    - cd docs
  script:
    - pip install sphinx
Agate's avatar
Agate committed
128
    - ./build_docs.sh
Agate's avatar
Agate committed
129 130 131 132
  artifacts:
    paths:
      - public
  only:
133
    - develop@funkwhale/funkwhale
Agate's avatar
Agate committed
134 135
  tags:
    - docker
136

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

152 153 154 155 156 157 158 159
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
160
  script: echo Done!
161
  only:
162 163 164
    - tags@funkwhale/funkwhale
    - master@funkwhale/funkwhale
    - develop@funkwhale/funkwhale