github.com/google/trillian-examples@v0.0.0-20240520080811-0d40d35cef0e/cloudbuild.yaml (about) 1 timeout: 1200s 2 options: 3 machineType: E2_HIGHCPU_32 4 volumes: 5 - name: go-modules 6 path: /go 7 env: 8 - GOPROXY=https://proxy.golang.org 9 - PROJECT_ROOT=github.com/google/trillian-examples 10 - GOPATH=/go 11 - GOLANG_PROTOBUF_REGISTRATION_CONFLICT=ignore # Temporary work-around v1.proto already registered error. 12 13 # Cloud Build logs sent to GCS bucket 14 logsBucket: 'gs://trillian-cloudbuild-logs' 15 16 steps: 17 # First build a "testbase" docker image which contains most of the tools we need for the later steps: 18 - name: 'gcr.io/cloud-builders/docker' 19 entrypoint: 'bash' 20 args: ['-c', 'docker pull gcr.io/$PROJECT_ID/testbase:latest || exit 0'] 21 - name: 'gcr.io/cloud-builders/docker' 22 args: [ 23 'build', 24 '-t', 'gcr.io/$PROJECT_ID/testbase:latest', 25 '--cache-from', 'gcr.io/$PROJECT_ID/testbase:latest', 26 '-f', './integration/Dockerfile', 27 '.' 28 ] 29 30 # prepare spins up an ephemeral trillian instance for testing use. 31 - name: gcr.io/$PROJECT_ID/testbase 32 entrypoint: 'bash' 33 id: 'prepare' 34 args: 35 - '-exc' 36 - | 37 # googleapis is not Go code, but it's required for .pb.go regeneration because of API dependencies. 38 git clone --depth=1 https://github.com/googleapis/googleapis.git "$$GOPATH/src/github.com/googleapis/googleapis" 39 40 # Use latest versions of Trillian docker images built by the Trillian CI cloudbuilders. 41 docker pull gcr.io/$PROJECT_ID/log_server:latest 42 docker tag gcr.io/$PROJECT_ID/log_server:latest deployment_trillian-log-server 43 docker pull gcr.io/$PROJECT_ID/log_signer:latest 44 docker tag gcr.io/$PROJECT_ID/log_signer:latest deployment_trillian-log-signer 45 46 # Bring up an ephemeral trillian instance using the docker-compose config in the Trillian repo: 47 export TRILLIAN_PATH="$(go list -f '{{.Dir}}' github.com/google/trillian)" 48 49 # We need to fix up Trillian's docker-compose to connect to the CloudBuild network to that tests can use it: 50 echo -e "networks:\n default:\n external:\n name: cloudbuild" >> $${TRILLIAN_PATH}/examples/deployment/docker-compose.yml 51 52 docker-compose -f $${TRILLIAN_PATH}/examples/deployment/docker-compose.yml pull mysql trillian-log-server trillian-log-signer 53 docker-compose -f $${TRILLIAN_PATH}/examples/deployment/docker-compose.yml up -d mysql trillian-log-server trillian-log-signer 54 55 # Install proto related bits 56 - name: gcr.io/$PROJECT_ID/testbase 57 id: 'go-get-proto' 58 args: ['go', 'get', 'github.com/golang/protobuf/proto'] 59 waitFor: ['prepare'] 60 - name: gcr.io/$PROJECT_ID/testbase 61 id: 'go-get-proto-gen' 62 args: ['go', 'get', 'github.com/golang/protobuf/protoc-gen-go'] 63 waitFor: ['prepare'] 64 65 # Run the presubmit build, generate, and test with coverage enabled. 66 - name: gcr.io/$PROJECT_ID/testbase 67 entrypoint: 'bash' 68 id: 'presubmit-build-and-test-with-coverage' 69 args: 70 - '-exc' 71 - | 72 ./scripts/presubmit.sh --cloud-build --coverage --no-linters --no-actions --no-docker 73 # Check re-generation didn't change anything. 74 echo "Checking that generated files are the same as checked-in versions." 75 git diff -- --exit-code 76 waitFor: ['go-get-proto', 'go-get-proto-gen'] 77 78 # Run the presubmit linters 79 - name: gcr.io/$PROJECT_ID/testbase 80 entrypoint: 'bash' 81 id: 'presubmit-lint' 82 args: 83 - '-exc' 84 - | 85 ./scripts/presubmit.sh --cloud-build --no-build --no-generate --no-actions --no-docker 86 waitFor: ['go-get-proto', 'go-get-proto-gen'] 87 88 # Build serverless actions 89 - name: gcr.io/$PROJECT_ID/testbase 90 entrypoint: 'bash' 91 id: 'presubmit-build-actions' 92 args: 93 - '-exc' 94 - | 95 ./scripts/presubmit.sh --cloud-build --no-build --no-linters --no-generate --no-docker 96 waitFor: ['go-get-proto', 'go-get-proto-gen'] 97 98 # Build docker images 99 - name: gcr.io/$PROJECT_ID/testbase 100 entrypoint: 'bash' 101 id: 'presubmit-build-docker' 102 args: 103 - '-exc' 104 - | 105 ./scripts/presubmit.sh --cloud-build --no-build --no-linters --no-generate --no-actions 106 waitFor: ['go-get-proto', 'go-get-proto-gen'] 107 108 # Test the USB Armory code as best we can 109 - name: gcr.io/$PROJECT_ID/testbase 110 id: 'usbarmory' 111 entrypoint: 'bash' 112 args: ['-exc', './binary_transparency/firmware/integration/ft_usbarmory_test.sh'] 113 waitFor: ['go-get-proto', 'go-get-proto-gen'] 114 115 # Run the FT integration test 116 - name: gcr.io/$PROJECT_ID/testbase 117 entrypoint: 'bash' 118 id: 'firmware-integration-test' 119 args: 120 - '-exc' 121 - | 122 export PATH=/bin:/usr/bin:/workspace/bin:/go/protoc/bin:/usr/local/go/bin 123 export TRILLIAN_LOG_RPC="deployment_trillian-log-server_1:8090" 124 ./binary_transparency/firmware/integration/ft_test.sh --coverage 125 waitFor: ['go-get-proto', 'go-get-proto-gen'] 126 127 # Run the helloworld integration test 128 - name: gcr.io/$PROJECT_ID/testbase 129 entrypoint: 'bash' 130 id: 'helloworld-integration-test' 131 args: 132 - '-exc' 133 - | 134 export PATH=/bin:/usr/bin:/workspace/bin:/go/protoc/bin:/usr/local/go/bin 135 export TRILLIAN_LOG_RPC="deployment_trillian-log-server_1:8090" 136 ./helloworld/hw_integration.sh --coverage 137 waitFor: ['go-get-proto', 'go-get-proto-gen'] 138 139 # Submit coverage results 140 - name: 'gcr.io/cloud-builders/curl' 141 entrypoint: bash 142 args: ['-c', 'bash <(curl -s https://codecov.io/bash)'] 143 env: 144 - 'VCS_COMMIT_ID=$COMMIT_SHA' 145 - 'VCS_BRANCH_NAME=$BRANCH_NAME' 146 - 'VCS_PULL_REQUEST=$_PR_NUMBER' 147 - 'CI_BUILD_ID=$BUILD_ID' 148 - 'CODECOV_TOKEN=$_CODECOV_TOKEN' # _CODECOV_TOKEN is specified in the cloud build trigger 149 waitFor: ['presubmit-build-and-test-with-coverage', 'firmware-integration-test'] 150 151 images: 152 - 'gcr.io/$PROJECT_ID/testbase:latest'