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.

246 lines
6.5KB

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