.gitlab-ci.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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:$VERSION
  18. variables:
  19. SECRET_KEY: testing
  20. ENABLE_TEST_API: "true"
  21. ENABLE_OPEN_USER_REGISTRATION: "true"
  22. services:
  23. - postgres:16
  24. cache:
  25. key: ${CI_COMMIT_REF_SLUG}${VERSION}
  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. parallel:
  35. matrix:
  36. - VERSION: ['3.11', '3.12']
  37. lint:
  38. image: python:3.12
  39. script:
  40. - curl -sSL https://install.python-poetry.org | python3 -
  41. - $POETRY_HOME/bin/poetry install --no-interaction --no-ansi
  42. - ruff check glitchtip/ apps/
  43. rules:
  44. - if: $CI_PIPELINE_SOURCE != "schedule"
  45. build:
  46. image: docker:27
  47. rules:
  48. # Run only on protected branches that are not tagged and not merge requests
  49. - if: '$CI_PIPELINE_SOURCE != "merge_request_event" && $CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG =~ "/^$/"'
  50. services:
  51. - docker:27-dind
  52. script:
  53. - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
  54. - docker build -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME//\//-} --build-arg IS_CI="True" .
  55. - docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME//\//-}
  56. rules:
  57. - if: $CI_PIPELINE_SOURCE != "schedule"
  58. buildx:
  59. image: docker:25-git
  60. variables:
  61. GIT_STRATEGY: none
  62. artifacts:
  63. paths:
  64. - buildx
  65. expire_in: 1 hour
  66. services:
  67. - docker:27-dind
  68. script:
  69. - export DOCKER_BUILDKIT=1
  70. - git clone https://github.com/docker/buildx.git ./docker-buildx
  71. - docker build --platform=local -o . ./docker-buildx
  72. rules:
  73. - if: $CI_PIPELINE_SOURCE =~ "schedule"
  74. when: never
  75. - if: $CI_COMMIT_TAG =~ /^v\d+.\d+.\d+/
  76. build_arm_x86:
  77. image: docker:27
  78. needs:
  79. - buildx
  80. services:
  81. - docker:27-dind
  82. before_script:
  83. - mkdir -p ~/.docker/cli-plugins
  84. - mv buildx ~/.docker/cli-plugins/docker-buildx
  85. - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
  86. script:
  87. - wget https://gitlab.com/api/v4/projects/15449363/jobs/artifacts/$CI_COMMIT_TAG/download?job=build-assets -O assets.zip
  88. - unzip assets.zip
  89. - rm assets.zip
  90. - mv dist/glitchtip-frontend/* dist/
  91. - rmdir dist/glitchtip-frontend/
  92. - VERSION=${CI_COMMIT_REF_NAME#*v}
  93. - MINOR_VERSION=$(echo "$CI_COMMIT_REF_NAME" | sed 's/\.[^.]*$//')
  94. - echo "Build version $VERSION ci registry image $CI_REGISTRY_IMAGE commit ref $CI_COMMIT_REF_NAME"
  95. - docker login -u ${DOCKER_CI_REGISTRY_USER} -p ${DOCKER_CI_REGISTRY_PASSWORD}
  96. - docker buildx create --use
  97. - docker buildx build --platform linux/arm64/v8,linux/amd64 --push -t ${DOCKER_CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME} -t ${DOCKER_CI_REGISTRY_IMAGE}:${MINOR_VERSION} -t ${DOCKER_CI_REGISTRY_IMAGE}:latest --build-arg IS_CI="True" --build-arg GLITCHTIP_VERSION=$VERSION --build-arg COLLECT_STATIC="True" .
  98. rules:
  99. - if: $CI_PIPELINE_SOURCE =~ "schedule"
  100. when: never
  101. - if: '$CI_COMMIT_TAG =~ /^v\d+.\d+.\d+/ && $CI_COMMIT_REF_PROTECTED == "true"'
  102. update_deps:
  103. image: renovate/renovate:38
  104. variables:
  105. RENOVATE_PLATFORM: gitlab
  106. RENOVATE_ENDPOINT: https://gitlab.com/api/v4
  107. RENOVATE_TOKEN: $GITLAB_ACCESS_TOKEN
  108. RENOVATE_REPOSITORIES: glitchtip/glitchtip-backend
  109. rules:
  110. - if: $CI_PIPELINE_SOURCE == "schedule"
  111. script: renovate