.gitlab-ci.yml 2.18 KB
Newer Older
1
2
variables:
  IMAGE_NAME: funkwhale/funkwhale
3
  IMAGE: $IMAGE_NAME:$CI_COMMIT_REF_NAME
4
5
6
7
  IMAGE_LATEST: $IMAGE_NAME:latest



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
  image: funkwhale/funkwhale:base
18
19
  variables:
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache"
Eliot Berriot's avatar
Eliot Berriot committed
20
21
    DATABASE_URL: "postgresql://postgres@postgres/postgres"

Eliot Berriot's avatar
Eliot Berriot committed
22
  before_script:
23
24
    - python3 -m venv --copies virtualenv
    - source virtualenv/bin/activate
25
    - cd api
Eliot Berriot's avatar
Eliot Berriot committed
26
27
    - pip install -r requirements/base.txt
    - pip install -r requirements/local.txt
28
    - pip install -r requirements/test.txt
Eliot Berriot's avatar
Eliot Berriot committed
29
  script:
30
    - pytest
31
32
33
34
  cache:
    key: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    paths:
      - "$CI_PROJECT_DIR/pip-cache"
Eliot Berriot's avatar
Eliot Berriot committed
35
  tags:
36
    - docker
Eliot Berriot's avatar
Eliot Berriot committed
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55

build_front:
  stage: build
  image: node:6-alpine
  before_script:
    - cd front

  script:
    - npm install
    - npm run build
  cache:
    key: "$CI_COMMIT_REF_NAME"
    paths:
      - front/node_modules
  artifacts:
    name: "front_${CI_COMMIT_REF_NAME}"
    paths:
      - front/dist/
  only:
56
    - tags
Eliot Berriot's avatar
Eliot Berriot committed
57
58
59
60
    - master
    - develop
  tags:
    - docker
61

62

63
pages:
Eliot Berriot's avatar
Attempt    
Eliot Berriot committed
64
  stage: test
65
66
67
68
69
70
71
72
  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
73
    - mv _build/html/ ../public
74
75
76
77
  artifacts:
    paths:
      - public
  only:
78
    - develop
Eliot Berriot's avatar
Eliot Berriot committed
79
80
  tags:
    - docker
81

82
docker_develop:
83
  stage: deploy
84
  before_script:
85
    - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
86
    - cp -r front/dist api/frontend
87
88
    - cd api
  script:
89
90
    - docker build -t $IMAGE .
    - docker push $IMAGE
91
92
  only:
    - develop
93
94
95
  tags:
    - dind

96
97
98
99
100
101
102
103
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
104
  script: echo Done!
105
106
107
108
109
110
  only:
    - tags
    - master
    - develop


111
112
113
114
docker_release:
  stage: deploy
  before_script:
    - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
115
    - cp -r front/dist api/frontend
116
117
118
119
120
121
    - cd api
  script:
    - docker build -t $IMAGE -t $IMAGE_LATEST .
    - docker push $IMAGE
    - docker push $IMAGE_LATEST
  only:
122
    - tags
123
124
  tags:
    - dind