.gitlab-ci.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. variables:
  2. PROJECT_NAME: glitchtip
  3. PIP_DISABLE_PIP_VERSION_CHECK: "on"
  4. POSTGRES_HOST_AUTH_METHOD: "trust"
  5. UV_VERSION: 0.4
  6. BASE_LAYER: bookworm
  7. UV_SYSTEM_PYTHON: "true"
  8. UV_PYTHON_DOWNLOADS: "never"
  9. UV_PROJECT_ENVIRONMENT: "/usr/local"
  10. UV_CACHE_DIR: ".uv-cache"
  11. DEBUG: "true"
  12. include:
  13. - template: SAST.gitlab-ci.yml
  14. - template: Dependency-Scanning.gitlab-ci.yml
  15. - template: Secret-Detection.gitlab-ci.yml
  16. workflow:
  17. rules:
  18. - when: always
  19. test:
  20. image: ghcr.io/astral-sh/uv:$UV_VERSION-python$PYTHON_VERSION-$BASE_LAYER
  21. variables:
  22. SECRET_KEY: testing
  23. ENABLE_TEST_API: "true"
  24. ENABLE_OPEN_USER_REGISTRATION: "true"
  25. services:
  26. - postgres:$POSTGRES_VERSION
  27. cache:
  28. - key: ${CI_COMMIT_REF_SLUG}${VERSION}
  29. files:
  30. - uv.lock
  31. paths:
  32. - $UV_CACHE_DIR
  33. cache:
  34. paths:
  35. - .cache/pip
  36. script:
  37. - uv sync --frozen --no-install-project
  38. - uv run ./manage.py test
  39. - uv cache prune --ci
  40. rules:
  41. - if: $CI_PIPELINE_SOURCE != "schedule"
  42. parallel:
  43. matrix:
  44. - PYTHON_VERSION: '3.11'
  45. POSTGRES_VERSION: '13'
  46. - PYTHON_VERSION: '3.12'
  47. POSTGRES_VERSION: '16'
  48. lint:
  49. image: python:3.13-slim
  50. script:
  51. - pip install ruff
  52. - ruff check glitchtip/ apps/
  53. rules:
  54. - if: $CI_PIPELINE_SOURCE != "schedule"
  55. build:
  56. image: docker:27
  57. rules:
  58. # Run only on protected branches that are not tagged and not merge requests
  59. - if: '$CI_PIPELINE_SOURCE != "merge_request_event" && $CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG =~ "/^$/"'
  60. services:
  61. - docker:27-dind
  62. script:
  63. - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN registry.gitlab.com
  64. - docker build -t ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME//\//-} --build-arg IS_CI="True" .
  65. - docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_NAME//\//-}
  66. rules:
  67. - if: $CI_PIPELINE_SOURCE != "schedule"
  68. buildx:
  69. image: docker:25-git
  70. variables:
  71. GIT_STRATEGY: none
  72. artifacts:
  73. paths:
  74. - buildx
  75. expire_in: 1 hour
  76. services:
  77. - docker:27-dind
  78. script:
  79. - export DOCKER_BUILDKIT=1
  80. - git clone https://github.com/docker/buildx.git ./docker-buildx
  81. - docker build --platform=local -o . ./docker-buildx
  82. rules:
  83. - if: $CI_PIPELINE_SOURCE =~ "schedule"
  84. when: never
  85. - if: $CI_COMMIT_TAG =~ /^v\d+.\d+.\d+/
  86. build_arm_x86:
  87. image: docker:27
  88. needs:
  89. - buildx
  90. services:
  91. - docker:27-dind
  92. before_script:
  93. - mkdir -p ~/.docker/cli-plugins
  94. - mv buildx ~/.docker/cli-plugins/docker-buildx
  95. - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
  96. script:
  97. - wget https://gitlab.com/api/v4/projects/15449363/jobs/artifacts/$CI_COMMIT_TAG/download?job=build-assets -O assets.zip
  98. - unzip assets.zip
  99. - rm assets.zip
  100. - mv dist/glitchtip-frontend/* dist/
  101. - rmdir dist/glitchtip-frontend/
  102. - VERSION=${CI_COMMIT_REF_NAME#*v}
  103. - MINOR_VERSION=$(echo "$CI_COMMIT_REF_NAME" | sed 's/\.[^.]*$//')
  104. - echo "Build version $VERSION ci registry image $CI_REGISTRY_IMAGE commit ref $CI_COMMIT_REF_NAME"
  105. - docker login -u ${DOCKER_CI_REGISTRY_USER} -p ${DOCKER_CI_REGISTRY_PASSWORD}
  106. - docker buildx create --use
  107. - 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" .
  108. rules:
  109. - if: $CI_PIPELINE_SOURCE =~ "schedule"
  110. when: never
  111. - if: '$CI_COMMIT_TAG =~ /^v\d+.\d+.\d+/ && $CI_COMMIT_REF_PROTECTED == "true"'
  112. update_deps:
  113. image: renovate/renovate:39
  114. variables:
  115. RENOVATE_PLATFORM: gitlab
  116. RENOVATE_ENDPOINT: https://gitlab.com/api/v4
  117. RENOVATE_TOKEN: $GITLAB_ACCESS_TOKEN
  118. RENOVATE_REPOSITORIES: glitchtip/glitchtip-backend
  119. rules:
  120. - if: $CI_PIPELINE_SOURCE == "schedule"
  121. script: renovate