Skip to content
Snippets Groups Projects
.gitlab-ci.yml 2.64 KiB
Newer Older
variables:
  IMAGE_NAME: funkwhale/funkwhale
  IMAGE: $IMAGE_NAME:$CI_COMMIT_REF_NAME
  IMAGE_LATEST: $IMAGE_NAME:latest
  PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache"
Eliot Berriot's avatar
Eliot Berriot committed
stages:
  - test
Eliot Berriot's avatar
Eliot Berriot committed
  - build
Eliot Berriot's avatar
Eliot Berriot committed

test_api:
  services:
    - postgres:9.4
Eliot Berriot's avatar
Eliot Berriot committed
    - redis:3
Eliot Berriot's avatar
Eliot Berriot committed
  stage: test
  image: funkwhale/funkwhale:latest
  cache:
    key: "$CI_PROJECT_ID__pip_cache"
    paths:
      - "$PIP_CACHE_DIR"
    DJANGO_ALLOWED_HOSTS: "localhost"
    DATABASE_URL: "postgresql://postgres@postgres/postgres"
    FUNKWHALE_URL: "https://funkwhale.ci"
Eliot Berriot's avatar
Eliot Berriot committed
    DJANGO_SETTINGS_MODULE: config.settings.local
Eliot Berriot's avatar
Eliot Berriot committed
  before_script:
    - pip install -r requirements/base.txt
    - pip install -r requirements/local.txt
    - pip install -r requirements/test.txt
Eliot Berriot's avatar
Eliot Berriot committed
  script:
    - pytest --cov=funkwhale_api tests/
  tags:
    - docker


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

  script:
    - yarn install
    - yarn run unit
    key: "$CI_PROJECT_ID__front_dependencies"
      - front/node_modules
      - front/yarn.lock
  artifacts:
    name: "front_${CI_COMMIT_REF_NAME}"
    paths:
      - front/dist/
Eliot Berriot's avatar
Eliot Berriot committed
  tags:
Eliot Berriot's avatar
Eliot Berriot committed

Eliot Berriot's avatar
Eliot Berriot committed
build_front:
  stage: build
  image: node:9
Eliot Berriot's avatar
Eliot Berriot committed
  before_script:
    - cd front

  script:
    - yarn install
    - yarn run i18n-extract
    - yarn run i18n-compile
    - yarn run build
Eliot Berriot's avatar
Eliot Berriot committed
  cache:
    key: "$CI_PROJECT_ID__front_dependencies"
Eliot Berriot's avatar
Eliot Berriot committed
    paths:
      - front/node_modules
      - front/yarn.lock
Eliot Berriot's avatar
Eliot Berriot committed
  artifacts:
    name: "front_${CI_COMMIT_REF_NAME}"
    paths:
      - front/dist/
  only:
Eliot Berriot's avatar
Eliot Berriot committed
    - master
    - develop
  tags:
    - docker
Eliot Berriot's avatar
Eliot Berriot committed
  stage: test
  image: python:3.6-alpine
  before_script:
    - cd docs
  script:
    - pip install sphinx
    - python -m sphinx . ../public
  artifacts:
    paths:
      - public
  only:
Eliot Berriot's avatar
Eliot Berriot committed
  tags:
    - docker
  stage: deploy
    - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
    - cp -r front/dist api/frontend
    - docker build -t $IMAGE .
    - docker push $IMAGE
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
  script: echo Done!
docker_release:
  stage: deploy
  before_script:
    - docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
    - cp -r front/dist api/frontend
    - cd api
  script:
    - docker build -t $IMAGE -t $IMAGE_LATEST .
    - docker push $IMAGE
    - docker push $IMAGE_LATEST
  only: