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.

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