cloudbuild.yaml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. waitFor: ['-']
  38. entrypoint: 'bash'
  39. args:
  40. - '-e'
  41. - '-c'
  42. - |
  43. mkdir self-hosted && cd self-hosted
  44. curl -L "https://github.com/getsentry/self-hosted/archive/master.tar.gz" | tar xzf - --strip-components=1
  45. echo '{"version": "3.4", "networks":{"default":{"external":{"name":"cloudbuild"}}}}' > docker-compose.override.yml
  46. - name: 'gcr.io/$PROJECT_ID/docker-compose'
  47. id: e2e-test
  48. waitFor:
  49. - runtime-image
  50. - get-self-hosted-repo
  51. entrypoint: 'bash'
  52. dir: self-hosted
  53. args:
  54. - '-e'
  55. - '-c'
  56. - |
  57. ./install.sh
  58. set +e
  59. ./test.sh
  60. test_return=$?
  61. set -e
  62. if [[ $test_return -ne 0 ]]; then
  63. echo "Test failed.";
  64. docker-compose ps;
  65. docker-compose logs;
  66. exit $test_return;
  67. fi
  68. timeout: 600s
  69. - name: 'gcr.io/cloud-builders/docker'
  70. id: docker-push
  71. waitFor:
  72. - e2e-test
  73. secretEnv: ['DOCKER_PASSWORD']
  74. entrypoint: 'bash'
  75. args:
  76. - '-e'
  77. - '-c'
  78. - |
  79. # Only push to Docker Hub from master
  80. [ "$BRANCH_NAME" != "master" ] && exit 0
  81. # Need to pull the image first due to Kaniko
  82. docker pull $$SENTRY_IMAGE
  83. echo "$$DOCKER_PASSWORD" | docker login --username=sentrybuilder --password-stdin
  84. docker tag $$SENTRY_IMAGE $$DOCKER_REPO:$SHORT_SHA
  85. docker push $$DOCKER_REPO:$SHORT_SHA
  86. docker tag $$SENTRY_IMAGE $$DOCKER_REPO:$COMMIT_SHA
  87. docker push $$DOCKER_REPO:$COMMIT_SHA
  88. docker tag $$SENTRY_IMAGE $$DOCKER_REPO:nightly
  89. docker push $$DOCKER_REPO:nightly
  90. timeout: 2640s
  91. artifacts:
  92. objects:
  93. location: 'gs://sentryio-cloudbuild-opensource/getsentry/sentry/$COMMIT_SHA/'
  94. paths: ['dist/*.whl']
  95. options:
  96. # We need more memory for Webpack builds & e2e self-hosted tests
  97. machineType: 'E2_HIGHCPU_8'
  98. env:
  99. - 'CI=1'
  100. - 'SENTRY_IMAGE=us.gcr.io/$PROJECT_ID/sentry:$COMMIT_SHA'
  101. - 'DOCKER_REPO=getsentry/sentry'
  102. - 'SENTRY_TEST_HOST=http://nginx'
  103. secrets:
  104. - kmsKeyName: projects/sentryio/locations/global/keyRings/service-credentials/cryptoKeys/cloudbuild
  105. secretEnv:
  106. # This is a personal access token for the sentrybuilder account, encrypted using the
  107. # short guide at http://bit.ly/2Pg6uw9
  108. DOCKER_PASSWORD: |
  109. CiQAE8gN7y3OMxn+a1kofmK4Bi8jQZtdRFj2lYYwaZHVeIIBUzMSTQA9tvn8XCv2vqj6u8CHoeSP
  110. TVW9pLvSCorKoeNtOp0eb+6V1yNJW/+JC07DNO1KLbTbodbuza6jKJHU5xeAJ4kGQI78UY5Vu1Gp
  111. QcMK