featurebase/.cloudbuild/cloudbuild.yml
Fletcher Haynes 155855d97f Added in various CI files
This adds in configs for Cloud Build, Artifactory, and GitLab CI/CD.
2021-10-08 12:16:03 -07:00

202 lines
5.1 KiB
YAML

steps:
- name: gcr.io/cloud-builders/yarn
args:
- install
dir: lattice/
id: Install Lattice
waitFor:
- '-'
- name: gcr.io/cloud-builders/yarn
args:
- build
dir: lattice/
id: Build Lattice
waitFor:
- Install Lattice
- name: 'us.gcr.io/featurebase-pipeline-dev/featurebase:0.3'
args:
- tar
- '-c'
- '-z'
- '-v'
- '-f'
- lattice.tar.gz
- lattice/build
id: Package Lattice Build
waitFor:
- Build Lattice
- name: 'us.gcr.io/featurebase-pipeline-dev/featurebase:0.3'
args:
- mv
- lattice.tar.gz
- /cache/
waitFor:
- Package Lattice Build
- name: 'us.gcr.io/featurebase-pipeline-dev/featurebase:0.3'
args:
- go
- test
- '-covermode=atomic'
- '-coverprofile=/cache/coverage.out'
id: Generate code coverage report
waitFor:
- '-'
- name: 'us.gcr.io/featurebase-pipeline-dev/featurebase:0.3'
args:
- '-c'
- |
go test -json > /cache/test-report.out
id: Generate test report
waitFor:
- '-'
entrypoint: bash
- name: 'us.gcr.io/featurebase-pipeline-dev/featurebase:0.3'
args:
- go
- tool
- cover
- '-html'
- /cache/coverage.out
- '-o'
- /cache/coverage.html
id: Calculate Coverage
waitFor:
- Generate code coverage report
- name: 'sonarsource/sonar-scanner-cli:4.6'
args:
- '-Dsonar.projectKey=molecula_featurebase'
- '-Dsonar.organization=molecula'
- '-Dsonar.sources=.'
- '-Dsonar.host.url=https://sonarcloud.io'
- '-Dsonar.go.coverage.reportPaths=/cache/coverage.out'
- '-Dsonar.go.tests.reportPaths=/cache/test-report.out'
id: SonarCloud
waitFor:
- Calculate Coverage
secretEnv:
- SONAR_TOKEN
- name: 'us.gcr.io/featurebase-pipeline-dev/featurebase:0.3'
args:
- jfrog
- config
- add
- molecula
- '--interactive=false'
- '--artifactory-url=https://molecula.jfrog.io/'
- '--access-token=$$JFROG_API_TOKEN'
secretEnv:
- JFROG_API_TOKEN
- name: 'us.gcr.io/featurebase-pipeline-dev/featurebase:0.3'
env:
- GOOS=linux
- GOARCH=amd64
args:
- go
- build
- '-o'
- /cache/featurebase_linux_amd64
- ./cmd/featurebase
id: Build for Linux amd64
waitFor:
- '-'
- name: 'us.gcr.io/featurebase-pipeline-dev/featurebase:0.3'
env:
- GOOS=darwin
- GOARCH=amd64
args:
- go
- build
- '-o'
- /cache/featurebase_darwin_amd64
- ./cmd/featurebase
id: Build for Darwin amd64
waitFor:
- '-'
- name: 'us.gcr.io/featurebase-pipeline-dev/featurebase:0.3'
env:
- GOOS=linux
- GOARCH=arm64
args:
- go
- build
- '-o'
- /cache/featurebase_linux_arm64
- ./cmd/featurebase
id: Build for Linux arm64
waitFor:
- '-'
- name: 'us.gcr.io/featurebase-pipeline-dev/featurebase:0.3'
env:
- GOOS=darwin
- GOARCH=arm64
args:
- go
- build
- '-o'
- /cache/featurebase_darwin_arm64
- ./cmd/featurebase
id: Build for Darwin arm64
waitFor:
- '-'
- name: gcr.io/cloud-builders/gsutil
args:
- '-c'
- >
gsutil -m cp -r '/cache/*'
"gs://molecula-pipeline/featurebase/dev/$SHORT_SHA/"
id: Upload Binaries by Short SHA
waitFor:
- Package Lattice Build
- Calculate Coverage
- Build for Linux amd64
- Build for Darwin amd64
- Build for Linux arm64
- Build for Darwin arm64
entrypoint: bash
- name: gcr.io/cloud-builders/gsutil
args:
- '-c'
- >
gsutil -m cp -r '/cache/*'
"gs://molecula-pipeline/featurebase/dev/$BRANCH_NAME/"
id: Upload Binaries by Branch Name
waitFor:
- Package Lattice Build
- Calculate Coverage
- Build for Linux amd64
- Build for Darwin amd64
- Build for Linux arm64
- Build for Darwin arm64
entrypoint: bash
- name: gcr.io/cloud-builders/docker
args:
- '-c'
- >
cp -v /cache/* .cloudbuild/ && docker build --build-arg
SHORT_SHA=$SHORT_SHA -t
northamerica-northeast1-docker.pkg.dev/featurebase-pipeline-dev/featurebase/main:$SHORT_SHA
-f .cloudbuild/Dockerfile .
id: Build Linux amd Container
entrypoint: bash
- name: gcr.io/cloud-builders/docker
args:
- push
- >-
northamerica-northeast1-docker.pkg.dev/featurebase-pipeline-dev/featurebase/main:$SHORT_SHA
waitFor:
- Build Linux amd Container
timeout: 1200s
logsBucket: 'gs://molecula-pipeline/logs'
options:
volumes:
- name: data
path: /cache
pool:
name: >-
projects/featurebase-pipeline-dev/locations/us-central1/workerPools/test-pool-00
availableSecrets:
secretManager:
- versionName: projects/903994035405/secrets/jfrog-admin-token/versions/1
env: JFROG_API_TOKEN
- versionName: projects/903994035405/secrets/sonarcloud-featurebase-token/versions/1
env: SONAR_TOKEN