funkwhale/.gitlab-ci.yml

490 wiersze
14 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: ""
BUILD_PLATFORMS: linux/amd64,linux/arm64,linux/arm/v7
2022-09-08 12:09:51 +00:00
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH
2017-06-25 17:12:23 +00:00
stages:
2022-09-08 12:09:51 +00:00
- deploy
- lint
- test
2022-09-08 12:09:51 +00:00
- build
- publish
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
2022-09-08 12:09:51 +00:00
stage: deploy
2022-11-08 22:02:27 +00:00
image: node:18-alpine
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:
2022-07-10 17:31:37 +00:00
- apk add --no-cache jq bash coreutils python3
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
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
2022-09-08 12:09:51 +00:00
stage: deploy
2019-06-13 12:50:31 +00:00
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
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
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- docs/**/*
- if: $CI_PIPELINE_SOURCE != "merge_request_event" && $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH
when: manual
2019-06-13 12:50:31 +00:00
2022-02-05 21:42:31 +00:00
changelog_snippet:
interruptible: true
image: alpine:3.17
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'
2022-11-18 21:24:50 +00:00
pre-commit:
stage: lint
image: python:3.10
variables:
PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip
PRE_COMMIT_HOME: $CI_PROJECT_DIR/.cache/pre-commit
cache:
paths:
- $PIP_CACHE_DIR
- $PRE_COMMIT_HOME
before_script:
- pip3 install pre-commit
script:
- pre-commit run --all --color=always --show-diff-on-failure
2022-02-05 21:42:31 +00:00
black:
2019-09-23 09:15:32 +00:00
interruptible: true
2022-07-10 17:31:37 +00:00
image: python:3.10
stage: lint
2018-06-09 15:03:06 +00:00
variables:
GIT_STRATEGY: fetch
before_script:
- pip install black
script:
2022-07-15 07:49:37 +00:00
- black --check --diff .
2022-09-15 08:39:06 +00:00
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- api/**/*
2018-06-09 15:12:58 +00:00
flake8:
2019-09-23 09:15:32 +00:00
interruptible: true
2022-07-10 17:31:37 +00:00
image: python:3.7
2018-06-09 15:12:58 +00:00
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"
2022-09-15 08:39:06 +00:00
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- api/**/*
2021-07-16 18:34:46 +00:00
eslint:
interruptible: true
2022-11-08 22:02:27 +00:00
image: node:18-alpine
2021-07-16 18:34:46 +00:00
stage: lint
before_script:
- cd front
2022-07-10 17:31:37 +00:00
- apk add --no-cache jq bash coreutils python3
2021-07-16 18:34:46 +00:00
- yarn install
script:
2021-12-08 18:48:06 +00:00
- yarn lint --max-warnings 0
- yarn lint:tsc
2021-07-16 18:34:46 +00:00
cache:
key: "$CI_PROJECT_ID__eslint_npm_cache"
paths:
- front/node_modules
2022-09-15 08:39:06 +00:00
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
changes:
- front/**/*
2021-07-16 18:34:46 +00:00
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:
- postgres:15-alpine
2022-07-10 17:31:37 +00:00
- redis:7-alpine
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"
2017-06-25 17:13:46 +00:00
before_script:
- cd api
- 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:
expire_in: 2 weeks
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", "3.11"]
2022-02-05 17:26:10 +00:00
image: $CI_REGISTRY/funkwhale/backend-test-docker:$PY_VER
2022-10-14 06:30:52 +00:00
coverage: '/TOTAL\s*\d*\s*\d*\s*(\d*%)/'
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "push"
changes:
- api/**/*
- if: $CI_COMMIT_REF_PROTECTED == "true"
when: always
2022-10-30 18:39:04 +00:00
# Those tests are disabled for now since no vitest dom emulation is providing
# AudioContext, which is required for our HTML audio player
#test_front:
# interruptible: true
# stage: test
2022-11-08 22:02:27 +00:00
# image: node:18-alpine
2022-10-30 18:39:04 +00:00
# before_script:
# - cd front
# - apk add --no-cache jq bash coreutils python3
# script:
# - yarn install --check-files
# - yarn test:unit
# cache:
# key: "funkwhale__front_dependencies"
# paths:
# - front/node_modules
# - front/yarn.lock
# artifacts:
# name: "front_${CI_COMMIT_REF_NAME}"
# paths:
# - front/dist/
# reports:
# junit: front/coverage/cobertura-coverage.xml
# tags:
# - docker
# rules:
# - if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_PIPELINE_SOURCE == "push"
# changes:
# - front/**/*
# - if: $CI_COMMIT_REF_PROTECTED == "true"
2022-10-30 18:39:04 +00:00
# when: always
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:
- postgres:15-alpine
2022-07-10 17:31:37 +00:00
- redis:7-alpine
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"
2022-07-16 07:17:12 +00:00
API_TYPE: "v1"
2022-01-28 12:33:39 +00:00
before_script:
- cd api
- pip3 install poetry
- poetry install
- poetry run python manage.py migrate
script:
- poetry run python manage.py spectacular --file ../docs/schema.yml
tags:
- docker
artifacts:
expire_in: 2 weeks
2022-01-28 12:33:39 +00:00
paths:
- docs/schema.yml
2017-06-25 17:13:46 +00:00
build_front:
stage: build
2022-11-08 22:02:27 +00:00
image: node:18-alpine
2017-06-25 17:13:46 +00:00
before_script:
2022-07-10 17:31:37 +00:00
- apk add --no-cache jq bash coreutils python3
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
- 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:
expire_in: 2 weeks
2017-06-25 17:05:31 +00:00
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == "stable"
when: always
- if: $CI_COMMIT_BRANCH == "develop"
changes:
- docs/**/*
when: always
2017-06-25 17:07:49 +00:00
tags:
- docker
deploy_documentation:
2022-09-08 12:09:51 +00:00
stage: publish
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:
2022-09-08 12:09:51 +00:00
stage: publish
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
cache:
key: docker_public_${CI_COMMIT_REF_NAME}
paths:
- ~/.cargo
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:
2022-09-08 12:09:51 +00:00
stage: publish
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" == "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
- stable@funkwhale/funkwhale
2021-08-15 20:17:22 +00:00
- tags@funkwhale/funkwhale
build_api:
# Simply publish a zip containing api/ directory
2022-09-08 12:09:51 +00:00
stage: publish
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
2022-11-19 17:53:38 +00:00
- >
if [ "$CI_COMMIT_REF_NAME" == "develop" ] || [ "$CI_COMMIT_REF_NAME" == "stable" ]; then
./scripts/set-api-build-metadata.sh $(echo $CI_COMMIT_SHA | cut -c 1-8);
fi
- chmod -R 750 api
only:
- tags@funkwhale/funkwhale
- stable@funkwhale/funkwhale
- develop@funkwhale/funkwhale