funkwhale/.gitlab-ci.yml

292 wiersze
7.1 KiB
YAML
Czysty Zwykły widok Historia

variables:
IMAGE_NAME: funkwhale/funkwhale
2017-06-26 20:24:37 +00:00
IMAGE: $IMAGE_NAME:$CI_COMMIT_REF_NAME
ALL_IN_ONE_IMAGE_NAME: funkwhale/all-in-one
ALL_IN_ONE_IMAGE: $ALL_IN_ONE_IMAGE_NAME:$CI_COMMIT_REF_NAME
PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache"
2018-06-09 15:03:06 +00:00
PYTHONDONTWRITEBYTECODE: "true"
2018-07-04 16:31:29 +00:00
REVIEW_DOMAIN: preview.funkwhale.audio
REVIEW_INSTANCE_URL: https://demo.funkwhale.audio
2017-06-25 17:12:23 +00:00
stages:
2018-06-23 14:51:31 +00:00
- review
- lint
2017-06-25 17:12:23 +00:00
- test
2017-06-25 17:13:46 +00:00
- build
- deploy
2017-06-25 17:13:46 +00:00
2018-06-24 10:37:01 +00:00
review_front:
2018-06-23 14:51:31 +00:00
stage: review
image: node:9
when: manual
allow_failure: true
before_script:
2018-07-01 15:07:21 +00:00
- curl -L -o /usr/local/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64
- chmod +x /usr/local/bin/jq
2018-06-23 14:51:31 +00:00
- cd front
script:
- yarn install
- yarn run i18n-compile
2018-06-23 14:51:31 +00:00
# this is to ensure we don't have any errors in the output,
2018-12-10 15:00:33 +00:00
# cf https://dev.funkwhale.audio/funkwhale/funkwhale/issues/169
- VUE_APP_INSTANCE_URL=$REVIEW_INSTANCE_URL yarn run build | tee /dev/stderr | (! grep -i 'ERROR in')
2018-07-04 16:31:29 +00:00
- mkdir -p /static/front/$CI_PROJECT_PATH_SLUG-$CI_BUILD_REF_SLUG
- cp -r dist/* /static/front/$CI_PROJECT_PATH_SLUG-$CI_BUILD_REF_SLUG
2018-06-23 14:51:31 +00:00
cache:
2018-07-04 16:31:29 +00:00
key: "funkwhale__front_dependencies"
2018-06-23 14:51:31 +00:00
paths:
- front/node_modules
- front/yarn.lock
environment:
2018-07-04 16:31:29 +00:00
name: review/front/$CI_PROJECT_PATH_SLUG-$CI_BUILD_REF_SLUG
url: http://front-$CI_PROJECT_PATH_SLUG-$CI_BUILD_REF_SLUG.$REVIEW_DOMAIN
2018-06-24 10:37:01 +00:00
on_stop: stop_front_review
2018-06-23 14:51:31 +00:00
only:
2018-07-01 14:21:08 +00:00
- branches
2018-06-23 14:51:31 +00:00
tags:
- funkwhale-review
2018-06-24 10:37:01 +00:00
stop_front_review:
2018-06-23 14:51:31 +00:00
stage: review
script:
2018-07-04 16:31:29 +00:00
- rm -rf /static/front/$CI_PROJECT_PATH_SLUG-$CI_BUILD_REF_SLUG/
2018-06-23 14:51:31 +00:00
variables:
GIT_STRATEGY: none
when: manual
2018-07-01 14:21:08 +00:00
only:
- branches
2018-06-23 14:51:31 +00:00
environment:
2018-07-04 16:31:29 +00:00
name: review/front/$CI_PROJECT_PATH_SLUG-$CI_BUILD_REF_SLUG
2018-06-24 10:37:01 +00:00
action: stop
tags:
- funkwhale-review
review_docs:
stage: review
image: python:3.6
when: manual
allow_failure: true
variables:
BUILD_PATH: "../public"
before_script:
- cd docs
- apt-get update
- apt-get install -y graphviz
- pip install sphinx
2018-06-24 10:37:01 +00:00
cache:
key: "$CI_PROJECT_ID__sphinx"
paths:
- "$PIP_CACHE_DIR"
script:
- ./build_docs.sh
2018-07-04 16:31:29 +00:00
- mkdir -p /static/docs/$CI_PROJECT_PATH_SLUG-$CI_BUILD_REF_SLUG
- cp -r $CI_PROJECT_DIR/public/* /static/docs/$CI_PROJECT_PATH_SLUG-$CI_BUILD_REF_SLUG
2018-06-24 10:37:01 +00:00
environment:
2018-07-04 16:31:29 +00:00
name: review/docs/$CI_PROJECT_PATH_SLUG-$CI_BUILD_REF_SLUG
url: http://docs-$CI_PROJECT_PATH_SLUG-$CI_BUILD_REF_SLUG.$REVIEW_DOMAIN
2018-06-24 10:37:01 +00:00
on_stop: stop_docs_review
only:
2018-07-01 14:21:08 +00:00
- branches
2018-06-24 10:37:01 +00:00
tags:
- funkwhale-review
stop_docs_review:
stage: review
script:
2018-07-04 16:31:29 +00:00
- rm -rf /static/docs/$CI_PROJECT_PATH_SLUG-$CI_BUILD_REF_SLUG/
2018-06-24 10:37:01 +00:00
variables:
GIT_STRATEGY: none
when: manual
2018-07-01 14:21:08 +00:00
only:
- branches
2018-06-24 10:37:01 +00:00
environment:
2018-07-04 16:31:29 +00:00
name: review/docs/$CI_PROJECT_PATH_SLUG-$CI_BUILD_REF_SLUG
2018-06-23 14:51:31 +00:00
action: stop
tags:
- funkwhale-review
black:
image: python:3.6
stage: lint
2018-06-09 15:03:06 +00:00
variables:
GIT_STRATEGY: fetch
before_script:
- pip install black
script:
2019-03-15 11:11:05 +00:00
- black --check --diff api/
2018-06-09 15:12:58 +00:00
flake8:
image: python:3.6
stage: lint
variables:
GIT_STRATEGY: fetch
before_script:
- pip install flake8
script:
- flake8 -v api
2018-06-09 15:03:06 +00:00
cache:
2018-06-09 15:12:58 +00:00
key: "$CI_PROJECT_ID__flake8_pip_cache"
2018-06-09 15:03:06 +00:00
paths:
- "$PIP_CACHE_DIR"
2017-06-25 17:13:46 +00:00
test_api:
2017-12-28 21:59:43 +00:00
services:
- postgres:11
2018-04-02 17:24:01 +00:00
- redis:3
2017-06-25 17:13:46 +00:00
stage: test
image: funkwhale/funkwhale:develop
cache:
2018-03-20 13:41:36 +00:00
key: "$CI_PROJECT_ID__pip_cache"
paths:
- "$PIP_CACHE_DIR"
variables:
2017-12-28 21:59:43 +00:00
DATABASE_URL: "postgresql://postgres@postgres/postgres"
FUNKWHALE_URL: "https://funkwhale.ci"
2018-04-02 17:16:34 +00:00
DJANGO_SETTINGS_MODULE: config.settings.local
2018-07-01 14:21:08 +00:00
only:
- branches
2017-06-25 17:13:46 +00:00
before_script:
- cd api
2019-01-21 13:20:14 +00:00
- sed -i '/Pillow/d' requirements/base.txt
- pip3 install -r requirements/base.txt
- pip3 install -r requirements/local.txt
- pip3 install -r requirements/test.txt
2017-06-25 17:13:46 +00:00
script:
2018-03-25 20:45:37 +00:00
- pytest --cov=funkwhale_api tests/
tags:
- docker
test_front:
stage: test
image: node:9
before_script:
- cd front
2018-07-01 14:21:08 +00:00
only:
- branches
script:
- yarn install --check-files
- yarn test:unit
cache:
2018-07-04 16:31:29 +00:00
key: "funkwhale__front_dependencies"
paths:
- front/node_modules
- front/yarn.lock
artifacts:
name: "front_${CI_COMMIT_REF_NAME}"
paths:
- front/dist/
2017-06-25 17:13:46 +00:00
tags:
- docker
2017-06-25 17:13:46 +00:00
build_front:
stage: build
image: node:9
2017-06-25 17:13:46 +00:00
before_script:
2018-07-01 15:07:21 +00:00
- curl -L -o /usr/local/bin/jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64
- chmod +x /usr/local/bin/jq
2017-06-25 17:13:46 +00:00
- cd front
script:
- yarn install
2018-04-16 20:54:36 +00:00
- yarn run i18n-compile
2018-04-20 17:25:29 +00:00
# this is to ensure we don't have any errors in the output,
2018-12-10 15:00:33 +00:00
# cf https://dev.funkwhale.audio/funkwhale/funkwhale/issues/169
- yarn build | tee /dev/stderr | (! grep -i 'ERROR in')
- chmod -R 755 dist
2017-06-25 17:13:46 +00:00
artifacts:
name: "front_${CI_COMMIT_REF_NAME}"
paths:
- front/dist/
only:
- tags@funkwhale/funkwhale
- master@funkwhale/funkwhale
- develop@funkwhale/funkwhale
2017-06-25 17:13:46 +00:00
tags:
- docker
2017-06-25 17:05:31 +00:00
pages:
2017-06-25 17:12:23 +00:00
stage: test
2018-04-26 16:12:08 +00:00
image: python:3.6
variables:
BUILD_PATH: "../public"
2017-06-25 17:05:31 +00:00
before_script:
- cd docs
- apt-get update
- apt-get install -y graphviz
2017-06-25 17:05:31 +00:00
- pip install sphinx
script:
2018-04-26 16:12:08 +00:00
- ./build_docs.sh
2018-06-24 10:37:01 +00:00
cache:
key: "$CI_PROJECT_ID__sphinx"
paths:
- "$PIP_CACHE_DIR"
2017-06-25 17:05:31 +00:00
artifacts:
paths:
- public
only:
- master@funkwhale/funkwhale
2017-06-25 17:07:49 +00:00
tags:
- docker
docker_release:
2017-06-26 18:07:19 +00:00
stage: deploy
2019-01-11 09:01:06 +00:00
image: bash
before_script:
2017-06-26 17:51:25 +00:00
- docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
2017-06-28 18:11:06 +00:00
- cp -r front/dist api/frontend
2019-01-11 09:01:06 +00:00
- (if [ "$CI_COMMIT_REF_NAME" == "develop" ]; then ./scripts/set-api-build-metadata.sh $(echo $CI_COMMIT_SHA | cut -c 1-8); fi);
- cd api
script:
- docker build -t $IMAGE .
- docker push $IMAGE
only:
- develop@funkwhale/funkwhale
- tags@funkwhale/funkwhale
tags:
- docker-build
docker_all_in_one_release:
stage: deploy
image: bash
variables:
ALL_IN_ONE_REF: master
ALL_IN_ONE_ARTIFACT_URL: https://github.com/thetarkus/docker-funkwhale/archive/$ALL_IN_ONE_REF.zip
BUILD_PATH: all_in_one
before_script:
- docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
- (if [ "$CI_COMMIT_REF_NAME" == "develop" ]; then ./scripts/set-api-build-metadata.sh $(echo $CI_COMMIT_SHA | cut -c 1-8); fi);
script:
- wget $ALL_IN_ONE_ARTIFACT_URL -O all_in_one.zip
- unzip -o all_in_one.zip -d tmpdir
- mv tmpdir/docker-funkwhale-$ALL_IN_ONE_REF $BUILD_PATH && rmdir tmpdir
- cp -r api $BUILD_PATH/src/api
- cp -r front $BUILD_PATH/src/front
- cd $BUILD_PATH
- ./scripts/download-nginx-template.sh src/ $CI_COMMIT_REF_NAME
- docker build -t $ALL_IN_ONE_IMAGE .
- docker push $ALL_IN_ONE_IMAGE
only:
- develop@funkwhale/funkwhale
- tags@funkwhale/funkwhale
tags:
- docker-build
build_api:
# Simply publish a zip containing api/ directory
stage: deploy
2019-01-11 09:01:06 +00:00
image: bash
artifacts:
name: "api_${CI_COMMIT_REF_NAME}"
paths:
- api
script:
2019-05-13 13:30:58 +00:00
- rm -rf api/tests
2019-01-11 09:01:06 +00:00
- (if [ "$CI_COMMIT_REF_NAME" == "develop" ]; then ./scripts/set-api-build-metadata.sh $(echo $CI_COMMIT_SHA | cut -c 1-8); fi);
- chmod -R 750 api
- echo Done!
only:
- tags@funkwhale/funkwhale
- master@funkwhale/funkwhale
- develop@funkwhale/funkwhale