.gitlab-ci.yml 3.01 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
9
stages:
  - test
Eliot Berriot's avatar
Eliot Berriot committed
10
  - build
11
  - deploy
Eliot Berriot's avatar
Eliot Berriot committed
12
13

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

Eliot Berriot's avatar
Eliot Berriot committed
30
  before_script:
31
    - cd api
Eliot Berriot's avatar
Eliot Berriot committed
32
33
    - pip install -r requirements/base.txt
    - pip install -r requirements/local.txt
34
    - pip install -r requirements/test.txt
Eliot Berriot's avatar
Eliot Berriot committed
35
  script:
Eliot Berriot's avatar
Eliot Berriot 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:
Eliot Berriot's avatar
Eliot Berriot 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/
Eliot Berriot's avatar
Eliot Berriot committed
59
  tags:
60
    - docker
Eliot Berriot's avatar
Eliot Berriot committed
61

62

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

  script:
70
    - yarn install
71
72
    - yarn run i18n-extract
    - yarn run i18n-compile
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')
Eliot Berriot's avatar
Eliot Berriot committed
76
  cache:
Eliot Berriot's avatar
Eliot Berriot committed
77
    key: "$CI_PROJECT_ID__front_dependencies"
Eliot Berriot's avatar
Eliot Berriot committed
78
79
    paths:
      - front/node_modules
80
      - front/yarn.lock
Eliot Berriot's avatar
Eliot Berriot 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
Eliot Berriot's avatar
Eliot Berriot committed
89
90
  tags:
    - docker
91

92

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

111
docker_develop:
112
  stage: deploy
113
  before_script:
114
    - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
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
Eliot Berriot's avatar
Eliot Berriot 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
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