following upstream develop; adds sentry
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.

225 lines
6.2 KiB

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