.gitlab-ci.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. variables:
  2. PROJECT_NAME: glitchtip
  3. PIP_DISABLE_PIP_VERSION_CHECK: "on"
  4. PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
  5. POETRY_VIRTUALENVS_CREATE: "false"
  6. POETRY_HOME: "/opt/poetry"
  7. POSTGRES_HOST_AUTH_METHOD: "trust"
  8. DEBUG: "true"
  9. include:
  10. - template: SAST.gitlab-ci.yml
  11. - template: Dependency-Scanning.gitlab-ci.yml
  12. - template: Secret-Detection.gitlab-ci.yml
  13. workflow:
  14. rules:
  15. - when: always
  16. test:
  17. image: python:3.11
  18. variables:
  19. SECRET_KEY: testing
  20. ENABLE_TEST_API: "true"
  21. ENABLE_OPEN_USER_REGISTRATION: "true"
  22. services:
  23. - postgres:15
  24. cache:
  25. key: ${CI_COMMIT_REF_SLUG}
  26. paths:
  27. - .cache/pip
  28. script:
  29. - curl -sSL https://install.python-poetry.org | python3 -
  30. - $POETRY_HOME/bin/poetry install --no-interaction --no-ansi
  31. - ./manage.py test
  32. rules:
  33. - if: $CI_PIPELINE_SOURCE != "schedule"
  34. lint:
  35. image: python:3.11
  36. script:
  37. - curl -sSL https://install.python-poetry.org | python3 -
  38. - $POETRY_HOME/bin/poetry install --no-interaction --no-ansi
  39. # - isort --check glitchtip not compatible with black :(
  40. # - pylint --load-plugins=pylint_django --django-settings-module=glitchtip.settings --disable=R glitchtip
  41. rules:
  42. - if: $CI_PIPELINE_SOURCE != "schedule"
  43. test_dind:
  44. image: docker:20
  45. variables:
  46. DOCKER_HOST: "tcp://docker:2375"
  47. DOCKER_TLS_CERTDIR: ""
  48. tags:
  49. - funkwhale
  50. services:
  51. - docker:20-dind
  52. script:
  53. - docker info
  54. rules:
  55. - if: $CI_PIPELINE_SOURCE != "schedule"
  56. build:
  57. image: docker:20
  58. rules:
  59. # Run only on protected branches that are not tagged and not merge requests
  60. - if: '$CI_PIPELINE_SOURCE != "merge_request_event" && $CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG =~ "/^$/"'
  61. services:
  62. - docker:20-dind
  63. script:
  64. - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
  65. - docker build -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME//\//-} --build-arg IS_CI="True" .
  66. - docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME//\//-}
  67. rules:
  68. - if: $CI_PIPELINE_SOURCE != "schedule"
  69. buildx:
  70. image: docker:20-git
  71. variables:
  72. GIT_STRATEGY: none
  73. artifacts:
  74. paths:
  75. - buildx
  76. expire_in: 1 hour
  77. services:
  78. - docker:20-dind
  79. script:
  80. - export DOCKER_BUILDKIT=1
  81. - git clone https://github.com/docker/buildx.git ./docker-buildx
  82. - docker build --platform=local -o . ./docker-buildx
  83. rules:
  84. - if: $CI_PIPELINE_SOURCE =~ "schedule"
  85. when: never
  86. - if: $CI_COMMIT_TAG =~ /^v\d+.\d+.\d+/
  87. build_arm_x86:
  88. image: docker:20
  89. needs:
  90. - buildx
  91. variables:
  92. DOCKER_HOST: "tcp://docker:2375"
  93. tags:
  94. - funkwhale
  95. services:
  96. - docker:20-dind
  97. before_script:
  98. - mkdir -p ~/.docker/cli-plugins
  99. - mv buildx ~/.docker/cli-plugins/docker-buildx
  100. - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
  101. script:
  102. - wget https://gitlab.com/api/v4/projects/15449363/jobs/artifacts/$CI_COMMIT_TAG/download?job=build-assets -O assets.zip
  103. - unzip assets.zip
  104. - rm assets.zip
  105. - mv dist/glitchtip-frontend/* dist/
  106. - rmdir dist/glitchtip-frontend/
  107. - VERSION=${CI_COMMIT_REF_NAME#*v}
  108. - echo "Build version $VERSION ci registry image $CI_REGISTRY_IMAGE commit ref $CI_COMMIT_REF_NAME"
  109. - docker login -u ${DOCKER_CI_REGISTRY_USER} -p ${DOCKER_CI_REGISTRY_PASSWORD}
  110. - docker buildx create --use
  111. - docker buildx build --platform linux/arm64/v8,linux/amd64 --push -t ${DOCKER_CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME} -t ${DOCKER_CI_REGISTRY_IMAGE}:latest --build-arg IS_CI="True" --build-arg GLITCHTIP_VERSION=$VERSION --build-arg COLLECT_STATIC="True" .
  112. rules:
  113. - if: $CI_PIPELINE_SOURCE =~ "schedule"
  114. when: never
  115. - if: '$CI_COMMIT_TAG =~ /^v\d+.\d+.\d+/ && $CI_COMMIT_REF_PROTECTED == "true"'
  116. update_deps:
  117. image: renovate/renovate:latest
  118. variables:
  119. RENOVATE_PLATFORM: gitlab
  120. RENOVATE_ENDPOINT: https://gitlab.com/api/v4
  121. RENOVATE_TOKEN: $GITLAB_ACCESS_TOKEN
  122. RENOVATE_REPOSITORIES: glitchtip/glitchtip-backend
  123. rules:
  124. - if: $CI_PIPELINE_SOURCE == "schedule"
  125. script: renovate