Skip to content
Permalink
Browse files

Build images and run Python tests on all branches (#33)

  • Loading branch information...
deliahu committed Mar 11, 2019
1 parent a14a2eb commit bf8ed1b19a4faa9d0bf5ecc76283f2461e4fc99d
Showing with 52 additions and 23 deletions.
  1. +36 −16 .circleci/config.yml
  2. +4 −1 Makefile
  3. +12 −6 build/cli.sh
@@ -1,12 +1,35 @@
version: 2
version: 2.1

commands:
return-if-not-deployed-branch:
description: >-
Exit and succeed this build step if it should not deploy images to DockerHub / upload CLI to AWS
steps:
- run:
name: Exit build step if should not be deployed
command: |
if ! ([[ "$CIRCLE_BRANCH" =~ ^[0-9]\.[0-9]$ ]] || [[ "$CIRCLE_BRANCH" == "master" ]]); then
echo "Exiting build step for branch which should not be deployed ($CIRCLE_BRANCH)"
circleci step halt
fi
install-go:
steps:
- run:
name: Install Go
command: |
wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.11.5.linux-amd64.tar.gz
rm -rf go*.tar.gz
echo 'export PATH=$PATH:/usr/local/go/bin' >> $BASH_ENV
echo 'export PATH=$PATH:~/go/bin' >> $BASH_ENV
jobs:
test:
docker:
- image: circleci/python:3.7.2-stretch
steps:
- checkout
- run: wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz && sudo tar -C /usr/local -xzf go1.11.5.linux-amd64.tar.gz && rm -rf go*.tar.gz && echo 'export PATH=$PATH:/usr/local/go/bin' >> $BASH_ENV && echo 'export PATH=$PATH:~/go/bin' >> $BASH_ENV
- install-go
- run: GO111MODULE=off go get -u -v golang.org/x/lint/golint
- run: sudo pip3 install black
- run:
@@ -23,30 +46,32 @@ jobs:
- run:
name: Version Test
command: make find-missing-version
deploy:
build-and-deploy:
docker:
- image: circleci/python:3.7.2-stretch
steps:
- run: wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz && sudo tar -C /usr/local -xzf go1.11.5.linux-amd64.tar.gz && rm -rf go*.tar.gz && echo 'export PATH=$PATH:/usr/local/go/bin' >> $BASH_ENV && echo 'export PATH=$PATH:~/go/bin' >> $BASH_ENV
- run: sudo pip3 install awscli
- checkout
- setup_remote_docker
- install-go
- checkout
- run: make build-images
- run: make build-cli
- run: make test-python
- return-if-not-deployed-branch
- run: sudo pip3 install awscli
- run: make push-images
- run: make build-and-upload-cli

workflows:
version: 2
build_and_test:
version: 2.1
build:
jobs:
- test
- test-release:
filters:
branches:
only:
- /^[0-9]\.[0-9]$/
- deploy-approval:
- build-and-deploy-approval:
type: approval
requires:
- test
@@ -55,13 +80,8 @@ workflows:
branches:
only:
- /^[0-9]\.[0-9]$/
- deploy:
- build-and-deploy:
requires:
- test
- test-release
- deploy-approval
filters:
branches:
only:
- /^[0-9]\.[0-9]$/
- master
- build-and-deploy-approval
@@ -153,5 +153,8 @@ push-images:
@./build/push-image.sh argo-controller
@./build/push-image.sh argo-executor

build-and-upload-cli:
build-cli:
@./build/cli.sh

build-and-upload-cli:
@./build/cli.sh upload
@@ -21,20 +21,26 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. >/dev/null && pwd)"

CORTEX_VERSION=master

arg1=${1:-""}
upload="false"
if [ "$arg1" == "upload" ]; then
upload="true"
fi

function build_and_upload() {
set -euo pipefail

os=$1
echo -e "\nBuilding Cortex CLI for $os"
GOOS=$os GOARCH=amd64 CGO_ENABLED=0 GO111MODULE=on go build -o cortex "$ROOT/cli"
aws s3 cp cortex s3://$CLI_BUCKET_NAME/$CORTEX_VERSION/cli/$os/cortex --only-show-errors
if [ "$upload" == "true" ]; then
echo "Uploading Cortex CLI to s3://$CLI_BUCKET_NAME/$CORTEX_VERSION/cli/$os/cortex"
aws s3 cp cortex s3://$CLI_BUCKET_NAME/$CORTEX_VERSION/cli/$os/cortex --only-show-errors
fi
echo "Done ✓"
rm cortex
echo "Uploaded CLI to s3://$CLI_BUCKET_NAME/$CORTEX_VERSION/cli/$os/cortex"
}

echo ""
echo "Building Cortex CLI for Mac"
build_and_upload darwin

echo ""
echo "Building Cortex CLI for Linux"
build_and_upload linux

0 comments on commit bf8ed1b

Please sign in to comment.
You can’t perform that action at this time.