.gitlab-ci.yml 3.13 KB
Newer Older
1
2
variables:
  IMAGE_NAME: funkwhale/funkwhale
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


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

14
15
16
17
18
19
20
21
22
black:
  image: python:3.6
  stage: lint
  before_script:
    - pip install black
  script:
    - black --check api/


Eliot Berriot's avatar
Eliot Berriot committed
23
test_api:
Eliot Berriot's avatar
Eliot Berriot committed
24
25
  services:
    - postgres:9.4
Eliot Berriot's avatar
Eliot Berriot committed
26
    - redis:3
Eliot Berriot's avatar
Eliot Berriot committed
27
  stage: test
28
29
  image: funkwhale/funkwhale:latest
  cache:
Eliot Berriot's avatar
Eliot Berriot committed
30
    key: "$CI_PROJECT_ID__pip_cache"
31
32
    paths:
      - "$PIP_CACHE_DIR"
33
  variables:
34
    DJANGO_ALLOWED_HOSTS: "localhost"
Eliot Berriot's avatar
Eliot Berriot committed
35
    DATABASE_URL: "postgresql://postgres@postgres/postgres"
36
    FUNKWHALE_URL: "https://funkwhale.ci"
37
    CACHEOPS_ENABLED: "false"
Eliot Berriot's avatar
Eliot Berriot committed
38
    DJANGO_SETTINGS_MODULE: config.settings.local
39

Eliot Berriot's avatar
Eliot Berriot committed
40
  before_script:
41
    - cd api
Eliot Berriot's avatar
Eliot Berriot committed
42
43
    - pip install -r requirements/base.txt
    - pip install -r requirements/local.txt
44
    - pip install -r requirements/test.txt
Eliot Berriot's avatar
Eliot Berriot committed
45
  script:
Eliot Berriot's avatar
Eliot Berriot committed
46
    - pytest --cov=funkwhale_api tests/
47
48
49
50
51
52
53
54
55
56
57
58
59
  tags:
    - docker


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

  script:
    - yarn install
    - yarn run unit
60
  cache:
Eliot Berriot's avatar
Eliot Berriot committed
61
    key: "$CI_PROJECT_ID__front_dependencies"
62
    paths:
63
64
65
66
67
68
      - front/node_modules
      - front/yarn.lock
  artifacts:
    name: "front_${CI_COMMIT_REF_NAME}"
    paths:
      - front/dist/
Eliot Berriot's avatar
Eliot Berriot committed
69
  tags:
70
    - docker
Eliot Berriot's avatar
Eliot Berriot committed
71

72

Eliot Berriot's avatar
Eliot Berriot committed
73
74
build_front:
  stage: build
75
  image: node:9
Eliot Berriot's avatar
Eliot Berriot committed
76
77
78
79
  before_script:
    - cd front

  script:
80
    - yarn install
81
82
    - yarn run i18n-extract
    - yarn run i18n-compile
83
84
85
    # 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')
Eliot Berriot's avatar
Eliot Berriot committed
86
  cache:
Eliot Berriot's avatar
Eliot Berriot committed
87
    key: "$CI_PROJECT_ID__front_dependencies"
Eliot Berriot's avatar
Eliot Berriot committed
88
89
    paths:
      - front/node_modules
90
      - front/yarn.lock
Eliot Berriot's avatar
Eliot Berriot committed
91
92
93
94
95
  artifacts:
    name: "front_${CI_COMMIT_REF_NAME}"
    paths:
      - front/dist/
  only:
96
97
98
    - tags@funkwhale/funkwhale
    - master@funkwhale/funkwhale
    - develop@funkwhale/funkwhale
Eliot Berriot's avatar
Eliot Berriot committed
99
100
  tags:
    - docker
101

102

103
pages:
Eliot Berriot's avatar
Attempt    
Eliot Berriot committed
104
  stage: test
105
106
107
  image: python:3.6
  variables:
    BUILD_PATH: "../public"
108
109
110
111
  before_script:
    - cd docs
  script:
    - pip install sphinx
112
    - ./build_docs.sh
113
114
115
116
  artifacts:
    paths:
      - public
  only:
117
    - develop@funkwhale/funkwhale
Eliot Berriot's avatar
Eliot Berriot committed
118
119
  tags:
    - docker
120

121
docker_develop:
122
  stage: deploy
123
  before_script:
124
    - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
125
    - cp -r front/dist api/frontend
126
127
    - cd api
  script:
128
129
    - docker build -t $IMAGE .
    - docker push $IMAGE
130
  only:
131
    - develop@funkwhale/funkwhale
132
133
134
  tags:
    - dind

135
136
137
138
139
140
141
142
build_api:
  # Simply publish a zip containing api/ directory
  stage: deploy
  image: busybox
  artifacts:
    name: "api_${CI_COMMIT_REF_NAME}"
    paths:
      - api
Eliot Berriot's avatar
Eliot Berriot committed
143
  script: echo Done!
144
  only:
145
146
147
    - tags@funkwhale/funkwhale
    - master@funkwhale/funkwhale
    - develop@funkwhale/funkwhale
148
149


150
151
152
153
docker_release:
  stage: deploy
  before_script:
    - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
154
    - cp -r front/dist api/frontend
155
156
157
158
159
160
    - cd api
  script:
    - docker build -t $IMAGE -t $IMAGE_LATEST .
    - docker push $IMAGE
    - docker push $IMAGE_LATEST
  only:
161
    - tags@funkwhale/funkwhale
162
163
  tags:
    - dind