Skip to content

Commit

Permalink
First draft at setting up Cloudbuild
Browse files Browse the repository at this point in the history
Revert dependencies
  • Loading branch information
VinayLondhe14 committed May 6, 2022
1 parent 00a1e0d commit 54c6cdc
Show file tree
Hide file tree
Showing 9 changed files with 609 additions and 30 deletions.
18 changes: 18 additions & 0 deletions .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
28 changes: 0 additions & 28 deletions cloudbuild.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions cloudbuild/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# This Dockerfile creates an image for running presubmit tests.
FROM openjdk:8
29 changes: 29 additions & 0 deletions cloudbuild/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
steps:
# 1. Create a Docker image containing hadoop-connectors repo
- name: 'gcr.io/cloud-builders/docker'
id: 'docker-build'
args: ['build', '--tag=gcr.io/$PROJECT_ID/dataproc-hive-bigquery-storage-handler-presubmit', '-f', 'cloudbuild/Dockerfile', '.']

# 2. Fetch maven and dependencies
- name: 'gcr.io/$PROJECT_ID/dataproc-hive-bigquery-storage-handler-presubmit'
id: 'init'
waitFor: ['docker-build']
entrypoint: 'bash'
args: ['/workspace/cloudbuild/presubmit.sh', 'init']
env:
- 'CODECOV_TOKEN=${_CODECOV_TOKEN}'

# 3. Run unit tests
- name: 'gcr.io/$PROJECT_ID/dataproc-hive-bigquery-storage-handler-presubmit'
id: 'unit-tests'
waitFor: ['init']
entrypoint: 'bash'
args: ['/workspace/cloudbuild/presubmit.sh', 'unittest']
env:
- 'CODECOV_TOKEN=${_CODECOV_TOKEN}'

# Tests take around 30 mins in general.
timeout: 1800s

options:
machineType: 'N1_HIGHCPU_32'
13 changes: 13 additions & 0 deletions cloudbuild/gcp-settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<id>google-maven-central</id>
<name>GCS Maven Central mirror</name>
<url>https://maven-central.storage-download.googleapis.com/maven2/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
</settings>
41 changes: 41 additions & 0 deletions cloudbuild/presubmit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

# Copyright 2019 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -euxo pipefail

readonly MVN="./mvnw -B -e -s /workspace/cloudbuild/gcp-settings.xml -Dmaven.repo.local=/workspace/.repository"
readonly STEP=$1

cd /workspace

case $STEP in
# Download maven and all the dependencies
init)
$MVN install -DskipTests
exit
;;

# Run unit tests
unittest)
$MVN test
;;

*)
echo "Unknown step $STEP"
exit 1
;;
esac

Loading

0 comments on commit 54c6cdc

Please sign in to comment.