.gitlab-ci.yml 2.5 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
  stage: test
17
18
19
20
21
  image: funkwhale/funkwhale:latest
  cache:
    key: "$CI_PROJECT_ID/pip_cache"
    paths:
      - "$PIP_CACHE_DIR"
22
  variables:
23
    DJANGO_ALLOWED_HOSTS: "localhost"
Eliot Berriot's avatar
Eliot Berriot committed
24
25
    DATABASE_URL: "postgresql://postgres@postgres/postgres"

Eliot Berriot's avatar
Eliot Berriot committed
26
  before_script:
27
    - cd api
Eliot Berriot's avatar
Eliot Berriot committed
28
29
    - pip install -r requirements/base.txt
    - pip install -r requirements/local.txt
30
    - pip install -r requirements/test.txt
Eliot Berriot's avatar
Eliot Berriot committed
31
  script:
32
    - pytest
33
34
35
36
37
38
39
40
41
42
43
44
45
  tags:
    - docker


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

  script:
    - yarn install
    - yarn run unit
46
  cache:
47
    key: "$CI_PROJECT_ID/front_dependencies"
48
    paths:
49
50
51
52
53
54
      - front/node_modules
      - front/yarn.lock
  artifacts:
    name: "front_${CI_COMMIT_REF_NAME}"
    paths:
      - front/dist/
Eliot Berriot's avatar
Eliot Berriot committed
55
  tags:
56
    - docker
Eliot Berriot's avatar
Eliot Berriot committed
57

58

Eliot Berriot's avatar
Eliot Berriot committed
59
60
build_front:
  stage: build
61
  image: node:9
Eliot Berriot's avatar
Eliot Berriot committed
62
63
64
65
  before_script:
    - cd front

  script:
66
67
    - yarn install
    - yarn run build
Eliot Berriot's avatar
Eliot Berriot committed
68
  cache:
69
    key: "$CI_PROJECT_ID/front_dependencies"
Eliot Berriot's avatar
Eliot Berriot committed
70
71
    paths:
      - front/node_modules
72
      - front/yarn.lock
Eliot Berriot's avatar
Eliot Berriot committed
73
74
75
76
77
  artifacts:
    name: "front_${CI_COMMIT_REF_NAME}"
    paths:
      - front/dist/
  only:
78
    - tags
Eliot Berriot's avatar
Eliot Berriot committed
79
80
81
82
    - master
    - develop
  tags:
    - docker
83

84

85
pages:
Eliot Berriot's avatar
Attempt    
Eliot Berriot committed
86
  stage: test
87
88
89
90
91
92
93
94
  image: alpine
  before_script:
    - cd docs
  script:
    - apk --no-cache add py2-pip python-dev
    - pip install sphinx
    - apk --no-cache add make
    - make html
Eliot Berriot's avatar
Attempt    
Eliot Berriot committed
95
    - mv _build/html/ ../public
96
97
98
99
  artifacts:
    paths:
      - public
  only:
100
    - develop
Eliot Berriot's avatar
Eliot Berriot committed
101
102
  tags:
    - docker
103

104
docker_develop:
105
  stage: deploy
106
  before_script:
107
    - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
108
    - cp -r front/dist api/frontend
109
110
    - cd api
  script:
111
112
    - docker build -t $IMAGE .
    - docker push $IMAGE
113
114
  only:
    - develop
115
116
117
  tags:
    - dind

118
119
120
121
122
123
124
125
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
126
  script: echo Done!
127
128
129
130
131
132
  only:
    - tags
    - master
    - develop


133
134
135
136
docker_release:
  stage: deploy
  before_script:
    - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
137
    - cp -r front/dist api/frontend
138
139
140
141
142
143
    - cd api
  script:
    - docker build -t $IMAGE -t $IMAGE_LATEST .
    - docker push $IMAGE
    - docker push $IMAGE_LATEST
  only:
144
    - tags
145
146
  tags:
    - dind