Skip to content

Commit

Permalink
speed up build by paritioning (#150)
Browse files Browse the repository at this point in the history
speed up build by paritioningNote the most elegant solution, but the best quick-win I could find with travis.


### Test Plan
* run travis
  • Loading branch information
ryanking authored and czimergebot committed Oct 23, 2019
1 parent 18fbacd commit 7fcf733
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 20 deletions.
40 changes: 21 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,30 @@ install:
# - chmod +x ~/bin/terraform-docs
# awscli
- pip install awscli --upgrade --user
# gotest
- go get github.com/rakyll/gotest
- go install github.com/rakyll/gotest
- aws configure set aws_access_key_id $CI1_AWS_ACCESS_KEY_ID --profile cztack-ci-1
- aws configure set aws_secret_access_key $CI1_AWS_SECRET_ACCESS_KEY --profile cztack-ci-1
- aws --profile cztack-ci-1 sts get-caller-identity
- aws configure set aws_access_key_id $CI2_AWS_ACCESS_KEY_ID --profile cztack-ci-2
- aws configure set aws_secret_access_key $CI2_AWS_SECRET_ACCESS_KEY --profile cztack-ci-2
- aws --profile cztack-ci-2 sts get-caller-identity

script:
- travis_wait 45 make test-ci

jobs:
include:
- stage: check
script: make lint
# terraform-docs is incompatible with 0.12 for now
# - stage: check
# script: make check-docs
- stage: check
before_script:
- aws configure set aws_access_key_id $CI1_AWS_ACCESS_KEY_ID --profile cztack-ci-1
- aws configure set aws_secret_access_key $CI1_AWS_SECRET_ACCESS_KEY --profile cztack-ci-1
- aws --profile cztack-ci-1 sts get-caller-identity
- aws configure set aws_access_key_id $CI2_AWS_ACCESS_KEY_ID --profile cztack-ci-2
- aws configure set aws_secret_access_key $CI2_AWS_SECRET_ACCESS_KEY --profile cztack-ci-2
- aws --profile cztack-ci-2 sts get-caller-identity
script: travis_wait 45 make test
env:
jobs:
- TEST_BUCKET_INDEX=0
- TEST_BUCKET_INDEX=1
- TEST_BUCKET_INDEX=2
- TEST_BUCKET_INDEX=3
- TEST_BUCKET_INDEX=4
- TEST_BUCKET_IND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8YAbd0=
Expand Down
23 changes: 22 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,27 @@ export ROUTE53_ZONE_ID := Z2W9YC1AAOXX6B
export WILDCARD_CERT_ARN := arn:aws:acm:us-west-2:119435350371:certificate/b13e8e24-6436-488d-990d-2cedee3e36dd
export CLOUDFRONT_WILDCARD_CERT_ARN := arn:aws:acm:us-east-1:119435350371:certificate/99f1fb68-4469-4280-b452-7193c8c787ca
export ACCOUNT_ID := 119435350371
export AWS_PROFILE=cztack-ci-1
export AWS_SDK_LOAD_CONFIG=true
export GOFLAGS=-mod=vendor
export GO111MODULE=on

all: clean fmt docs lint test

setup: ## setup development dependencies
curl -L https://raw.githubusercontent.com/chanzuckerberg/bff/master/download.sh | sh
.PHONY: setup

release: ## run a release
bff bump
git push
.PHONY: release

fmt:
@for m in $(MODULES); do \
terraform fmt $m; \
done
.PHONY: fmt

lint:
@for m in $(MODULES); do \
Expand All @@ -33,23 +40,37 @@ lint:
@for m in $(MODULES); do \
ls $$m/*_test.go 2>/dev/null 1>/dev/null || (echo "no test(s) for $$m"; exit $$?); \
done
.PHONY: lint

docs:
@for m in $(MODULES); do \
pushd $$m; \
../scripts/update-readme.sh update; \
popd; \
done;
.PHONY: docs

check-docs:
@for m in $(MODULES); do \
pushd $$m; \
../scripts/update-readme.sh check || exit $$?; \
popd; \
done;
.PHONY: check-docs

clean:
rm **/*.tfstate*; true
.PHONY: clean

test: fmt
AWS_PROFILE=cztack-ci-1 AWS_SDK_LOAD_CONFIG=true gotest -count=1 -parallel 10 -test.timeout 45m $(TEST)
go test -count=1 -parallel 10 -test.timeout 45m $(TEST)
.PHONY: test

test-ci:
go list ./... | ./scripts/split-build $(TEST_BUCKETS) $(TEST_BUCKET_INDEX) | xargs go test -count=1 -parallel 10 -test.timeout 45m
.PHONY: test

deps:
go mod tidy
go mod vendor
.PHONY: deps
15 changes: 15 additions & 0 deletions aws-nuke.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
regions:
- us-west-2

account-blacklist:
- "1"

accounts:
"119435350371": {}

resource-types:
# we can add to this over time
targets:
- RDSDBCluster
- RDSSnapshot
- RDSInstance
20 changes: 20 additions & 0 deletions scripts/split-build
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python

import os, sys

buckets = int(sys.argv[1])
bucket = int(sys.argv[2])

assert bucket < buckets

b = []

for i in range(buckets):
b.append([])

for i, line in enumerate(sys.stdin):
for x in line.strip().split():
b[ i % buckets ].append(x)

for pkg in b[bucket]:
print(pkg)

0 comments on commit 7fcf733

Please sign in to comment.