pleroma/.gitlab-ci.yml

162 lines
3.4 KiB
YAML
Raw Normal View History

2022-08-26 14:31:00 -07:00
image: registry.gitlab.com/soapbox-pub/rebased/ci
2017-11-02 09:26:13 -07:00
variables: &global_variables
2017-11-02 09:26:13 -07:00
POSTGRES_DB: pleroma_test
2017-11-02 09:52:53 -07:00
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
2018-04-24 05:28:59 -07:00
DB_HOST: postgres
2022-11-11 07:22:21 -08:00
DB_PORT: 5432
MIX_ENV: test
2022-08-05 12:59:25 -07:00
# Needed for Dokku deployment.
# https://github.com/dokku/dokku/issues/2514#issuecomment-616775470
GIT_DEPTH: 0
2022-08-26 15:36:49 -07:00
cache: &cache
2021-04-28 10:31:22 -07:00
key:
files:
- mix.lock
2018-11-29 00:45:14 -08:00
paths:
- deps
- _build
2022-08-26 15:36:49 -07:00
policy: pull
2017-11-02 09:26:13 -07:00
stages:
2022-08-26 15:36:49 -07:00
- deps
2017-11-02 09:26:13 -07:00
- test
- deploy
2017-11-02 09:26:13 -07:00
deps:
2022-08-26 15:36:49 -07:00
stage: deps
script:
- mix deps.get
- mix deps.compile
cache:
<<: *cache
policy: pull-push
only:
changes:
- mix.lock
2022-08-26 15:36:49 -07:00
openapi:
stage: test
only:
changes:
- ".gitlab-ci.yml"
- "lib/pleroma/web/api_spec/**/*.ex"
- "lib/pleroma/web/api_spec.ex"
artifacts:
paths:
2022-08-26 15:36:49 -07:00
- spec.json
2019-10-10 05:24:54 -07:00
script:
2022-08-26 15:36:49 -07:00
- mix pleroma.openapi_spec spec.json
2019-06-13 03:53:59 -07:00
2022-08-26 15:37:59 -07:00
test:
stage: test
only:
changes: &elixir-changes
- ".gitlab-ci.yml"
- "**/*.ex"
- "**/*.exs"
- "mix.lock"
2022-08-26 15:36:49 -07:00
services: &db-services
- name: postgres:13-alpine
alias: postgres
command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
2022-08-26 15:36:49 -07:00
before_script: &db-setup
- mix ecto.create
- mix ecto.migrate
2022-08-26 15:36:49 -07:00
script:
- mix test --cover --preload-modules
coverage: '/^Line total: ([^ ]*%)$/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
2022-08-26 15:37:59 -07:00
test-erratic:
stage: test
2022-01-15 11:35:22 -08:00
allow_failure: true
only:
2022-08-26 15:36:49 -07:00
changes: *elixir-changes
services: *db-services
before_script: *db-setup
script:
- mix test --only=erratic
lint:
stage: test
only:
2022-08-26 15:36:49 -07:00
changes: *elixir-changes
script:
- mix format --check-formatted
2023-06-07 07:16:59 -07:00
# analysis:
# stage: test
# only:
# changes: *elixir-changes
# script:
# - mix credo --strict --only=warnings,todo,fixme,consistency,readability
cycles:
stage: test
only:
2022-08-26 15:36:49 -07:00
changes: *elixir-changes
2021-12-26 09:54:54 -08:00
script:
- mix xref graph --format cycles --label compile | awk '{print $0} END{exit ($0 != "No cycles found")}'
2022-08-05 11:14:03 -07:00
# Deploy with Dokku
# https://github.com/dokku/gitlab-ci
# https://github.com/dokku/ci-docker-image
2022-08-26 15:36:49 -07:00
review:
2022-08-05 11:14:03 -07:00
image: dokku/ci-docker-image
2022-09-04 19:31:30 -07:00
stage: test
2019-05-31 01:55:35 -07:00
environment:
name: review/$CI_COMMIT_REF_NAME
2022-09-04 20:04:40 -07:00
url: https://rebased-$CI_COMMIT_REF_SLUG.dokku.soapbox.pub
2019-05-31 01:55:35 -07:00
only:
- branches
except:
- develop
2022-08-05 11:14:03 -07:00
variables:
2022-09-04 20:04:40 -07:00
GIT_REMOTE_URL: ssh://dokku@$DOKKU_HOST/rebased-$CI_COMMIT_REF_SLUG
2022-09-04 21:00:10 -07:00
GIT_PUSH_FLAGS: --force
2022-08-05 11:14:03 -07:00
script: dokku-deploy
allow_failure: true
release:
stage: deploy
variables:
MIX_ENV: prod
PLEROMA_BUILD_BRANCH: $CI_COMMIT_REF_NAME
script:
- mix deps.get
- mkdir release
- mix release --path release
artifacts:
name: "rebased-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
paths:
- release/*
cache: {}
only:
refs:
- develop
2022-09-04 20:06:02 -07:00
changes: *elixir-changes
docker:
stage: deploy
image: docker:20.10.17
cache: {}
services:
- docker:20.10.17-dind
2022-10-09 10:25:23 -07:00
tags:
- dind
2022-09-04 20:06:02 -07:00
# https://medium.com/devops-with-valentine/how-to-build-a-docker-image-and-push-it-to-the-gitlab-container-registry-from-a-gitlab-ci-pipeline-acac0d1f26df
script:
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
- docker build -t $CI_REGISTRY_IMAGE .
- docker push $CI_REGISTRY_IMAGE
only:
refs:
- develop