diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..df68f82 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,38 @@ +#!groovy +// Copyright (2021) Cobalt Speech and Language Inc. + +// Keep only 10 builds on Jenkins +properties([ + buildDiscarder(logRotator( + artifactDaysToKeepStr: '', artifactNumToKeepStr: '', daysToKeepStr: '', numToKeepStr: '10')) +]) + +if (env.CHANGE_ID) { + // Building a pull request + node { + try { + timeout(time: 30, unit: 'MINUTES'){ + checkout scm + def sdkGenImage = docker.build("sdk-generator", "./ci") + sdkGenImage.inside('-u root') { + stage("validate") { + try { + commit.setBuildStatus("validate-built-artifacts", "PENDING", "Validating generated artifacts.") + sh 'make' + sh "git diff --exit-code" + } finally { + // Allow Jenkins to cleanup workspace + sh "chown -R 1000:1000 ." + } + } + } + commit.setBuildStatus("validate-built-artifacts", "SUCCESS", "Successfully validated.") + } + } catch(err) { + commit.setBuildStatus("validate-built-artifacts", "ERROR", "Validation failed.") + throw err + } finally { + deleteDir() + } + } +} diff --git a/ci/Dockerfile b/ci/Dockerfile new file mode 100644 index 0000000..ec52eb3 --- /dev/null +++ b/ci/Dockerfile @@ -0,0 +1,8 @@ +# Copyright (2021) Cobalt Speech and Language Inc. + +# Dockerfile to setup base system for building protoc/grpc code + +FROM debian:10 +RUN apt-get update && apt-get install -y clang git libcurl4 libpython2.7 libpython2.7-dev libtinfo5 libncurses5 make python-virtualenv python3 python3-pip sudo unzip wget +RUN wget https://dl.google.com/go/go1.16.2.linux-amd64.tar.gz -O - | tar xz && mv go /usr/share/go +ENV PATH=/usr/share/go/bin:$PATH