Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

248 řádky
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. - /^maint/.*$/@pleroma/pleroma
  141. artifacts: &release-artifacts
  142. name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
  143. paths:
  144. - release/*
  145. # Ideally it would be never for master branch and with the next commit for develop,
  146. # but Gitlab does not support neither `only` for artifacts
  147. # nor setting it to never from .gitlab-ci.yml
  148. # nor expiring with the next commit
  149. expire_in: 42 yrs
  150. cache: &release-cache
  151. key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
  152. paths:
  153. - deps
  154. variables: &release-variables
  155. MIX_ENV: prod
  156. before_script: &before-release
  157. - echo "import Mix.Config" > config/prod.secret.exs
  158. - mix local.hex --force
  159. - mix local.rebar --force
  160. script: &release
  161. - mix deps.get --only prod
  162. - mkdir release
  163. - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
  164. - mix release --path release
  165. amd64-musl:
  166. stage: release
  167. artifacts: *release-artifacts
  168. only: *release-only
  169. # TODO: Replace with upstream image when 1.9.0 comes out
  170. image: rinpatch/elixir:1.9.0-rc.0-alpine
  171. cache: *release-cache
  172. variables: *release-variables
  173. before_script: &before-release-musl
  174. - apk add git gcc g++ musl-dev make
  175. - echo "import Mix.Config" > config/prod.secret.exs
  176. - mix local.hex --force
  177. - mix local.rebar --force
  178. script: *release
  179. arm:
  180. stage: release
  181. artifacts: *release-artifacts
  182. only: *release-only
  183. tags:
  184. - arm32
  185. # TODO: Replace with upstream image when 1.9.0 comes out
  186. image: rinpatch/elixir:1.9.0-rc.0-arm
  187. cache: *release-cache
  188. variables: *release-variables
  189. before_script: *before-release
  190. script: *release
  191. arm-musl:
  192. stage: release
  193. artifacts: *release-artifacts
  194. only: *release-only
  195. tags:
  196. - arm32
  197. # TODO: Replace with upstream image when 1.9.0 comes out
  198. image: rinpatch/elixir:1.9.0-rc.0-arm-alpine
  199. cache: *release-cache
  200. variables: *release-variables
  201. before_script: *before-release-musl
  202. script: *release
  203. arm64:
  204. stage: release
  205. artifacts: *release-artifacts
  206. only: *release-only
  207. tags:
  208. - arm
  209. # TODO: Replace with upstream image when 1.9.0 comes out
  210. image: rinpatch/elixir:1.9.0-rc.0-arm64
  211. cache: *release-cache
  212. variables: *release-variables
  213. before_script: *before-release
  214. script: *release
  215. arm64-musl:
  216. stage: release
  217. artifacts: *release-artifacts
  218. only: *release-only
  219. tags:
  220. - arm
  221. # TODO: Replace with upstream image when 1.9.0 comes out
  222. image: rinpatch/elixir:1.9.0-rc.0-arm64-alpine
  223. cache: *release-cache
  224. variables: *release-variables
  225. before_script: *before-release-musl
  226. script: *release