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.

332 lines
9.3KB

  1. image: elixir:1.8.1
  2. variables: &global_variables
  3. POSTGRES_DB: pleroma_test
  4. POSTGRES_USER: postgres
  5. POSTGRES_PASSWORD: postgres
  6. DB_HOST: postgres
  7. MIX_ENV: test
  8. cache: &global_cache_policy
  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. - docker
  20. before_script:
  21. - mix local.hex --force
  22. - mix local.rebar --force
  23. build:
  24. stage: build
  25. script:
  26. - mix deps.get
  27. - mix compile --force
  28. benchmark:
  29. stage: benchmark
  30. when: manual
  31. variables:
  32. MIX_ENV: benchmark
  33. services:
  34. - name: postgres:9.6
  35. alias: postgres
  36. command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
  37. script:
  38. - mix deps.get
  39. - mix ecto.create
  40. - mix ecto.migrate
  41. - mix pleroma.load_testing
  42. unit-testing:
  43. stage: test
  44. cache: &testing_cache_policy
  45. <<: *global_cache_policy
  46. policy: pull
  47. services:
  48. - name: postgres:9.6
  49. alias: postgres
  50. command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
  51. script:
  52. - mix deps.get
  53. - mix ecto.create
  54. - mix ecto.migrate
  55. - mix coveralls --preload-modules
  56. federated-testing:
  57. stage: test
  58. cache: *testing_cache_policy
  59. services:
  60. - name: minibikini/postgres-with-rum:12
  61. alias: postgres
  62. command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
  63. script:
  64. - mix deps.get
  65. - mix ecto.create
  66. - mix ecto.migrate
  67. - epmd -daemon
  68. - mix test --trace --only federated
  69. unit-testing-rum:
  70. stage: test
  71. cache: *testing_cache_policy
  72. services:
  73. - name: minibikini/postgres-with-rum:12
  74. alias: postgres
  75. command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
  76. variables:
  77. <<: *global_variables
  78. RUM_ENABLED: "true"
  79. script:
  80. - mix deps.get
  81. - mix ecto.create
  82. - mix ecto.migrate
  83. - "mix ecto.migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
  84. - mix test --preload-modules
  85. lint:
  86. stage: test
  87. cache: *testing_cache_policy
  88. script:
  89. - mix format --check-formatted
  90. analysis:
  91. stage: test
  92. cache: *testing_cache_policy
  93. script:
  94. - mix deps.get
  95. - mix credo --strict --only=warnings,todo,fixme,consistency,readability
  96. docs-deploy:
  97. stage: deploy
  98. cache: *testing_cache_policy
  99. image: alpine:latest
  100. only:
  101. - stable@pleroma/pleroma
  102. - develop@pleroma/pleroma
  103. before_script:
  104. - apk add curl
  105. script:
  106. - 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
  107. review_app:
  108. image: alpine:3.9
  109. stage: deploy
  110. before_script:
  111. - apk update && apk add openssh-client git
  112. when: manual
  113. environment:
  114. name: review/$CI_COMMIT_REF_NAME
  115. url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
  116. on_stop: stop_review_app
  117. only:
  118. - branches
  119. except:
  120. - master
  121. - develop
  122. script:
  123. - echo "$CI_ENVIRONMENT_SLUG"
  124. - mkdir -p ~/.ssh
  125. - eval $(ssh-agent -s)
  126. - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
  127. - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
  128. - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
  129. - (ssh -t dokku@pleroma.online -- git:set "$CI_ENVIRONMENT_SLUG" keep-git-dir true) || true
  130. - 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
  131. - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
  132. - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
  133. - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
  134. - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
  135. stop_review_app:
  136. image: alpine:3.9
  137. stage: deploy
  138. before_script:
  139. - apk update && apk add openssh-client git
  140. when: manual
  141. environment:
  142. name: review/$CI_COMMIT_REF_NAME
  143. action: stop
  144. script:
  145. - echo "$CI_ENVIRONMENT_SLUG"
  146. - mkdir -p ~/.ssh
  147. - eval $(ssh-agent -s)
  148. - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
  149. - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
  150. - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
  151. - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
  152. amd64:
  153. stage: release
  154. # TODO: Replace with upstream image when 1.9.0 comes out
  155. image: rinpatch/elixir:1.9.0-rc.0
  156. only: &release-only
  157. - stable@pleroma/pleroma
  158. - develop@pleroma/pleroma
  159. - /^maint/.*$/@pleroma/pleroma
  160. - /^release/.*$/@pleroma/pleroma
  161. artifacts: &release-artifacts
  162. name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
  163. paths:
  164. - release/*
  165. # Ideally it would be never for master branch and with the next commit for develop,
  166. # but Gitlab does not support neither `only` for artifacts
  167. # nor setting it to never from .gitlab-ci.yml
  168. # nor expiring with the next commit
  169. expire_in: 42 yrs
  170. cache: &release-cache
  171. key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
  172. paths:
  173. - deps
  174. variables: &release-variables
  175. MIX_ENV: prod
  176. before_script: &before-release
  177. - echo "import Mix.Config" > config/prod.secret.exs
  178. - mix local.hex --force
  179. - mix local.rebar --force
  180. script: &release
  181. - mix deps.get --only prod
  182. - mkdir release
  183. - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
  184. - mix release --path release
  185. amd64-musl:
  186. stage: release
  187. artifacts: *release-artifacts
  188. only: *release-only
  189. # TODO: Replace with upstream image when 1.9.0 comes out
  190. image: rinpatch/elixir:1.9.0-rc.0-alpine
  191. cache: *release-cache
  192. variables: *release-variables
  193. before_script: &before-release-musl
  194. - apk add git gcc g++ musl-dev make
  195. - echo "import Mix.Config" > config/prod.secret.exs
  196. - mix local.hex --force
  197. - mix local.rebar --force
  198. script: *release
  199. arm:
  200. stage: release
  201. artifacts: *release-artifacts
  202. only: *release-only
  203. tags:
  204. - arm32
  205. # TODO: Replace with upstream image when 1.9.0 comes out
  206. image: rinpatch/elixir:1.9.0-rc.0-arm
  207. cache: *release-cache
  208. variables: *release-variables
  209. before_script: *before-release
  210. script: *release
  211. arm-musl:
  212. stage: release
  213. artifacts: *release-artifacts
  214. only: *release-only
  215. tags:
  216. - arm32
  217. # TODO: Replace with upstream image when 1.9.0 comes out
  218. image: rinpatch/elixir:1.9.0-rc.0-arm-alpine
  219. cache: *release-cache
  220. variables: *release-variables
  221. before_script: *before-release-musl
  222. script: *release
  223. arm64:
  224. stage: release
  225. artifacts: *release-artifacts
  226. only: *release-only
  227. tags:
  228. - arm
  229. # TODO: Replace with upstream image when 1.9.0 comes out
  230. image: rinpatch/elixir:1.9.0-rc.0-arm64
  231. cache: *release-cache
  232. variables: *release-variables
  233. before_script: *before-release
  234. script: *release
  235. arm64-musl:
  236. stage: release
  237. artifacts: *release-artifacts
  238. only: *release-only
  239. tags:
  240. - arm
  241. # TODO: Replace with upstream image when 1.9.0 comes out
  242. image: rinpatch/elixir:1.9.0-rc.0-arm64-alpine
  243. cache: *release-cache
  244. variables: *release-variables
  245. before_script: *before-release-musl
  246. script: *release
  247. docker:
  248. stage: docker
  249. image: docker:latest
  250. cache: {}
  251. dependencies: []
  252. variables: &docker-variables
  253. DOCKER_DRIVER: overlay2
  254. DOCKER_HOST: unix:///var/run/docker.sock
  255. IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
  256. IMAGE_TAG_SLUG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
  257. IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
  258. IMAGE_TAG_LATEST_STABLE: $CI_REGISTRY_IMAGE:latest-stable
  259. before_script: &before-docker
  260. - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
  261. - docker pull $IMAGE_TAG_SLUG || true
  262. - export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
  263. - export CI_VCS_REF=$CI_COMMIT_SHORT_SHA
  264. allow_failure: true
  265. script:
  266. - docker build --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST .
  267. - docker push $IMAGE_TAG
  268. - docker push $IMAGE_TAG_SLUG
  269. - docker push $IMAGE_TAG_LATEST
  270. tags:
  271. - dind
  272. only:
  273. - develop@pleroma/pleroma
  274. docker-stable:
  275. stage: docker
  276. image: docker:latest
  277. cache: {}
  278. dependencies: []
  279. variables: *docker-variables
  280. before_script: *before-docker
  281. allow_failure: true
  282. script:
  283. - docker build --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST_STABLE .
  284. - docker push $IMAGE_TAG
  285. - docker push $IMAGE_TAG_SLUG
  286. - docker push $IMAGE_TAG_LATEST_STABLE
  287. tags:
  288. - dind
  289. only:
  290. - stable@pleroma/pleroma
  291. docker-release:
  292. stage: docker
  293. image: docker:latest
  294. cache: {}
  295. dependencies: []
  296. variables: *docker-variables
  297. before_script: *before-docker
  298. allow_failure: true
  299. script:
  300. - docker build --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG .
  301. - docker push $IMAGE_TAG
  302. - docker push $IMAGE_TAG_SLUG
  303. tags:
  304. - dind
  305. only:
  306. - /^release/.*$/@pleroma/pleroma