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.

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