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.

258 lines
6.8KB

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