.gitlab-ci.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. build:
  44. image: docker:20
  45. rules:
  46. # Run only on protected branches that are not tagged and not merge requests
  47. - if: '$CI_PIPELINE_SOURCE != "merge_request_event" && $CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG =~ "/^$/"'
  48. services:
  49. - docker:20-dind
  50. script:
  51. - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
  52. - docker build -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME//\//-} --build-arg IS_CI="True" .
  53. - docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME//\//-}
  54. rules:
  55. - if: $CI_PIPELINE_SOURCE != "schedule"
  56. buildx:
  57. image: docker:20-git
  58. variables:
  59. GIT_STRATEGY: none
  60. artifacts:
  61. paths:
  62. - buildx
  63. expire_in: 1 hour
  64. services:
  65. - docker:20-dind
  66. script:
  67. - export DOCKER_BUILDKIT=1
  68. - git clone https://github.com/docker/buildx.git ./docker-buildx
  69. - docker build --platform=local -o . ./docker-buildx
  70. rules:
  71. - if: $CI_PIPELINE_SOURCE =~ "schedule"
  72. when: never
  73. - if: $CI_COMMIT_TAG =~ /^v\d+.\d+.\d+/
  74. build_arm_x86:
  75. image: docker:20
  76. needs:
  77. - buildx
  78. services:
  79. - docker:20-dind
  80. before_script:
  81. - mkdir -p ~/.docker/cli-plugins
  82. - mv buildx ~/.docker/cli-plugins/docker-buildx
  83. - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
  84. script:
  85. - wget https://gitlab.com/api/v4/projects/15449363/jobs/artifacts/$CI_COMMIT_TAG/download?job=build-assets -O assets.zip
  86. - unzip assets.zip
  87. - rm assets.zip
  88. - mv dist/glitchtip-frontend/* dist/
  89. - rmdir dist/glitchtip-frontend/
  90. - VERSION=${CI_COMMIT_REF_NAME#*v}
  91. - echo "Build version $VERSION ci registry image $CI_REGISTRY_IMAGE commit ref $CI_COMMIT_REF_NAME"
  92. - docker login -u ${DOCKER_CI_REGISTRY_USER} -p ${DOCKER_CI_REGISTRY_PASSWORD}
  93. - docker buildx create --use
  94. - 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" .
  95. rules:
  96. - if: $CI_PIPELINE_SOURCE =~ "schedule"
  97. when: never
  98. - if: '$CI_COMMIT_TAG =~ /^v\d+.\d+.\d+/ && $CI_COMMIT_REF_PROTECTED == "true"'
  99. update_deps:
  100. image: renovate/renovate:latest
  101. variables:
  102. RENOVATE_PLATFORM: gitlab
  103. RENOVATE_ENDPOINT: https://gitlab.com/api/v4
  104. RENOVATE_TOKEN: $GITLAB_ACCESS_TOKEN
  105. RENOVATE_REPOSITORIES: glitchtip/glitchtip-backend
  106. rules:
  107. - if: $CI_PIPELINE_SOURCE == "schedule"
  108. script: renovate