Skip to content

Commit 575b6e0

Browse files
committed
Squashed 'tools/' changes from b783528..7fab441
7fab441 Rename bazel to bazel-rules (#125) ccc8316 Revert "Gocyclo should return error code if issues detected" (#124) 1fe184f Bazel rules for building gogo protobufs (#123) b917bb8 Merge pull request #122 from weaveworks/fix-scope-gc c029ce0 Add regex to match scope VMs 0d4824b Merge pull request #121 from weaveworks/provisioning-readme-terraform 5a82d64 Move terraform instructions to tf section d285d78 Merge pull request #120 from weaveworks/gocyclo-return-value 76b94a4 Do not spawn subshell when reading cyclo output 93b3c0d Use golang:1.9.2-stretch image d40728f Gocyclo should return error code if issues detected c4ac1c3 Merge pull request #114 from weaveworks/tune-spell-check 8980656 Only check files 12ebc73 Don't spell-check pki files 578904a Special-case spell-check the same way we do code checks e772ed5 Special-case on mime type and extension using just patterns ae82b50 Merge pull request #117 from weaveworks/test-verbose 8943473 Propagate verbose flag to 'go test'. 7c79b43 Merge pull request #113 from weaveworks/update-shfmt-instructions 258ef01 Merge pull request #115 from weaveworks/extra-linting e690202 Use tools in built image to lint itself 126eb56 Add shellcheck to bring linting in line with scope 63ad68f Don't run lint on files under .git 51d908a Update shfmt instructions e91cb0d Merge pull request #112 from weaveworks/add-python-lint-tools 0c87554 Add yapf and flake8 to golang build image 35679ee Merge pull request #110 from weaveworks/parallel-push-errors 3ae41b6 Remove unneeded if block 51ff31a Exit on first error 0faad9f Check for errors when pushing images in parallel 74dc626 Merge pull request #108 from weaveworks/disable-apt-daily b4f1d91 Merge pull request #107 from weaveworks/docker-17-update 7436aa1 Override apt daily job to not run immediately on boot 7980f15 Merge pull request #106 from weaveworks/document-docker-install-role f741e53 Bump to Docker 17.06 from CE repo 61796a1 Update Docker CE Debian repo details 0d86f5e Allow for Docker package to be named docker-ce 065c68d Document selection of Docker installation role. 3809053 Just --porcelain; it defaults to v1 11400ea Merge pull request #105 from weaveworks/remove-weaveplugin-remnants b8b4d64 remove weaveplugin remnants 35099c9 Merge pull request #104 from weaveworks/pull-docker-py cdd48fc Pull docker-py to speed tests/builds up. e1c6c24 Merge pull request #103 from weaveworks/test-build-tags d5d71e0 Add -tags option so callers can pass in build tags 8949b2b Merge pull request #98 from weaveworks/git-status-tag ac30687 Merge pull request #100 from weaveworks/python_linting 4b125b5 Pin yapf & flake8 versions 7efb485 Lint python linting function 444755b Swap diff direction to reflect changes required c5b2434 Install flake8 & yapf 5600eac Lint python in build-tools repo 0b02ca9 Add python linting c011c0d Merge pull request #79 from kinvolk/schu/python-shebang 6577d07 Merge pull request #99 from weaveworks/shfmt-version 00ce0dc Use git status instead of diff to add 'WIP' tag 411fd13 Use shfmt v1.3.0 instead of latest from master. 0d6d4da Run shfmt 1.3 on the code. 5cdba32 Add sudo c322ca8 circle.yml: Install shfmt binary. e59c225 Install shfmt 1.3 binary. 30706e6 Install pyhcl in the build container. 960d222 Merge pull request #97 from kinvolk/alban/update-shfmt-3 1d535c7 shellcheck: fix escaping issue 5542498 Merge pull request #96 from kinvolk/alban/update-shfmt-2 32f7cc5 shfmt: fix coding style 09f72af lint: print the diff in case of error 571c7d7 Merge pull request #95 from kinvolk/alban/update-shfmt bead6ed Update for latest shfmt b08dc4d Update for latest shfmt (#94) 2ed8aaa Add no-race argument to test script (#92) 80dd78e Merge pull request #91 from weaveworks/upgrade-go-1.8.1 08dcd0d Please ./lint as shfmt changed its rules between 1.0.0 and 1.3.0. a8bc9ab Upgrade default Go version to 1.8.1. 41c5622 Merge pull request #90 from weaveworks/build-golang-service-conf e8ebdd5 broaden imagetag regex to fix haskell build image ba3fbfa Merge pull request #89 from weaveworks/build-golang-service-conf e506f1b Fix up test script for updated shfmt 9216db8 Add stuff for service-conf build to build-goland image 66a9a93 Merge pull request #88 from weaveworks/haskell-image cb3e3a2 shfmt 74a5239 Haskell build image 4ccd42b Trying circle quay login b2c295f Merge branch 'common-build' 0ac746f Trim quay prefix in circle script c405b31 Merge pull request #87 from weaveworks/common-build 9672d7c Push build images to quay as they have sane robot accounts a2bf112 Review feedback fef9b7d Add protobuf tools 10a77ea Update readme 254f266 Don't need the image name in ffb59fc Adding a weaveworks/build-golang image with tags b817368 Update min Weave Net docker version cf87ca3 Merge pull request #86 from weaveworks/lock-kubeadm-version 3ae6919 Add example of custom SSH private key to tf_ssh's usage. cf8bd8a Add example of custom SSH private key to tf_ansi's usage. c7d3370 Lock kubeadm's Kubernetes version. faaaa6f Merge pull request #84 from weaveworks/centos-rhel ef552e7 Select weave-kube YAML URL based on K8S version. b4c1198 Upgrade default kubernetes_version to 1.6.1. b82805e Use a fixed version of kubeadm. f33888b Factorise and make kubeconfig option optional. f7b8b89 Install EPEL repo for CentOS. 615917a Fix error in decrypting AWS access key and secret. 86f97b4 Add CentOS 7 AMI and username for AWS via Terraform. eafd810 Add tf_ansi example with Ansible variables. 2b05787 Skip setup of Docker over TCP for CentOS/RHEL. 84c420b Add docker-ce role for CentOS/RHEL. 00a820c Add setup_weave-net_debug.yml playbook for user issues' debugging. 3eae480 Upgrade default kubernetes_version to 1.5.4. 753921c Allow injection of Docker installation role. e1ff90d Fix kubectl taint command for 1.5. b989e97 Fix typo in kubectl taint for single node K8S cluster. 541f58d Remove 'install_recommends: no' for ethtool. c3f9711 Make Ansible role docker-from-get.docker.com work on RHEL/CentOS. 038c0ae Add frequently used OS images, for convenience. d30649f Add --insecure-registry to docker.conf 1dd9218 shfmt -i 4 -w push-images 6de96ac Add option to not push docker hub images 310f53d Add push-images script from cortex 8641381 Add port 6443 to kubeadm join commands for K8S 1.6+. 50bf0bc Force type of K8S token to string. 08ab1c0 Remove trailing whitespaces. ae9efb8 Enable testing against K8S release candidates. 9e32194 Secure GCP servers for Scope: open port 80. a22536a Secure GCP servers for Scope. 89c3a29 Merge pull request #78 from weaveworks/lint-merge-rebase-issue-in-docs 73ad56d Add linter function to avoid bad merge/rebase artefact 31d069d Change Python shebang to `#!/usr/bin/env python` 52d695c Merge pull request #77 from kinvolk/schu/fix-relative-weave-path 77aed01 Merge pull request #73 from weaveworks/mike/sched/fix-unicode-issue 7c080f4 integration/sanity_check: disable SC1090 d6d360a integration/gce.sh: update gcloud command e8def2c provisioning/setup: fix shellcheck SC2140 cc02224 integration/config: fix weave path 9c0d6a5 Fix config_management/README.md 334708c Merge pull request #75 from kinvolk/alban/external-build-1 da2505d gce.sh: template: print creation date e676854 integration tests: fix user account 8530836 host nameing: add repo name b556c0a gce.sh: fix deletion of gce instances 2ecd1c2 integration: fix GCE --zones/--zone parameter 3e863df sched: Fix unicode encoding issues 51785b5 Use rm -f and set current dir using BASH_SOURCE. f5c6d68 Merge pull request #71 from kinvolk/schu/fix-linter-warnings 0269628 Document requirement for `lint_sh` 9a3f09e Fix linter warnings efcf9d2 Merge pull request #53 from weaveworks/2647-testing-mvp d31ea57 Weave Kube playbook now works with multiple nodes. 27868dd Add GCP firewall rule for FastDP crypto. edc8bb3 Differentiated name of dev and test playbooks, to avoid confusion. efa3df7 Moved utility Ansible Yaml to library directory. fcd2769 Add shorthands to run Ansible playbooks against Terraform-provisioned virtual machines. f7946fb Add shorthands to SSH into Terraform-provisioned virtual machines. aad5c6f Mention Terraform and Ansible in README.md. dddabf0 Add Terraform output required for templates' creation. dcc7d02 Add Ansible configuration playbooks for development environments. f86481c Add Ansible configuration playbooks for Docker, K8S and Weave-Net. efedd25 Git-ignore Ansible retry files. 765c4ca Add helper functions to setup Terraform programmatically. 801dd1d Add Terraform cloud provisioning scripts. b8017e1 Install hclfmt on CircleCI. 4815e19 Git-ignore Terraform state files. 0aaebc7 Add script to generate cartesian product of dependencies of cross-version testing. 007d90a Add script to list OS images from GCP, AWS and DO. ca65cc0 Add script to list relevant versions of Go, Docker and Kubernetes. aa66f44 Scripts now source dependencies using absolute path (previously breaking make depending on current directory). 7865e86 Add -p option to parallelise lint. 36c1835 Merge pull request #69 from weaveworks/mflag 9857568 Use mflag and mflagext package from weaveworks/common. 9799112 Quote bash variable. 10a36b3 Merge pull request #67 from weaveworks/shfmt-ignore a59884f Add support for .lintignore. 03cc598 Don't lint generated protobuf code. 2b55c2d Merge pull request #66 from weaveworks/reduce-test-timeout d4e163c Make timeout a flag 49a8609 Reduce test timeout 8fa15cb Merge pull request #63 from weaveworks/test-defaults git-subtree-dir: tools git-subtree-split: 7fab44131e536aee46f60e17f7dcc438869fec76
1 parent 19467df commit 575b6e0

File tree

77 files changed

+3694
-188
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+3694
-188
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ socks/image.tar
44
runner/runner
55
*.pyc
66
*~
7+
terraform.tfstate
8+
terraform.tfstate.backup
9+
*.retry
10+
build/**/.uptodate

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22

33
Included in this repo are tools shared by weave.git and scope.git. They include
44

5+
- ```bazel-rules```: Bazel build rules used in our projects
6+
- ```build```: a set of docker base-images for building weave
7+
projects. These should be used instead of giving each project its
8+
own build image.
9+
- ```provisioning```: a set of Terraform scripts to provision virtual machines in GCP, AWS or Digital Ocean.
10+
- ```config_management```: a set of Ansible playbooks to configure virtual machines for development, testing, etc.
511
- ```cover```: a tool which merges overlapping coverage reports generated by go
612
test
713
- ```files-with-type```: a tool to search directories for files of a given
814
MIME type
9-
- ```lint```: a script to lint Go project; runs various tools like golint, go
10-
vet, errcheck etc
15+
- ```lint```: a script to lint go, sh and hcl files; runs various tools like
16+
golint, go vet, errcheck, shellcheck etc
1117
- ```rebuild-image```: a script to rebuild docker images when their input files
1218
change; useful when you using docker images to build your software, but you
1319
don't want to build the image every time.
@@ -24,6 +30,15 @@ Included in this repo are tools shared by weave.git and scope.git. They include
2430
- ```scheduler```: an appengine application that can be used to distribute
2531
tests across different shards in CircleCI.
2632

33+
## Requirements
34+
35+
- ```lint``` requires shfmt to lint sh files; get shfmt with
36+
```
37+
curl -fsSLo shfmt https://github.com/mvdan/sh/releases/download/v1.3.0/shfmt_v1.3.0_linux_amd64
38+
chmod +x shfmt
39+
```
40+
(we pin that version, and it doesn't build from the source repo any more)
41+
2742
## Using build-tools.git
2843

2944
To allow you to tie your code to a specific version of build-tools.git, such

bazel-rules/BUILD.bazel

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
load("@io_bazel_rules_go//proto:compiler.bzl", "go_proto_compiler")
2+
3+
go_proto_compiler(
4+
name = "gogo_proto",
5+
deps = [
6+
"//vendor/github.com/gogo/protobuf/gogoproto:go_default_library",
7+
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
8+
"//vendor/github.com/gogo/protobuf/sortkeys:go_default_library",
9+
],
10+
plugin = "@com_github_gogo_protobuf//protoc-gen-gogoslick",
11+
visibility = ["//visibility:public"],
12+
)
13+
14+
go_proto_compiler(
15+
name = "gogo_grpc",
16+
deps = [
17+
"//vendor/github.com/gogo/protobuf/gogoproto:go_default_library",
18+
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
19+
"//vendor/github.com/gogo/protobuf/sortkeys:go_default_library",
20+
"//vendor/google.golang.org/grpc:go_default_library",
21+
"//vendor/golang.org/x/net/context:go_default_library",
22+
],
23+
plugin = "@com_github_gogo_protobuf//protoc-gen-gogoslick",
24+
options = ["plugins=grpc"],
25+
visibility = ["//visibility:public"],
26+
)

bazel-rules/gogo.bzl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
load("@io_bazel_rules_go//go:def.bzl", "go_repository")
2+
3+
4+
_BUILD_FILE = """
5+
proto_library(
6+
name = "gogoproto",
7+
srcs = ["gogo.proto"],
8+
deps = [
9+
"@com_google_protobuf//:descriptor_proto",
10+
],
11+
visibility = ["//visibility:public"],
12+
)
13+
"""
14+
15+
def _go_repository_impl(ctx):
16+
ctx.file("BUILD.bazel", content="")
17+
ctx.file("github.com/gogo/protobuf/gogoproto/BUILD.bazel", content=_BUILD_FILE)
18+
ctx.template("github.com/gogo/protobuf/gogoproto/gogo.proto", ctx.attr._proto)
19+
20+
_gogo_proto_repository = repository_rule(
21+
implementation = _go_repository_impl,
22+
attrs = {
23+
"_proto": attr.label(default="//vendor/github.com/gogo/protobuf/gogoproto:gogo.proto"),
24+
},
25+
)
26+
27+
def gogo_dependencies():
28+
go_repository(
29+
name = "com_github_gogo_protobuf",
30+
importpath = "github.com/gogo/protobuf",
31+
urls = ["https://codeload.github.com/ianthehat/protobuf/zip/2adc21fd136931e0388e278825291678e1d98309"],
32+
strip_prefix = "protobuf-2adc21fd136931e0388e278825291678e1d98309",
33+
type = "zip",
34+
build_file_proto_mode="disable",
35+
)
36+
_gogo_proto_repository(name = "internal_gogo_proto_repository")

build/Makefile

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.PHONY: all clean images
2+
.DEFAULT_GOAL := all
3+
4+
# Boiler plate for bulding Docker containers.
5+
# All this must go at top of file I'm afraid.
6+
IMAGE_PREFIX := quay.io/weaveworks/build-
7+
IMAGE_TAG := $(shell ../image-tag)
8+
UPTODATE := .uptodate
9+
10+
# Every directory with a Dockerfile in it builds an image called
11+
# $(IMAGE_PREFIX)<dirname>. Dependencies (i.e. things that go in the image)
12+
# still need to be explicitly declared.
13+
%/$(UPTODATE): %/Dockerfile %/*
14+
$(SUDO) docker build -t $(IMAGE_PREFIX)$(shell basename $(@D)) $(@D)/
15+
$(SUDO) docker tag $(IMAGE_PREFIX)$(shell basename $(@D)) $(IMAGE_PREFIX)$(shell basename $(@D)):$(IMAGE_TAG)
16+
touch $@
17+
18+
# Get a list of directories containing Dockerfiles
19+
DOCKERFILES := $(shell find . -name tools -prune -o -name vendor -prune -o -type f -name 'Dockerfile' -print)
20+
UPTODATE_FILES := $(patsubst %/Dockerfile,%/$(UPTODATE),$(DOCKERFILES))
21+
DOCKER_IMAGE_DIRS := $(patsubst %/Dockerfile,%,$(DOCKERFILES))
22+
IMAGE_NAMES := $(foreach dir,$(DOCKER_IMAGE_DIRS),$(patsubst %,$(IMAGE_PREFIX)%,$(shell basename $(dir))))
23+
images:
24+
$(info $(IMAGE_NAMES))
25+
@echo > /dev/null
26+
27+
# Define imagetag-golang, etc, for each image, which parses the dockerfile and
28+
# prints an image tag. For example:
29+
# FROM golang:1.8.1-stretch
30+
# in the "foo/Dockerfile" becomes:
31+
# $ make imagetag-foo
32+
# 1.8.1-stretch
33+
define imagetag_dep
34+
.PHONY: imagetag-$(1)
35+
$(patsubst $(IMAGE_PREFIX)%,imagetag-%,$(1)): $(patsubst $(IMAGE_PREFIX)%,%,$(1))/Dockerfile
36+
@cat $$< | grep "^FROM " | head -n1 | sed 's/FROM \(.*\):\(.*\)/\2/'
37+
endef
38+
$(foreach image, $(IMAGE_NAMES), $(eval $(call imagetag_dep, $(image))))
39+
40+
all: $(UPTODATE_FILES)
41+
42+
clean:
43+
$(SUDO) docker rmi $(IMAGE_NAMES) >/dev/null 2>&1 || true
44+
rm -rf $(UPTODATE_FILES)
45+
46+

build/golang/Dockerfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
FROM golang:1.9.2-stretch
2+
RUN apt-get update && \
3+
apt-get install -y \
4+
curl \
5+
file \
6+
git \
7+
jq \
8+
libprotobuf-dev \
9+
make \
10+
protobuf-compiler \
11+
python-pip \
12+
python-requests \
13+
python-yaml \
14+
shellcheck \
15+
unzip && \
16+
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
17+
RUN pip install attrs pyhcl yapf==0.16.2 flake8==3.3.0
18+
RUN curl -fsSLo shfmt https://github.com/mvdan/sh/releases/download/v1.3.0/shfmt_v1.3.0_linux_amd64 && \
19+
echo "b1925c2c405458811f0c227266402cf1868b4de529f114722c2e3a5af4ac7bb2 shfmt" | sha256sum -c && \
20+
chmod +x shfmt && \
21+
mv shfmt /usr/bin
22+
RUN go clean -i net && \
23+
go install -tags netgo std && \
24+
go install -race -tags netgo std
25+
RUN go get -tags netgo \
26+
github.com/FiloSottile/gvt \
27+
github.com/client9/misspell/cmd/misspell \
28+
github.com/fatih/hclfmt \
29+
github.com/fzipp/gocyclo \
30+
github.com/gogo/protobuf/gogoproto \
31+
github.com/gogo/protobuf/protoc-gen-gogoslick \
32+
github.com/golang/dep/... \
33+
github.com/golang/lint/golint \
34+
github.com/golang/protobuf/protoc-gen-go \
35+
github.com/kisielk/errcheck \
36+
github.com/mjibson/esc \
37+
github.com/prometheus/prometheus/cmd/promtool && \
38+
rm -rf /go/pkg /go/src
39+
RUN mkdir protoc && \
40+
cd protoc && \
41+
curl -O -L https://github.com/google/protobuf/releases/download/v3.1.0/protoc-3.1.0-linux-x86_64.zip && \
42+
unzip protoc-3.1.0-linux-x86_64.zip && \
43+
cp bin/protoc /usr/bin/ && \
44+
chmod o+x /usr/bin/protoc && \
45+
cd .. && \
46+
rm -rf protoc
47+
RUN mkdir -p /var/run/secrets/kubernetes.io/serviceaccount && \
48+
touch /var/run/secrets/kubernetes.io/serviceaccount/token
49+
COPY build.sh /
50+
ENTRYPOINT ["/build.sh"]

build/golang/build.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
if [ -n "${SRC_NAME:-}" ]; then
6+
SRC_PATH=${SRC_PATH:-$GOPATH/src/$SRC_NAME}
7+
elif [ -z "${SRC_PATH:-}" ]; then
8+
echo "Must set either \$SRC_NAME or \$SRC_PATH."
9+
exit 1
10+
fi
11+
12+
# If we run make directly, any files created on the bind mount
13+
# will have awkward ownership. So we switch to a user with the
14+
# same user and group IDs as source directory. We have to set a
15+
# few things up so that sudo works without complaining later on.
16+
uid=$(stat --format="%u" "$SRC_PATH")
17+
gid=$(stat --format="%g" "$SRC_PATH")
18+
echo "weave:x:$uid:$gid::$SRC_PATH:/bin/sh" >>/etc/passwd
19+
echo "weave:*:::::::" >>/etc/shadow
20+
echo "weave ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers
21+
22+
su weave -c "PATH=$PATH make -C $SRC_PATH BUILD_IN_CONTAINER=false $*"

build/haskell/Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM fpco/stack-build:lts-8.9
2+
COPY build.sh /
3+
COPY copy-libraries /usr/local/bin/
4+
ENTRYPOINT ["/build.sh"]

build/haskell/build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
#
3+
# Build a static Haskell binary using stack.
4+
5+
set -eu
6+
7+
if [ -z "${SRC_PATH:-}" ]; then
8+
echo "Must set \$SRC_PATH."
9+
exit 1
10+
fi
11+
12+
make -C "$SRC_PATH" BUILD_IN_CONTAINER=false "$@"

build/haskell/copy-libraries

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
#
3+
# Copy dynamically linked libraries for a binary, so we can assemble a Docker
4+
# image.
5+
#
6+
# Run with:
7+
# copy-libraries /path/to/binary /output/dir
8+
#
9+
# Dependencies:
10+
# - awk
11+
# - cp
12+
# - grep
13+
# - ldd
14+
# - mkdir
15+
16+
set -o errexit
17+
set -o nounset
18+
set -o pipefail
19+
20+
# Path to a Linux binary that we're going to run in the container.
21+
binary_path="${1}"
22+
# Path to directory to write the output to.
23+
output_dir="${2}"
24+
25+
exe_name=$(basename "${binary_path}")
26+
27+
# Identify linked libraries.
28+
libraries=($(ldd "${binary_path}" | awk '{print $(NF-1)}' | grep -v '=>'))
29+
# Add /bin/sh, which we need for Docker imports.
30+
libraries+=('/bin/sh')
31+
32+
mkdir -p "${output_dir}"
33+
34+
# Copy executable and all needed libraries into temporary directory.
35+
cp "${binary_path}" "${output_dir}/${exe_name}"
36+
for lib in "${libraries[@]}"; do
37+
mkdir -p "${output_dir}/$(dirname "$lib")"
38+
# Need -L to make sure we get actual libraries & binaries, not symlinks to
39+
# them.
40+
cp -L "${lib}" "${output_dir}/${lib}"
41+
done

circle.yml

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,32 @@ dependencies:
1313
- go install -tags netgo std
1414
- mkdir -p $(dirname $SRCDIR)
1515
- cp -r $(pwd)/ $SRCDIR
16-
- |
17-
cd $SRCDIR;
18-
go get \
19-
github.com/fzipp/gocyclo \
20-
github.com/golang/lint/golint \
21-
github.com/kisielk/errcheck \
22-
gopkg.in/mvdan/sh.v1/cmd/shfmt
2316

2417
test:
2518
override:
26-
- cd $SRCDIR; ./lint .
19+
- |
20+
cd $SRCDIR/build && \
21+
make && \
22+
docker run --rm -v "$SRCDIR:$SRCDIR" -w "$SRCDIR" --entrypoint sh quay.io/weaveworks/build-golang -c ./lint .
2723
- cd $SRCDIR/cover; make
2824
- cd $SRCDIR/socks; make
2925
- cd $SRCDIR/runner; make
3026

27+
deployment:
28+
snapshot:
29+
branch: master
30+
commands:
31+
- docker login -e "$DOCKER_REGISTRY_EMAIL" -u "$DOCKER_REGISTRY_USER" -p "$DOCKER_REGISTRY_PASS" "$DOCKER_REGISTRY_URL"
32+
- |
33+
cd $SRCDIR/build;
34+
for image in $(make images); do
35+
# Tag the built images with the revision of this repo.
36+
docker push "${image}:${GIT_TAG}"
37+
38+
# Tag the built images with something derived from the base images in
39+
# their respective Dockerfiles. So "FROM golang:1.8.0-stretch" as a
40+
# base image would lead to a tag of "1.8.0-stretch"
41+
IMG_TAG=$(make "imagetag-${image#quay.io/weaveworks/build-}")
42+
docker tag "${image}:latest" "${image}:${IMG_TAG}"
43+
docker push "${image}:${IMG_TAG}"
44+
done

0 commit comments

Comments
 (0)