Local copy of Pleroma, an ActivityPub server software. Contains modifications running live on fedi.underscore.world
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.

351 lines
11KB

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