logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/

.gitlab-ci.yml (15667B)


  1. image: git.pleroma.social:5050/pleroma/pleroma/ci-base:elixir-1.14.5-otp-25
  2. variables: &global_variables
  3. # Only used for the release
  4. ELIXIR_VER: 1.14.5
  5. POSTGRES_DB: pleroma_test
  6. POSTGRES_USER: postgres
  7. POSTGRES_PASSWORD: postgres
  8. DB_HOST: postgres
  9. DB_PORT: "5432"
  10. MIX_ENV: test
  11. GIT_STRATEGY: fetch
  12. workflow:
  13. rules:
  14. - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  15. - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
  16. when: never
  17. - if: $CI_COMMIT_BRANCH
  18. cache: &global_cache_policy
  19. key: $CI_JOB_IMAGE-$CI_COMMIT_SHORT_SHA
  20. paths:
  21. - deps
  22. - _build
  23. stages:
  24. - build
  25. - lint
  26. - test
  27. - check-changelog
  28. - benchmark
  29. - deploy
  30. - release
  31. - docker
  32. - docker-combine
  33. before_script:
  34. - echo $MIX_ENV
  35. - rm -rf _build/*/lib/pleroma
  36. - mix deps.get
  37. after_script:
  38. - rm -rf _build/*/lib/pleroma
  39. check-changelog:
  40. stage: check-changelog
  41. image: alpine
  42. rules:
  43. - if: $CI_MERGE_REQUEST_SOURCE_PROJECT_PATH == 'pleroma/pleroma' && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == 'weblate-extract'
  44. when: never
  45. - if: $CI_MERGE_REQUEST_SOURCE_PROJECT_PATH == 'pleroma/pleroma' && $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == 'weblate'
  46. when: never
  47. - if: $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"
  48. before_script: ''
  49. after_script: ''
  50. cache: {}
  51. script:
  52. - apk add git
  53. - sh ./tools/check-changelog
  54. .build_changes_policy:
  55. rules:
  56. - changes:
  57. - ".gitlab-ci.yml"
  58. - "**/*.ex"
  59. - "**/*.exs"
  60. - "mix.lock"
  61. .using-ci-base:
  62. tags:
  63. - amd64
  64. build-1.14.5-otp-25:
  65. extends:
  66. - .build_changes_policy
  67. - .using-ci-base
  68. stage: build
  69. script:
  70. - mix compile --force
  71. build-1.17.1-otp-26:
  72. extends:
  73. - .build_changes_policy
  74. - .using-ci-base
  75. stage: build
  76. image: git.pleroma.social:5050/pleroma/pleroma/ci-base:elixir-1.17.1-otp-26
  77. script:
  78. - mix compile --force
  79. spec-build:
  80. extends:
  81. - .using-ci-base
  82. stage: build
  83. rules:
  84. - changes:
  85. - ".gitlab-ci.yml"
  86. - "lib/pleroma/web/api_spec/**/*.ex"
  87. - "lib/pleroma/web/api_spec.ex"
  88. artifacts:
  89. paths:
  90. - spec.json
  91. script:
  92. - mix pleroma.openapi_spec spec.json
  93. benchmark:
  94. extends:
  95. - .using-ci-base
  96. stage: benchmark
  97. when: manual
  98. variables:
  99. MIX_ENV: benchmark
  100. services:
  101. - name: postgres:11.22-alpine
  102. alias: postgres
  103. command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
  104. script:
  105. - mix ecto.create
  106. - mix ecto.migrate
  107. - mix pleroma.load_testing
  108. unit-testing-1.14.5-otp-25:
  109. extends:
  110. - .build_changes_policy
  111. - .using-ci-base
  112. stage: test
  113. cache: &testing_cache_policy
  114. <<: *global_cache_policy
  115. policy: pull
  116. services: &testing_services
  117. - name: postgres:13-alpine
  118. alias: postgres
  119. command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
  120. script: &testing_script
  121. - mix ecto.create
  122. - mix ecto.migrate
  123. - mix pleroma.test_runner --cover --preload-modules
  124. coverage: '/^Line total: ([^ ]*%)$/'
  125. artifacts:
  126. reports:
  127. coverage_report:
  128. coverage_format: cobertura
  129. path: coverage.xml
  130. unit-testing-1.17.1-otp-26:
  131. extends:
  132. - .build_changes_policy
  133. - .using-ci-base
  134. stage: test
  135. image: git.pleroma.social:5050/pleroma/pleroma/ci-base:elixir-1.17.1-otp-26
  136. cache: *testing_cache_policy
  137. services: *testing_services
  138. script: *testing_script
  139. formatting-1.15:
  140. extends: .build_changes_policy
  141. image: &formatting_elixir elixir:1.15-alpine
  142. stage: lint
  143. cache: *testing_cache_policy
  144. before_script: &current_bfr_script
  145. - apk update
  146. - apk add build-base cmake file-dev git openssl
  147. - mix local.hex --force
  148. - mix local.rebar --force
  149. - mix deps.get
  150. script:
  151. - mix format --check-formatted
  152. cycles-1.15:
  153. extends: .build_changes_policy
  154. image: *formatting_elixir
  155. stage: lint
  156. cache: {}
  157. before_script: *current_bfr_script
  158. script:
  159. - mix compile
  160. - mix xref graph --format cycles --label compile | awk '{print $0} END{exit ($0 != "No cycles found")}'
  161. analysis:
  162. extends:
  163. - .build_changes_policy
  164. - .using-ci-base
  165. stage: lint
  166. cache: *testing_cache_policy
  167. script:
  168. - mix credo --strict --only=warnings,todo,fixme,consistency,readability
  169. dialyzer:
  170. extends:
  171. - .build_changes_policy
  172. - .using-ci-base
  173. stage: lint
  174. allow_failure: true
  175. when: manual
  176. cache: *testing_cache_policy
  177. tags:
  178. - feld
  179. script:
  180. - mix dialyzer
  181. docs-deploy:
  182. stage: deploy
  183. cache: *testing_cache_policy
  184. image: alpine:latest
  185. only:
  186. - stable@pleroma/pleroma
  187. - develop@pleroma/pleroma
  188. before_script:
  189. - apk add curl
  190. script:
  191. - curl --fail-with-body -X POST -F"token=$CI_JOB_TOKEN" -F'ref=master' -F"variables[BRANCH]=$CI_COMMIT_REF_NAME" https://git.pleroma.social/api/v4/projects/673/trigger/pipeline
  192. review_app:
  193. image: alpine:3.9
  194. stage: deploy
  195. before_script:
  196. - apk update && apk add openssh-client git
  197. when: manual
  198. environment:
  199. name: review/$CI_COMMIT_REF_NAME
  200. url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
  201. on_stop: stop_review_app
  202. only:
  203. - branches
  204. except:
  205. - master
  206. - develop
  207. script:
  208. - echo "$CI_ENVIRONMENT_SLUG"
  209. - mkdir -p ~/.ssh
  210. - eval $(ssh-agent -s)
  211. - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
  212. - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
  213. - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
  214. - (ssh -t dokku@pleroma.online -- git:set "$CI_ENVIRONMENT_SLUG" keep-git-dir true) || true
  215. - 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
  216. - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
  217. - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
  218. - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
  219. - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
  220. spec-deploy:
  221. stage: deploy
  222. artifacts:
  223. paths:
  224. - spec.json
  225. only:
  226. - develop@pleroma/pleroma
  227. image: alpine:latest
  228. before_script:
  229. - apk add curl
  230. script:
  231. - curl --fail-with-body -X POST -F"token=$CI_JOB_TOKEN" -F'ref=master' -F"variables[BRANCH]=$CI_COMMIT_REF_NAME" -F"variables[JOB_REF]=$CI_JOB_ID" https://git.pleroma.social/api/v4/projects/1130/trigger/pipeline
  232. stop_review_app:
  233. image: alpine:3.9
  234. stage: deploy
  235. before_script:
  236. - apk update && apk add openssh-client git
  237. when: manual
  238. environment:
  239. name: review/$CI_COMMIT_REF_NAME
  240. action: stop
  241. script:
  242. - echo "$CI_ENVIRONMENT_SLUG"
  243. - mkdir -p ~/.ssh
  244. - eval $(ssh-agent -s)
  245. - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
  246. - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
  247. - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
  248. - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
  249. amd64:
  250. stage: release
  251. image: elixir:$ELIXIR_VER
  252. only: &release-only
  253. - stable@pleroma/pleroma
  254. - develop@pleroma/pleroma
  255. - /^maint/.*$/@pleroma/pleroma
  256. - /^release/.*$/@pleroma/pleroma
  257. tags:
  258. - amd64
  259. artifacts: &release-artifacts
  260. name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
  261. paths:
  262. - release/*
  263. # Ideally it would be never for master branch and with the next commit for develop,
  264. # but Gitlab does not support neither `only` for artifacts
  265. # nor setting it to never from .gitlab-ci.yml
  266. # nor expiring with the next commit
  267. expire_in: 42 yrs
  268. cache: &release-cache
  269. key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
  270. paths:
  271. - deps
  272. variables: &release-variables
  273. MIX_ENV: prod
  274. VIX_COMPILATION_MODE: PLATFORM_PROVIDED_LIBVIPS
  275. before_script: &before-release
  276. - apt-get update && apt-get install -y cmake libmagic-dev libvips-dev erlang-dev
  277. - echo "import Config" > config/prod.secret.exs
  278. - mix local.hex --force
  279. - mix local.rebar --force
  280. script: &release
  281. - mix deps.get --only prod
  282. - mkdir release
  283. - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
  284. - mix release --path release
  285. amd64-musl:
  286. stage: release
  287. artifacts: *release-artifacts
  288. only: *release-only
  289. image: elixir:$ELIXIR_VER-alpine
  290. tags:
  291. - amd64
  292. cache: *release-cache
  293. variables: *release-variables
  294. before_script: &before-release-musl
  295. - apk add git build-base cmake file-dev openssl vips-dev
  296. - echo "import Config" > config/prod.secret.exs
  297. - mix local.hex --force
  298. - mix local.rebar --force
  299. script: *release
  300. arm:
  301. stage: release
  302. artifacts: *release-artifacts
  303. only: *release-only
  304. tags:
  305. - arm32-specified
  306. image: arm32v7/elixir:$ELIXIR_VER
  307. cache: *release-cache
  308. variables: *release-variables
  309. before_script: *before-release
  310. script: *release
  311. arm-musl:
  312. stage: release
  313. artifacts: *release-artifacts
  314. only: *release-only
  315. tags:
  316. - arm32-specified
  317. image: arm32v7/elixir:$ELIXIR_VER-alpine
  318. cache: *release-cache
  319. variables: *release-variables
  320. before_script: *before-release-musl
  321. script: *release
  322. arm64:
  323. stage: release
  324. artifacts: *release-artifacts
  325. only: *release-only
  326. tags:
  327. - arm
  328. image: arm64v8/elixir:$ELIXIR_VER
  329. cache: *release-cache
  330. variables: *release-variables
  331. before_script: *before-release
  332. script: *release
  333. arm64-musl:
  334. stage: release
  335. artifacts: *release-artifacts
  336. only: *release-only
  337. tags:
  338. - arm
  339. image: arm64v8/elixir:$ELIXIR_VER-alpine
  340. cache: *release-cache
  341. variables: *release-variables
  342. before_script: *before-release-musl
  343. script: *release
  344. .kaniko:
  345. stage: docker
  346. image:
  347. name: gcr.io/kaniko-project/executor:debug
  348. entrypoint: [""]
  349. cache: {}
  350. dependencies: []
  351. before_script: &before-kaniko
  352. - export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
  353. - export CI_VCS_REF=$CI_COMMIT_SHORT_SHA
  354. - export IMAGE_TAG=$CI_REGISTRY_IMAGE/$BUILD_ARCH_IMG_SUFFIX:$CI_COMMIT_SHORT_SHA
  355. - export IMAGE_TAG_SLUG=$CI_REGISTRY_IMAGE/$BUILD_ARCH_IMG_SUFFIX:$CI_COMMIT_REF_SLUG
  356. - export IMAGE_TAG_LATEST=$CI_REGISTRY_IMAGE/$BUILD_ARCH_IMG_SUFFIX:latest
  357. - export IMAGE_TAG_LATEST_STABLE=$CI_REGISTRY_IMAGE/$BUILD_ARCH_IMG_SUFFIX:latest-stable
  358. - mkdir -p /kaniko/.docker
  359. - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
  360. .kaniko-latest:
  361. extends: .kaniko
  362. only:
  363. - develop@pleroma/pleroma
  364. script:
  365. - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --custom-platform=$BUILD_ARCH --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP --build-arg ELIXIR_IMG=$ELIXIR_IMG --destination $IMAGE_TAG --destination $IMAGE_TAG_SLUG --destination $IMAGE_TAG_LATEST
  366. .kaniko-stable:
  367. extends: .kaniko
  368. only:
  369. - stable@pleroma/pleroma
  370. script:
  371. - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --custom-platform=$BUILD_ARCH --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP --build-arg ELIXIR_IMG=$ELIXIR_IMG --destination $IMAGE_TAG --destination $IMAGE_TAG_SLUG --destination $IMAGE_TAG_LATEST_STABLE
  372. .kaniko-release:
  373. extends: .kaniko
  374. only:
  375. - /^release/.*$/@pleroma/pleroma
  376. script:
  377. - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --custom-platform=$BUILD_ARCH --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP --build-arg ELIXIR_IMG=$ELIXIR_IMG --destination $IMAGE_TAG --destination $IMAGE_TAG_SLUG
  378. .kaniko-adhoc:
  379. extends: .kaniko
  380. only:
  381. - /^build-docker/.*$/@pleroma/pleroma
  382. script:
  383. - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --custom-platform=$BUILD_ARCH --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP --build-arg ELIXIR_IMG=$ELIXIR_IMG --destination $IMAGE_TAG --destination $IMAGE_TAG_SLUG
  384. .kaniko:linux/amd64:
  385. variables:
  386. BUILD_ARCH: linux/amd64
  387. BUILD_ARCH_IMG_SUFFIX: linux-amd64
  388. ELIXIR_IMG: hexpm/elixir
  389. tags:
  390. - amd64
  391. .kaniko:linux/arm64:
  392. variables:
  393. BUILD_ARCH: linux/arm64/v8
  394. BUILD_ARCH_IMG_SUFFIX: linux-arm64-v8
  395. ELIXIR_IMG: hexpm/elixir
  396. tags:
  397. - arm
  398. .kaniko:linux/arm:
  399. variables:
  400. BUILD_ARCH: linux/arm/v7
  401. BUILD_ARCH_IMG_SUFFIX: linux-arm-v7
  402. ELIXIR_IMG: git.pleroma.social:5050/pleroma/ci-image/elixir-linux-arm-v7
  403. tags:
  404. - arm32-specified
  405. kaniko-latest:linux/amd64:
  406. extends:
  407. - .kaniko-latest
  408. - .kaniko:linux/amd64
  409. kaniko-latest:linux/arm64:
  410. extends:
  411. - .kaniko-latest
  412. - .kaniko:linux/arm64
  413. kaniko-latest:linux/arm:
  414. extends:
  415. - .kaniko-latest
  416. - .kaniko:linux/arm
  417. kaniko-stable:linux/amd64:
  418. extends:
  419. - .kaniko-stable
  420. - .kaniko:linux/amd64
  421. kaniko-stable:linux/arm64:
  422. extends:
  423. - .kaniko-stable
  424. - .kaniko:linux/arm64
  425. kaniko-stable:linux/arm:
  426. extends:
  427. - .kaniko-stable
  428. - .kaniko:linux/arm
  429. kaniko-release:linux/amd64:
  430. extends:
  431. - .kaniko-release
  432. - .kaniko:linux/amd64
  433. kaniko-release:linux/arm64:
  434. extends:
  435. - .kaniko-release
  436. - .kaniko:linux/arm64
  437. kaniko-release:linux/arm:
  438. extends:
  439. - .kaniko-release
  440. - .kaniko:linux/arm
  441. .docker-combine:
  442. stage: docker-combine
  443. image: docker:cli
  444. cache: {}
  445. before_script:
  446. - 'BUILD_ARCHES="linux-amd64 linux-arm64-v8 linux-arm-v7"'
  447. - export IMAGE_TAG=$CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
  448. - export IMAGE_TAG_SLUG=$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
  449. - export IMAGE_TAG_LATEST=$CI_REGISTRY_IMAGE:latest
  450. - export IMAGE_TAG_LATEST_STABLE=$CI_REGISTRY_IMAGE:latest-stable
  451. - 'IMAGES=; for arch in $BUILD_ARCHES; do IMAGES="$IMAGES $CI_REGISTRY_IMAGE/$arch:$CI_COMMIT_SHORT_SHA"; done'
  452. - 'IMAGES_SLUG=; for arch in $BUILD_ARCHES; do IMAGES_SLUG="$IMAGES_SLUG $CI_REGISTRY_IMAGE/$arch:$CI_COMMIT_REF_SLUG"; done'
  453. - 'IMAGES_LATEST=; for arch in $BUILD_ARCHES; do IMAGES_LATEST="$IMAGES_LATEST $CI_REGISTRY_IMAGE/$arch:latest"; done'
  454. - 'IMAGES_LATEST_STABLE=; for arch in $BUILD_ARCHES; do IMAGES_LATEST_STABLE="$IMAGES_LATEST_STABLE $CI_REGISTRY_IMAGE/$arch:latest"; done'
  455. - mkdir -p ~/.docker
  456. - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > ~/.docker/config.json
  457. docker-combine:latest:
  458. extends: .docker-combine
  459. only:
  460. - develop@pleroma/pleroma
  461. script:
  462. - 'docker manifest create $IMAGE_TAG $IMAGES'
  463. - 'docker manifest push $IMAGE_TAG'
  464. - 'docker manifest create $IMAGE_TAG_SLUG $IMAGES_SLUG'
  465. - 'docker manifest push $IMAGE_TAG_SLUG'
  466. - 'docker manifest create $IMAGE_TAG_LATEST $IMAGES_LATEST'
  467. - 'docker manifest push $IMAGE_TAG_LATEST'
  468. docker-combine:stable:
  469. extends: .docker-combine
  470. only:
  471. - stable@pleroma/pleroma
  472. script:
  473. - 'docker manifest create $IMAGE_TAG $IMAGES'
  474. - 'docker manifest push $IMAGE_TAG'
  475. - 'docker manifest create $IMAGE_TAG_SLUG $IMAGES_SLUG'
  476. - 'docker manifest push $IMAGE_TAG_SLUG'
  477. - 'docker manifest create $IMAGE_TAG_LATEST_STABLE $IMAGES_LATEST_STABLE'
  478. - 'docker manifest push $IMAGE_TAG_LATEST_STABLE'
  479. docker-combine:release:
  480. extends: .docker-combine
  481. only:
  482. - /^release/.*$/@pleroma/pleroma
  483. script:
  484. - 'docker manifest create $IMAGE_TAG $IMAGES'
  485. - 'docker manifest push $IMAGE_TAG'
  486. - 'docker manifest create $IMAGE_TAG_SLUG $IMAGES_SLUG'
  487. - 'docker manifest push $IMAGE_TAG_SLUG'