cloudbuild.yaml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. steps:
  2. - name: 'gcr.io/kaniko-project/executor:v1.5.1'
  3. id: builder-image
  4. args:
  5. [
  6. '--cache=true',
  7. '--use-new-run',
  8. '--build-arg',
  9. 'SOURCE_COMMIT=$COMMIT_SHA',
  10. '--destination=us.gcr.io/$PROJECT_ID/sentry-builder:$COMMIT_SHA',
  11. '-f',
  12. './docker/builder.dockerfile',
  13. ]
  14. timeout: 180s
  15. - name: 'us.gcr.io/$PROJECT_ID/sentry-builder:$COMMIT_SHA'
  16. id: builder-run
  17. env:
  18. - 'SOURCE_COMMIT=$COMMIT_SHA'
  19. timeout: 600s
  20. - name: 'gcr.io/kaniko-project/executor:v1.5.1'
  21. id: runtime-image
  22. waitFor:
  23. - builder-run
  24. args:
  25. [
  26. '--cache=true',
  27. '--use-new-run',
  28. '--build-arg',
  29. 'SOURCE_COMMIT=$COMMIT_SHA',
  30. '--destination=us.gcr.io/$PROJECT_ID/sentry:$COMMIT_SHA',
  31. '-f',
  32. './docker/Dockerfile',
  33. ]
  34. timeout: 300s
  35. - name: 'gcr.io/$PROJECT_ID/docker-compose'
  36. id: get-self-hosted-repo
  37. env:
  38. - 'REPORT_SELF_HOSTED_ISSUES=0'
  39. waitFor: ['-']
  40. entrypoint: 'bash'
  41. args:
  42. - '-e'
  43. - '-c'
  44. - |
  45. mkdir self-hosted && cd self-hosted
  46. curl -L "https://github.com/getsentry/self-hosted/archive/master.tar.gz" | tar xzf - --strip-components=1
  47. echo '{"version": "3.4", "networks":{"default":{"external":{"name":"cloudbuild"}}}}' > docker-compose.override.yml
  48. - name: 'gcr.io/$PROJECT_ID/docker-compose'
  49. id: e2e-test
  50. waitFor:
  51. - runtime-image
  52. - get-self-hosted-repo
  53. entrypoint: 'bash'
  54. dir: self-hosted
  55. args:
  56. - '-e'
  57. - '-c'
  58. - |
  59. ./install.sh
  60. set +e
  61. ./test.sh
  62. test_return=$?
  63. set -e
  64. if [[ $test_return -ne 0 ]]; then
  65. echo "Test failed.";
  66. docker-compose ps;
  67. docker-compose logs;
  68. exit $test_return;
  69. fi
  70. timeout: 900s
  71. - name: 'gcr.io/cloud-builders/docker'
  72. id: docker-push
  73. waitFor:
  74. - e2e-test
  75. secretEnv: ['DOCKER_PASSWORD']
  76. entrypoint: 'bash'
  77. args:
  78. - '-e'
  79. - '-c'
  80. - |
  81. # Only push to Docker Hub from master
  82. [ "$BRANCH_NAME" != "master" ] && exit 0
  83. # Need to pull the image first due to Kaniko
  84. docker pull $$SENTRY_IMAGE
  85. echo "$$DOCKER_PASSWORD" | docker login --username=sentrybuilder --password-stdin
  86. docker tag $$SENTRY_IMAGE $$DOCKER_REPO:$SHORT_SHA
  87. docker push $$DOCKER_REPO:$SHORT_SHA
  88. docker tag $$SENTRY_IMAGE $$DOCKER_REPO:$COMMIT_SHA
  89. docker push $$DOCKER_REPO:$COMMIT_SHA
  90. docker tag $$SENTRY_IMAGE $$DOCKER_REPO:nightly
  91. docker push $$DOCKER_REPO:nightly
  92. timeout: 2640s
  93. artifacts:
  94. objects:
  95. location: 'gs://sentryio-cloudbuild-opensource/getsentry/sentry/$COMMIT_SHA/'
  96. paths: ['dist/*.whl']
  97. options:
  98. # We need more memory for Webpack builds & e2e self-hosted tests
  99. machineType: 'E2_HIGHCPU_8'
  100. env:
  101. - 'CI=1'
  102. - 'SENTRY_IMAGE=us.gcr.io/$PROJECT_ID/sentry:$COMMIT_SHA'
  103. - 'DOCKER_REPO=getsentry/sentry'
  104. - 'SENTRY_TEST_HOST=http://nginx'
  105. secrets:
  106. - kmsKeyName: projects/sentryio/locations/global/keyRings/service-credentials/cryptoKeys/cloudbuild
  107. secretEnv:
  108. # This is a personal access token for the sentrybuilder account, encrypted using the
  109. # short guide at http://bit.ly/2Pg6uw9
  110. DOCKER_PASSWORD: |
  111. CiQAE8gN7y3OMxn+a1kofmK4Bi8jQZtdRFj2lYYwaZHVeIIBUzMSTQA9tvn8XCv2vqj6u8CHoeSP
  112. TVW9pLvSCorKoeNtOp0eb+6V1yNJW/+JC07DNO1KLbTbodbuza6jKJHU5xeAJ4kGQI78UY5Vu1Gp
  113. QcMK