Skip to content

Commit bf8ed1b

Browse files
authored
Build images and run Python tests on all branches (#33)
1 parent a14a2eb commit bf8ed1b

File tree

3 files changed

+52
-23
lines changed

3 files changed

+52
-23
lines changed

.circleci/config.yml

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,35 @@
1-
version: 2
1+
version: 2.1
2+
3+
commands:
4+
return-if-not-deployed-branch:
5+
description: >-
6+
Exit and succeed this build step if it should not deploy images to DockerHub / upload CLI to AWS
7+
steps:
8+
- run:
9+
name: Exit build step if should not be deployed
10+
command: |
11+
if ! ([[ "$CIRCLE_BRANCH" =~ ^[0-9]\.[0-9]$ ]] || [[ "$CIRCLE_BRANCH" == "master" ]]); then
12+
echo "Exiting build step for branch which should not be deployed ($CIRCLE_BRANCH)"
13+
circleci step halt
14+
fi
15+
install-go:
16+
steps:
17+
- run:
18+
name: Install Go
19+
command: |
20+
wget https://dl.google.com/go/go1.11.5.linux-amd64.tar.gz
21+
sudo tar -C /usr/local -xzf go1.11.5.linux-amd64.tar.gz
22+
rm -rf go*.tar.gz
23+
echo 'export PATH=$PATH:/usr/local/go/bin' >> $BASH_ENV
24+
echo 'export PATH=$PATH:~/go/bin' >> $BASH_ENV
225
326
jobs:
427
test:
528
docker:
629
- image: circleci/python:3.7.2-stretch
730
steps:
831
- checkout
9-
- 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
32+
- install-go
1033
- run: GO111MODULE=off go get -u -v golang.org/x/lint/golint
1134
- run: sudo pip3 install black
1235
- run:
@@ -23,30 +46,32 @@ jobs:
2346
- run:
2447
name: Version Test
2548
command: make find-missing-version
26-
deploy:
49+
build-and-deploy:
2750
docker:
2851
- image: circleci/python:3.7.2-stretch
2952
steps:
30-
- 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
31-
- run: sudo pip3 install awscli
32-
- checkout
3353
- setup_remote_docker
54+
- install-go
55+
- checkout
3456
- run: make build-images
57+
- run: make build-cli
3558
- run: make test-python
59+
- return-if-not-deployed-branch
60+
- run: sudo pip3 install awscli
3661
- run: make push-images
3762
- run: make build-and-upload-cli
3863

3964
workflows:
40-
version: 2
41-
build_and_test:
65+
version: 2.1
66+
build:
4267
jobs:
4368
- test
4469
- test-release:
4570
filters:
4671
branches:
4772
only:
4873
- /^[0-9]\.[0-9]$/
49-
- deploy-approval:
74+
- build-and-deploy-approval:
5075
type: approval
5176
requires:
5277
- test
@@ -55,13 +80,8 @@ workflows:
5580
branches:
5681
only:
5782
- /^[0-9]\.[0-9]$/
58-
- deploy:
83+
- build-and-deploy:
5984
requires:
6085
- test
6186
- test-release
62-
- deploy-approval
63-
filters:
64-
branches:
65-
only:
66-
- /^[0-9]\.[0-9]$/
67-
- master
87+
- build-and-deploy-approval

Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,5 +153,8 @@ push-images:
153153
@./build/push-image.sh argo-controller
154154
@./build/push-image.sh argo-executor
155155

156-
build-and-upload-cli:
156+
build-cli:
157157
@./build/cli.sh
158+
159+
build-and-upload-cli:
160+
@./build/cli.sh upload

build/cli.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,26 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. >/dev/null && pwd)"
2121

2222
CORTEX_VERSION=master
2323

24+
arg1=${1:-""}
25+
upload="false"
26+
if [ "$arg1" == "upload" ]; then
27+
upload="true"
28+
fi
29+
2430
function build_and_upload() {
2531
set -euo pipefail
2632

2733
os=$1
34+
echo -e "\nBuilding Cortex CLI for $os"
2835
GOOS=$os GOARCH=amd64 CGO_ENABLED=0 GO111MODULE=on go build -o cortex "$ROOT/cli"
29-
aws s3 cp cortex s3://$CLI_BUCKET_NAME/$CORTEX_VERSION/cli/$os/cortex --only-show-errors
36+
if [ "$upload" == "true" ]; then
37+
echo "Uploading Cortex CLI to s3://$CLI_BUCKET_NAME/$CORTEX_VERSION/cli/$os/cortex"
38+
aws s3 cp cortex s3://$CLI_BUCKET_NAME/$CORTEX_VERSION/cli/$os/cortex --only-show-errors
39+
fi
40+
echo "Done ✓"
3041
rm cortex
31-
echo "Uploaded CLI to s3://$CLI_BUCKET_NAME/$CORTEX_VERSION/cli/$os/cortex"
3242
}
3343

34-
echo ""
35-
echo "Building Cortex CLI for Mac"
3644
build_and_upload darwin
3745

38-
echo ""
39-
echo "Building Cortex CLI for Linux"
4046
build_and_upload linux

0 commit comments

Comments
 (0)