pleroma/.gitlab-ci.yml

144 lines
2.9 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
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
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:
2022-08-26 15:36:49 -07:00
changes: *elixir-changes
services: &db-services
2022-07-11 00:28:30 -07:00
- 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 coveralls --preload-modules
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:
2022-08-26 15:36:49 -07:00
image: &current-elixir elixir:1.12-alpine
stage: test
only:
2022-08-26 15:36:49 -07:00
changes: *elixir-changes
before_script: &current-setup
2022-07-11 00:28:47 -07:00
- apk update
- apk add build-base cmake file-dev git openssl
2021-12-26 09:54:54 -08:00
- mix local.hex --force
- mix local.rebar --force
- mix deps.get
script:
- mix format --check-formatted
analysis:
stage: test
only:
2022-08-26 15:36:49 -07:00
changes: *elixir-changes
script:
- mix credo --strict --only=warnings,todo,fixme,consistency,readability
cycles:
2022-08-26 15:36:49 -07:00
image: *current-elixir
stage: test
only:
2022-08-26 15:36:49 -07:00
changes: *elixir-changes
2021-06-09 11:12:33 -07:00
cache: {}
2022-08-26 15:36:49 -07:00
before_script: *current-setup
2021-12-26 09:54:54 -08:00
script:
- mix compile
- 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-08-26 15:36:49 -07:00
stage: deps
2019-05-31 01:55:35 -07:00
environment:
name: review/$CI_COMMIT_REF_NAME
2022-08-05 11:14:03 -07:00
url: https://$CI_ENVIRONMENT_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-08-05 12:20:57 -07:00
GIT_REMOTE_URL: ssh://dokku@$DOKKU_HOST/$CI_ENVIRONMENT_SLUG
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
changes: &elixir-changes
- ".gitlab-ci.yml"
- "**/*.ex"
- "**/*.exs"
- "mix.lock"