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.

334 lines
9.4KB

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