cloudbuild.yaml 3.4 KB

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