pleroma/.gitlab-ci.yml
2022-08-29 20:48:51 -05:00

141 lines
2.9 KiB
YAML

image: registry.gitlab.com/soapbox-pub/rebased/ci
variables: &global_variables
POSTGRES_DB: pleroma_test
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
DB_HOST: postgres
MIX_ENV: test
# Needed for Dokku deployment.
# https://github.com/dokku/dokku/issues/2514#issuecomment-616775470
GIT_DEPTH: 0
cache: &cache
key:
files:
- mix.lock
paths:
- deps
- _build
policy: pull
stages:
- deps
- test
test-deps:
stage: deps
script:
- mix deps.get
- mix deps.compile
cache:
<<: *cache
policy: pull-push
release:
stage: deps
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:
changes: &elixir-changes
- ".gitlab-ci.yml"
- "**/*.ex"
- "**/*.exs"
- "mix.lock"
openapi:
stage: test
only:
changes:
- ".gitlab-ci.yml"
- "lib/pleroma/web/api_spec/**/*.ex"
- "lib/pleroma/web/api_spec.ex"
artifacts:
paths:
- spec.json
script:
- mix pleroma.openapi_spec spec.json
test:
stage: test
only:
changes: *elixir-changes
services: &db-services
- name: postgres:13-alpine
alias: postgres
command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
before_script: &db-setup
- mix ecto.create
- mix ecto.migrate
script:
- mix coveralls --preload-modules
test-erratic:
stage: test
allow_failure: true
only:
changes: *elixir-changes
services: *db-services
before_script: *db-setup
script:
- mix test --only=erratic
lint:
image: &current-elixir elixir:1.12-alpine
stage: test
only:
changes: *elixir-changes
before_script: &current-setup
- apk update
- apk add build-base cmake file-dev git openssl
- mix local.hex --force
- mix local.rebar --force
- mix deps.get
script:
- mix format --check-formatted
analysis:
stage: test
only:
changes: *elixir-changes
script:
- mix credo --strict --only=warnings,todo,fixme,consistency,readability
cycles:
image: *current-elixir
stage: test
only:
changes: *elixir-changes
cache: {}
before_script: *current-setup
script:
- mix compile
- mix xref graph --format cycles --label compile | awk '{print $0} END{exit ($0 != "No cycles found")}'
# Deploy with Dokku
# https://github.com/dokku/gitlab-ci
# https://github.com/dokku/ci-docker-image
review:
image: dokku/ci-docker-image
stage: deps
environment:
name: review/$CI_COMMIT_REF_NAME
url: https://$CI_ENVIRONMENT_SLUG.dokku.soapbox.pub
only:
- branches
except:
- develop
variables:
GIT_REMOTE_URL: ssh://dokku@$DOKKU_HOST/$CI_ENVIRONMENT_SLUG
script: dokku-deploy
allow_failure: true