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.

256 lines
7.0KB

  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 --preload-modules
  51. federated-testing:
  52. stage: test
  53. services:
  54. - name: lainsoykaf/postgres-with-rum
  55. alias: postgres
  56. command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
  57. script:
  58. - mix deps.get
  59. - mix ecto.create
  60. - mix ecto.migrate
  61. - epmd -daemon
  62. - mix test --trace --only federated
  63. unit-testing-rum:
  64. stage: test
  65. services:
  66. - name: minibikini/postgres-with-rum:12
  67. alias: postgres
  68. command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
  69. variables:
  70. RUM_ENABLED: "true"
  71. script:
  72. - mix deps.get
  73. - mix ecto.create
  74. - mix ecto.migrate
  75. - "mix ecto.migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
  76. - mix test --preload-modules
  77. lint:
  78. stage: test
  79. script:
  80. - mix format --check-formatted
  81. analysis:
  82. stage: test
  83. script:
  84. - mix deps.get
  85. - mix credo --strict --only=warnings,todo,fixme,consistency,readability
  86. docs-deploy:
  87. stage: deploy
  88. image: alpine:latest
  89. only:
  90. - stable@pleroma/pleroma
  91. - develop@pleroma/pleroma
  92. before_script:
  93. - apk add curl
  94. script:
  95. - 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
  96. review_app:
  97. image: alpine:3.9
  98. stage: deploy
  99. before_script:
  100. - apk update && apk add openssh-client git
  101. when: manual
  102. environment:
  103. name: review/$CI_COMMIT_REF_NAME
  104. url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
  105. on_stop: stop_review_app
  106. only:
  107. - branches
  108. except:
  109. - master
  110. - develop
  111. script:
  112. - echo "$CI_ENVIRONMENT_SLUG"
  113. - mkdir -p ~/.ssh
  114. - eval $(ssh-agent -s)
  115. - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
  116. - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
  117. - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
  118. - (ssh -t dokku@pleroma.online -- git:set "$CI_ENVIRONMENT_SLUG" keep-git-dir true) || true
  119. - 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
  120. - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
  121. - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
  122. - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
  123. - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
  124. stop_review_app:
  125. image: alpine:3.9
  126. stage: deploy
  127. before_script:
  128. - apk update && apk add openssh-client git
  129. when: manual
  130. environment:
  131. name: review/$CI_COMMIT_REF_NAME
  132. action: stop
  133. script:
  134. - echo "$CI_ENVIRONMENT_SLUG"
  135. - mkdir -p ~/.ssh
  136. - eval $(ssh-agent -s)
  137. - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
  138. - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
  139. - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
  140. - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
  141. amd64:
  142. stage: release
  143. # TODO: Replace with upstream image when 1.9.0 comes out
  144. image: rinpatch/elixir:1.9.0-rc.0
  145. only: &release-only
  146. - stable@pleroma/pleroma
  147. - develop@pleroma/pleroma
  148. - /^maint/.*$/@pleroma/pleroma
  149. - /^release/.*$/@pleroma/pleroma
  150. artifacts: &release-artifacts
  151. name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
  152. paths:
  153. - release/*
  154. # Ideally it would be never for master branch and with the next commit for develop,
  155. # but Gitlab does not support neither `only` for artifacts
  156. # nor setting it to never from .gitlab-ci.yml
  157. # nor expiring with the next commit
  158. expire_in: 42 yrs
  159. cache: &release-cache
  160. key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
  161. paths:
  162. - deps
  163. variables: &release-variables
  164. MIX_ENV: prod
  165. before_script: &before-release
  166. - echo "import Mix.Config" > config/prod.secret.exs
  167. - mix local.hex --force
  168. - mix local.rebar --force
  169. script: &release
  170. - mix deps.get --only prod
  171. - mkdir release
  172. - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
  173. - mix release --path release
  174. amd64-musl:
  175. stage: release
  176. artifacts: *release-artifacts
  177. only: *release-only
  178. # TODO: Replace with upstream image when 1.9.0 comes out
  179. image: rinpatch/elixir:1.9.0-rc.0-alpine
  180. cache: *release-cache
  181. variables: *release-variables
  182. before_script: &before-release-musl
  183. - apk add git gcc g++ musl-dev make
  184. - echo "import Mix.Config" > config/prod.secret.exs
  185. - mix local.hex --force
  186. - mix local.rebar --force
  187. script: *release
  188. arm:
  189. stage: release
  190. artifacts: *release-artifacts
  191. only: *release-only
  192. tags:
  193. - arm32
  194. # TODO: Replace with upstream image when 1.9.0 comes out
  195. image: rinpatch/elixir:1.9.0-rc.0-arm
  196. cache: *release-cache
  197. variables: *release-variables
  198. before_script: *before-release
  199. script: *release
  200. arm-musl:
  201. stage: release
  202. artifacts: *release-artifacts
  203. only: *release-only
  204. tags:
  205. - arm32
  206. # TODO: Replace with upstream image when 1.9.0 comes out
  207. image: rinpatch/elixir:1.9.0-rc.0-arm-alpine
  208. cache: *release-cache
  209. variables: *release-variables
  210. before_script: *before-release-musl
  211. script: *release
  212. arm64:
  213. stage: release
  214. artifacts: *release-artifacts
  215. only: *release-only
  216. tags:
  217. - arm
  218. # TODO: Replace with upstream image when 1.9.0 comes out
  219. image: rinpatch/elixir:1.9.0-rc.0-arm64
  220. cache: *release-cache
  221. variables: *release-variables
  222. before_script: *before-release
  223. script: *release
  224. arm64-musl:
  225. stage: release
  226. artifacts: *release-artifacts
  227. only: *release-only
  228. tags:
  229. - arm
  230. # TODO: Replace with upstream image when 1.9.0 comes out
  231. image: rinpatch/elixir:1.9.0-rc.0-arm64-alpine
  232. cache: *release-cache
  233. variables: *release-variables
  234. before_script: *before-release-musl
  235. script: *release