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.

336 lines
9.4KB

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