.gitlab-ci.yml 2.49 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
  image: funkwhale/funkwhale:latest
  cache:
Eliot Berriot's avatar
Eliot Berriot committed
19
    key: "$CI_PROJECT_ID__pip_cache"
20
21
    paths:
      - "$PIP_CACHE_DIR"
22
  variables:
23
    DJANGO_ALLOWED_HOSTS: "localhost"
Eliot Berriot's avatar
Eliot Berriot committed
24
    DATABASE_URL: "postgresql://postgres@postgres/postgres"
25
    FUNKWHALE_URL: "https://funkwhale.ci"
26
27
    CACHEOPS_ENABLED: "false"

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


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

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

60

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

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

86

87
pages:
Eliot Berriot's avatar
Attempt    
Eliot Berriot committed
88
  stage: test
89
  image: python:3.6-alpine
90
91
92
93
  before_script:
    - cd docs
  script:
    - pip install sphinx
94
    - python -m sphinx . ../public
95
96
97
98
  artifacts:
    paths:
      - public
  only:
99
    - develop
Eliot Berriot's avatar
Eliot Berriot committed
100
101
  tags:
    - docker
102

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

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


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