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 - deploy deps: stage: deps script: - mix deps.get - mix deps.compile cache: <<: *cache policy: pull-push 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 - ".gitlab-ci.yml" - "**/*.ex" - "**/*.exs" - "mix.lock" 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: stage: test only: changes: *elixir-changes script: - mix format --check-formatted analysis: stage: test only: changes: *elixir-changes script: - mix credo --strict --only=warnings,todo,fixme,consistency,readability cycles: stage: test only: changes: *elixir-changes cache: {} script: - 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 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