funkwhale/.gitlab-ci.yml

439 wiersze
12 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
IMAGE_LATEST: $IMAGE_NAME:latest
ALL_IN_ONE_IMAGE_NAME: funkwhale/all-in-one
ALL_IN_ONE_IMAGE: $ALL_IN_ONE_IMAGE_NAME:$CI_COMMIT_REF_NAME
ALL_IN_ONE_IMAGE_LATEST: $ALL_IN_ONE_IMAGE_NAME:latest
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://funkwhale.juniorjpdj.pl
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
2021-11-06 21:55:25 +00:00
BUILD_PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
2017-06-25 17:12:23 +00:00
stages:
2022-01-28 12:33:39 +00:00
- build
2018-06-23 14:51:31 +00:00
- review
- lint
- test
- deploy
- deps
2017-06-25 17:13:46 +00:00
2018-06-24 10:37:01 +00:00
review_front:
2019-09-23 09:15:32 +00:00
interruptible: true
2018-06-23 14:51:31 +00:00
stage: review
2022-02-03 08:32:59 +00:00
image: node:16-buster
2018-06-23 14:51:31 +00:00
when: manual
allow_failure: true
2019-06-13 12:09:07 +00:00
variables:
BASE_URL: /-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/front-review/
VUE_APP_ROUTER_BASE_URL: /-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/front-review/
VUE_APP_INSTANCE_URL: $REVIEW_INSTANCE_URL
NODE_ENV: review
2018-06-23 14:51:31 +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
2019-06-13 12:09:07 +00:00
- rm -rf front-review
- mkdir front-review
2018-06-23 14:51:31 +00:00
- cd front
script:
- yarn install
# 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
2022-02-27 13:10:59 +00:00
- yarn run build --base ./ | tee /dev/stderr | (! grep -i 'ERROR in')
2019-06-13 12:09:07 +00:00
- cp -r dist/* ../front-review
artifacts:
expire_in: 2 weeks
paths:
- front-review
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
only:
2018-07-01 14:21:08 +00:00
- branches
2018-06-23 14:51:31 +00:00
tags:
2019-06-13 12:09:07 +00:00
- docker
2018-06-24 10:37:01 +00:00
environment:
2019-06-13 12:09:07 +00:00
name: review/front/$CI_COMMIT_REF_NAME
url: http://$CI_PROJECT_NAMESPACE.pages.funkwhale.audio/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/front-review/index.html
2018-06-24 10:37:01 +00:00
2019-06-13 12:50:31 +00:00
review_docs:
2019-09-23 09:15:32 +00:00
interruptible: true
2019-06-13 12:50:31 +00:00
stage: review
when: manual
allow_failure: true
image: python:3.10
2019-06-13 12:50:31 +00:00
variables:
BUILD_PATH: "../docs-review"
before_script:
- rm -rf docs-review
- mkdir docs-review
- cd docs
- apt-get update
- apt-get install -y graphviz git
- pip install poetry
- poetry install
- git switch develop && git pull
- git switch stable && git pull
- git switch $CI_COMMIT_BRANCH && git pull
2019-06-13 12:50:31 +00:00
script:
- poetry run python -m sphinx . $BUILD_PATH
2019-06-13 12:50:31 +00:00
cache:
key: "$CI_PROJECT_ID__sphinx"
paths:
- "$PIP_CACHE_DIR"
artifacts:
expire_in: 2 weeks
paths:
- docs-review
only:
- branches
tags:
- docker
environment:
name: review/docs/$CI_COMMIT_REF_NAME
url: http://$CI_PROJECT_NAMESPACE.pages.funkwhale.audio/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/docs-review/index.html
2022-02-05 21:42:31 +00:00
changelog_snippet:
interruptible: true
image: alpine:3.16
2022-02-05 21:42:31 +00:00
stage: lint
before_script:
- apk add git
- git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
script:
- git diff --name-only FETCH_HEAD | grep "changes/changelog.d/*"
rules:
- if: $CI_COMMIT_AUTHOR == 'Renovate Bot <bot@dev.funkwhale.audio>'
when: never
- if: $CI_MERGE_REQUEST_TITLE =~ /NOCHANGELOG/
when: never
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
black:
2019-09-23 09:15:32 +00:00
interruptible: true
image: python:3.6
stage: lint
2018-06-09 15:03:06 +00:00
variables:
GIT_STRATEGY: fetch
before_script:
- pip install black
script:
- black --check --diff .
2018-06-09 15:12:58 +00:00
flake8:
2019-09-23 09:15:32 +00:00
interruptible: true
2018-06-09 15:12:58 +00:00
image: python:3.6
stage: lint
variables:
GIT_STRATEGY: fetch
before_script:
2020-05-15 12:42:48 +00:00
- pip install 'flake8<3.7'
2018-06-09 15:12:58 +00:00
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"
2021-07-16 18:34:46 +00:00
eslint:
interruptible: true
2022-02-03 08:32:59 +00:00
image: node:16-buster
2021-07-16 18:34:46 +00:00
stage: lint
before_script:
- cd front
- yarn install
script:
2021-12-08 18:48:06 +00:00
- yarn lint --max-warnings 0
2021-07-16 18:34:46 +00:00
cache:
key: "$CI_PROJECT_ID__eslint_npm_cache"
paths:
- front/node_modules
2022-02-05 17:26:10 +00:00
test_api:
2019-09-23 09:15:32 +00:00
interruptible: true
2017-12-28 21:59:43 +00:00
services:
2022-02-03 19:33:13 +00:00
- postgres:14
- redis:6
2017-06-25 17:13:46 +00:00
stage: test
2022-02-18 13:41:10 +00:00
retry: 1
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
2020-02-15 11:01:19 +00:00
POSTGRES_HOST_AUTH_METHOD: trust
CACHE_URL: "redis://redis:6379/0"
2018-07-01 14:21:08 +00:00
only:
refs:
- branches
2017-06-25 17:13:46 +00:00
before_script:
- cd api
2022-04-01 08:11:30 +00:00
- poetry run pip install setuptools==59.1.1 # Hotfix for failing pipelines #1745
- poetry install --no-root
2017-06-25 17:13:46 +00:00
script:
2022-01-09 19:44:46 +00:00
- poetry run pytest --cov-report xml --cov-report term-missing:skip-covered --cov=funkwhale_api --junitxml=report.xml tests/
tags:
- docker
artifacts:
when: always
reports:
2021-04-22 15:04:16 +00:00
junit: api/report.xml
2022-06-08 12:12:55 +00:00
coverage_report:
coverage_format: cobertura
path: api/coverage.xml
2022-02-05 17:26:10 +00:00
parallel:
matrix:
- PY_VER: ["3.7", "3.8", "3.9", "3.10"]
image: $CI_REGISTRY/funkwhale/backend-test-docker:$PY_VER
test_front:
2019-09-23 09:15:32 +00:00
interruptible: true
stage: test
2022-02-03 08:32:59 +00:00
image: node:16-buster
before_script:
- cd front
2018-07-01 14:21:08 +00:00
only:
refs:
- 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/
reports:
junit: front/test-results.xml
2017-06-25 17:13:46 +00:00
tags:
- docker
2017-06-25 17:13:46 +00:00
2022-01-28 12:33:39 +00:00
build_docs:
stage: build
2022-04-01 07:00:49 +00:00
image: $CI_REGISTRY/funkwhale/backend-test-docker:3.10
2022-01-28 12:33:39 +00:00
services:
2022-02-03 19:33:13 +00:00
- postgres:14
- redis:6
2022-01-28 12:33:39 +00:00
cache:
key: "$CI_PROJECT_ID__pip_cache"
paths:
- "$PIP_CACHE_DIR"
variables:
DATABASE_URL: "postgresql://postgres@postgres/postgres"
FUNKWHALE_URL: "https://funkwhale.ci"
DJANGO_SETTINGS_MODULE: config.settings.local
POSTGRES_HOST_AUTH_METHOD: trust
CACHE_URL: "redis://redis:6379/0"
before_script:
- cd api
- pip3 install poetry
- poetry run pip install setuptools==59.1.1 # Hotfix for failing pipelines #1745
2022-01-28 12:33:39 +00:00
- poetry install
- poetry run python manage.py migrate
script:
- poetry run python manage.py spectacular --file ../docs/schema.yml
tags:
- docker
artifacts:
paths:
- docs/schema.yml
2017-06-25 17:13:46 +00:00
build_front:
stage: build
2022-02-03 08:32:59 +00:00
image: node:16-buster
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
2022-02-27 22:20:03 +00:00
- yarn run build:deployment | 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
- stable@funkwhale/funkwhale
- develop@funkwhale/funkwhale
2017-06-25 17:13:46 +00:00
tags:
- docker
build_documentation:
stage: build
image: python:3.10
2018-04-26 16:12:08 +00:00
variables:
BUILD_PATH: "../public"
2017-06-25 17:05:31 +00:00
before_script:
- cd docs
- apt-get update
- apt-get install -y graphviz git
- pip install poetry
- poetry install
- git switch develop && git pull
- git switch stable && git pull
- git switch $CI_COMMIT_BRANCH && git pull
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:
- stable@funkwhale/funkwhale
2017-06-25 17:07:49 +00:00
tags:
- docker
deploy_documentation:
stage: deploy
image: alpine
dependencies:
- build_documentation
before_script:
- apk add openssh-client rsync
- mkdir -p ~/.ssh
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- eval `ssh-agent -s`
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
script:
- rsync -r -e "ssh -p 2282" $CI_PROJECT_DIR/public/ docs@docs.funkwhale.audio:/htdocs/
only:
- stable
2021-11-06 21:55:25 +00:00
.docker_publish:
2017-06-26 18:07:19 +00:00
stage: deploy
image: egon0/docker-with-buildx-and-git:bash
2021-11-06 21:55:25 +00:00
tags:
- multiarch
2021-09-09 15:11:59 +00:00
services:
- docker:20-dind
before_script:
2017-06-26 17:51:25 +00:00
- docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
script:
2021-11-06 21:55:25 +00:00
docker_publish_stable_release:
# Publish a docker image for releases
extends: .docker_publish
variables:
IMAGE_NAME: funkwhale/$COMPONENT
2021-11-06 21:55:25 +00:00
rules:
- if: $CI_COMMIT_TAG && $CI_COMMIT_REF_NAME =~ /^[0-9]+(.[0-9]+){1,2}$/
script:
# Check if this is the latest release
- ./docs/get-releases-json.py | scripts/is-docker-latest.py $CI_COMMIT_TAG - && export DOCKER_LATEST_TAG="-t $IMAGE_LATEST" || export DOCKER_LATEST_TAG=;
2022-02-03 08:32:59 +00:00
- export major="$(echo $CI_COMMIT_REF_NAME | cut -d '.' -f 1)"
2021-12-29 19:20:29 +00:00
- export minor="$(echo $CI_COMMIT_REF_NAME | cut -d '.' -f 1,2)"
- cd $COMPONENT
2021-11-06 21:55:25 +00:00
- docker buildx create --use --name A$CI_COMMIT_SHORT_SHA
2021-12-29 19:20:29 +00:00
- docker buildx build --platform $BUILD_PLATFORMS --push -t $IMAGE $DOCKER_LATEST_TAG -t $IMAGE_NAME:$major -t $IMAGE_NAME:$minor .
parallel:
matrix:
- COMPONENT: ["api", "front"]
2021-11-06 21:55:25 +00:00
docker_publish_unstable_release:
# Publish a docker image for releases
extends: .docker_publish
variables:
IMAGE_NAME: funkwhale/$COMPONENT
2021-11-06 21:55:25 +00:00
rules:
- if: $CI_COMMIT_TAG && $CI_COMMIT_REF_NAME !~ /^[0-9]+(.[0-9]+){1,2}$/
script:
# Check if this is the latest release
- cd $COMPONENT
2021-11-06 21:55:25 +00:00
- docker buildx create --use --name A$CI_COMMIT_SHORT_SHA
- docker buildx build --platform $BUILD_PLATFORMS --push -t $IMAGE .
parallel:
matrix:
- COMPONENT: ["api", "front"]
2021-11-06 21:55:25 +00:00
docker_publish_non-release:
2021-11-06 21:55:25 +00:00
# Publish a docker image for each commit on develop
extends: .docker_publish
variables:
IMAGE_NAME: funkwhale/$COMPONENT
only:
- develop@funkwhale/funkwhale
- stable@funkwhale/funkwhale
2021-11-06 21:55:25 +00:00
script:
- ./scripts/set-api-build-metadata.sh $CI_COMMIT_SHORT_SHA
- cd $COMPONENT
2021-11-06 21:55:25 +00:00
- docker buildx create --use --name A$CI_COMMIT_SHORT_SHA
- docker buildx build --platform $BUILD_PLATFORMS --push -t $IMAGE .
parallel:
matrix:
- COMPONENT: ["api", "front"]
2021-08-15 20:17:22 +00:00
docker_all_in_one_release:
stage: deploy
image: egon0/docker-with-buildx-and-git:bash
allow_failure: true
services:
- docker:20-dind
2021-08-15 20:17:22 +00:00
variables:
ALL_IN_ONE_REF: main
ALL_IN_ONE_ARTIFACT_URL: https://dev.funkwhale.audio/funkwhale/funkwhale-docker-all-in-one/-/archive/$ALL_IN_ONE_REF/funkwhale-docker-all-in-one-$ALL_IN_ONE_REF.zip
2021-08-15 20:17:22 +00:00
BUILD_PATH: all_in_one
before_script:
- docker login -u $DOCKER_LOGIN -p $DOCKER_PASSWORD
- (if [ "$CI_COMMIT_REF_NAME" == "develop" ] || [ "$CI_COMMIT_REF_NAME" == "master" ] || [ "$CI_COMMIT_REF_NAME" == "stable" ]; then ./scripts/set-api-build-metadata.sh $(echo $CI_COMMIT_SHA | cut -c 1-8); fi);
2021-08-15 20:17:22 +00:00
script:
- if [[ ! -z "$CI_COMMIT_TAG" ]]; then (./docs/get-releases-json.py | scripts/is-docker-latest.py $CI_COMMIT_TAG -) && export DOCKER_LATEST_TAG="-t $ALL_IN_ONE_IMAGE_LATEST" || export DOCKER_LATEST_TAG=; fi
- wget $ALL_IN_ONE_ARTIFACT_URL -O all_in_one.zip
- unzip -o all_in_one.zip -d tmpdir
2021-08-17 08:45:27 +00:00
- mv tmpdir/funkwhale-docker-all-in-one-$ALL_IN_ONE_REF $BUILD_PATH && rmdir tmpdir
2021-08-15 20:17:22 +00:00
- 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_LATEST_TAG .
- docker push $ALL_IN_ONE_IMAGE
- if [[ ! -z "$DOCKER_LATEST_TAG" ]]; then docker push $ALL_IN_ONE_IMAGE_LATEST; fi
only:
- develop@funkwhale/funkwhale
- master@funkwhale/funkwhale
- stable@funkwhale/funkwhale
2021-08-15 20:17:22 +00:00
- tags@funkwhale/funkwhale
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
- (if [ "$CI_COMMIT_REF_NAME" == "develop" ] || [ "$CI_COMMIT_REF_NAME" == "stable" ] || [ "$CI_COMMIT_REF_NAME" == "master" ]; 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
- stable@funkwhale/funkwhale
- develop@funkwhale/funkwhale