.gitlab-ci.yml 3.8 KB

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