.gitlab-ci.yml 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. variables:
  2. PROJECT_NAME: glitchtip
  3. IMAGE_NAME: registry.gitlab.com/glitchtip/glitchtip-backend
  4. CONTAINER_TEST_IMAGE: registry.gitlab.com/glitchtip/glitchtip-backend:$CI_BUILD_REF_NAME
  5. PIP_DISABLE_PIP_VERSION_CHECK: "on"
  6. PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
  7. POETRY_VIRTUALENVS_CREATE: "false"
  8. POETRY_HOME: "/opt/poetry"
  9. POSTGRES_HOST_AUTH_METHOD: "trust"
  10. DEBUG: "true"
  11. include:
  12. - template: SAST.gitlab-ci.yml
  13. - template: Dependency-Scanning.gitlab-ci.yml
  14. - template: Secret-Detection.gitlab-ci.yml
  15. workflow:
  16. rules:
  17. - when: always
  18. test:
  19. image: python:3.10
  20. variables:
  21. SECRET_KEY: testing
  22. ENABLE_TEST_API: "true"
  23. ENABLE_OPEN_USER_REGISTRATION: "true"
  24. services:
  25. - postgres:14
  26. cache:
  27. key: ${CI_COMMIT_REF_SLUG}
  28. paths:
  29. - .cache/pip
  30. script:
  31. - curl -sSL https://install.python-poetry.org | python3 -
  32. - $POETRY_HOME/bin/poetry install --no-interaction --no-ansi
  33. - ./manage.py test
  34. lint:
  35. image: python:3.10
  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. build:
  42. image: docker:20
  43. rules:
  44. # Run only on protected branches that are not tagged and not merge requests
  45. - if: '$CI_PIPELINE_SOURCE != "merge_request_event" && $CI_COMMIT_REF_PROTECTED == "true" && $CI_COMMIT_TAG =~ "/^$/"'
  46. services:
  47. - docker:20-dind
  48. script:
  49. - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
  50. - docker build -t $CONTAINER_TEST_IMAGE --build-arg IS_CI="True" .
  51. - docker push $CONTAINER_TEST_IMAGE
  52. buildx:
  53. image: docker:20-git
  54. rules:
  55. - if: $CI_COMMIT_TAG =~ /^v\d+.\d+.\d+/
  56. variables:
  57. GIT_STRATEGY: none
  58. artifacts:
  59. paths:
  60. - buildx
  61. expire_in: 1 hour
  62. services:
  63. - docker:20-dind
  64. script:
  65. - export DOCKER_BUILDKIT=1
  66. - git clone https://github.com/docker/buildx.git ./docker-buildx
  67. - docker build --platform=local -o . ./docker-buildx
  68. build_arm_x86:
  69. image: docker:20
  70. rules:
  71. - if: '$CI_COMMIT_TAG =~ /^v\d+.\d+.\d+/ && $CI_COMMIT_REF_PROTECTED == "true"'
  72. needs:
  73. - buildx
  74. services:
  75. - docker:20-dind
  76. before_script:
  77. - mkdir -p ~/.docker/cli-plugins
  78. - mv buildx ~/.docker/cli-plugins/docker-buildx
  79. - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
  80. script:
  81. - wget https://gitlab.com/api/v4/projects/15449363/jobs/artifacts/$CI_COMMIT_TAG/download?job=build-assets -O assets.zip
  82. - unzip assets.zip
  83. - rm assets.zip
  84. - mv dist/glitchtip-frontend/* dist/
  85. - rmdir dist/glitchtip-frontend/
  86. - VERSION=${CI_COMMIT_REF_NAME#*v}
  87. - echo "Build version $VERSION ci registry image $CI_REGISTRY_IMAGE commit ref $CI_COMMIT_REF_NAME"
  88. - docker login -u ${DOCKER_CI_REGISTRY_USER} -p ${DOCKER_CI_REGISTRY_PASSWORD}
  89. - docker buildx create --use
  90. - 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" .