Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

242 lines
6.6KB

  1. image: elixir:1.8.1
  2. variables:
  3. POSTGRES_DB: pleroma_test
  4. POSTGRES_USER: postgres
  5. POSTGRES_PASSWORD: postgres
  6. DB_HOST: postgres
  7. MIX_ENV: test
  8. cache:
  9. key: ${CI_COMMIT_REF_SLUG}
  10. paths:
  11. - deps
  12. - _build
  13. stages:
  14. - build
  15. - test
  16. - benchmark
  17. - deploy
  18. - release
  19. before_script:
  20. - mix local.hex --force
  21. - mix local.rebar --force
  22. build:
  23. stage: build
  24. script:
  25. - mix deps.get
  26. - mix compile --force
  27. benchmark:
  28. stage: benchmark
  29. variables:
  30. MIX_ENV: benchmark
  31. services:
  32. - name: postgres:9.6
  33. alias: postgres
  34. command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
  35. script:
  36. - mix deps.get
  37. - mix ecto.create
  38. - mix ecto.migrate
  39. - mix pleroma.load_testing
  40. unit-testing:
  41. stage: test
  42. services:
  43. - name: postgres:9.6
  44. alias: postgres
  45. command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
  46. script:
  47. - mix deps.get
  48. - mix ecto.create
  49. - mix ecto.migrate
  50. - mix coveralls --trace --preload-modules
  51. unit-testing-rum:
  52. stage: test
  53. services:
  54. - name: minibikini/postgres-with-rum:12
  55. alias: postgres
  56. command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
  57. variables:
  58. RUM_ENABLED: "true"
  59. script:
  60. - mix deps.get
  61. - mix ecto.create
  62. - mix ecto.migrate
  63. - "mix ecto.migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
  64. - mix test --trace --preload-modules
  65. lint:
  66. stage: test
  67. script:
  68. - mix format --check-formatted
  69. analysis:
  70. stage: test
  71. script:
  72. - mix deps.get
  73. - mix credo --strict --only=warnings,todo,fixme,consistency,readability
  74. docs-deploy:
  75. stage: deploy
  76. image: alpine:latest
  77. only:
  78. - stable@pleroma/pleroma
  79. - develop@pleroma/pleroma
  80. before_script:
  81. - apk add curl
  82. script:
  83. - curl -X POST -F"token=$DOCS_PIPELINE_TRIGGER" -F'ref=master' -F"variables[BRANCH]=$CI_COMMIT_REF_NAME" https://git.pleroma.social/api/v4/projects/673/trigger/pipeline
  84. review_app:
  85. image: alpine:3.9
  86. stage: deploy
  87. before_script:
  88. - apk update && apk add openssh-client git
  89. when: manual
  90. environment:
  91. name: review/$CI_COMMIT_REF_NAME
  92. url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
  93. on_stop: stop_review_app
  94. only:
  95. - branches
  96. except:
  97. - master
  98. - develop
  99. script:
  100. - echo "$CI_ENVIRONMENT_SLUG"
  101. - mkdir -p ~/.ssh
  102. - eval $(ssh-agent -s)
  103. - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
  104. - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
  105. - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
  106. - ssh -t dokku@pleroma.online -- config:set "$CI_ENVIRONMENT_SLUG" APP_NAME="$CI_ENVIRONMENT_SLUG" APP_HOST="$CI_ENVIRONMENT_SLUG.pleroma.online" MIX_ENV=dokku
  107. - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
  108. - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
  109. - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
  110. - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
  111. stop_review_app:
  112. image: alpine:3.9
  113. stage: deploy
  114. before_script:
  115. - apk update && apk add openssh-client git
  116. when: manual
  117. environment:
  118. name: review/$CI_COMMIT_REF_NAME
  119. action: stop
  120. script:
  121. - echo "$CI_ENVIRONMENT_SLUG"
  122. - mkdir -p ~/.ssh
  123. - eval $(ssh-agent -s)
  124. - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
  125. - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
  126. - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
  127. - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
  128. amd64:
  129. stage: release
  130. # TODO: Replace with upstream image when 1.9.0 comes out
  131. image: rinpatch/elixir:1.9.0-rc.0
  132. only: &release-only
  133. - stable@pleroma/pleroma
  134. - develop@pleroma/pleroma
  135. - /^maint/.*$/@pleroma/pleroma
  136. - /^release/.*$/@pleroma/pleroma
  137. artifacts: &release-artifacts
  138. name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
  139. paths:
  140. - release/*
  141. # Ideally it would be never for master branch and with the next commit for develop,
  142. # but Gitlab does not support neither `only` for artifacts
  143. # nor setting it to never from .gitlab-ci.yml
  144. # nor expiring with the next commit
  145. expire_in: 42 yrs
  146. cache: &release-cache
  147. key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
  148. paths:
  149. - deps
  150. variables: &release-variables
  151. MIX_ENV: prod
  152. before_script: &before-release
  153. - echo "import Mix.Config" > config/prod.secret.exs
  154. - mix local.hex --force
  155. - mix local.rebar --force
  156. script: &release
  157. - mix deps.get --only prod
  158. - mkdir release
  159. - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
  160. - mix release --path release
  161. amd64-musl:
  162. stage: release
  163. artifacts: *release-artifacts
  164. only: *release-only
  165. # TODO: Replace with upstream image when 1.9.0 comes out
  166. image: rinpatch/elixir:1.9.0-rc.0-alpine
  167. cache: *release-cache
  168. variables: *release-variables
  169. before_script: &before-release-musl
  170. - apk add git gcc g++ musl-dev make
  171. - echo "import Mix.Config" > config/prod.secret.exs
  172. - mix local.hex --force
  173. - mix local.rebar --force
  174. script: *release
  175. arm:
  176. stage: release
  177. artifacts: *release-artifacts
  178. only: *release-only
  179. tags:
  180. - arm32
  181. # TODO: Replace with upstream image when 1.9.0 comes out
  182. image: rinpatch/elixir:1.9.0-rc.0-arm
  183. cache: *release-cache
  184. variables: *release-variables
  185. before_script: *before-release
  186. script: *release
  187. arm-musl:
  188. stage: release
  189. artifacts: *release-artifacts
  190. only: *release-only
  191. tags:
  192. - arm32
  193. # TODO: Replace with upstream image when 1.9.0 comes out
  194. image: rinpatch/elixir:1.9.0-rc.0-arm-alpine
  195. cache: *release-cache
  196. variables: *release-variables
  197. before_script: *before-release-musl
  198. script: *release
  199. arm64:
  200. stage: release
  201. artifacts: *release-artifacts
  202. only: *release-only
  203. tags:
  204. - arm
  205. # TODO: Replace with upstream image when 1.9.0 comes out
  206. image: rinpatch/elixir:1.9.0-rc.0-arm64
  207. cache: *release-cache
  208. variables: *release-variables
  209. before_script: *before-release
  210. script: *release
  211. arm64-musl:
  212. stage: release
  213. artifacts: *release-artifacts
  214. only: *release-only
  215. tags:
  216. - arm
  217. # TODO: Replace with upstream image when 1.9.0 comes out
  218. image: rinpatch/elixir:1.9.0-rc.0-arm64-alpine
  219. cache: *release-cache
  220. variables: *release-variables
  221. before_script: *before-release-musl
  222. script: *release