Skip to content

Commit

Permalink
improve CircleCI config; clean up go.mod/go.sum; .dockerignore more f…
Browse files Browse the repository at this point in the history
…iles (#915)
  • Loading branch information
raulk committed Apr 24, 2020
1 parent d7ccdf8 commit a8e5359
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 95 deletions.
138 changes: 62 additions & 76 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,106 +1,92 @@
---
version: 2.1
orbs:
win: circleci/windows@2.4.0

parameters:
go-version:
type: string
default: "1.14.2"
workspace-dir:
type: string
default: "/home/circleci"

commands:
setup:
description: "install go, checkout and restore cache"
steps:
- run:
name: "install go"
command: |
curl --create-dirs -o $GOPATH/go.tar.gz https://dl.google.com/go/go${GOVERSION}.linux-amd64.tar.gz
tar --strip-components=1 -C $GOPATH -xzf $GOPATH/go.tar.gz
rm -rf $GOPATH/go.tar.gz
- checkout
- restore_cache:
keys:
- 'v2-pkg-cache-{{ checksum "go.sum" }}-{{ .Environment.GOVERSION }}'

executors:
linux:
machine:
image: ubuntu-1604:201903-01
docker_layer_caching: true
working_directory: << pipeline.parameters.workspace-dir >>/project
environment:
GOPATH: << pipeline.parameters.workspace-dir >>/go/<< pipeline.parameters.go-version >>
PATH: << pipeline.parameters.workspace-dir >>/go/<< pipeline.parameters.go-version >>/bin:/usr/local/bin:/usr/bin:/bin
GOVERSION: << pipeline.parameters.go-version >>

workflows:
version: 2
test_os:
main:
jobs:
- go-install
- tidy-lint:
- prepare-tidy
- lint:
requires:
- go-install
- test-linux:
- prepare-tidy
- build-test:
requires:
- go-install
- test-windows
- prepare-tidy

jobs:
go-install:
machine:
image: ubuntu-1604:201903-01
prepare-tidy:
executor: linux
steps:
- restore_cache:
keys:
- v1-pkg-cache
- setup
- run:
name: "install go 1.14"
command: |
ls -A ~/go && echo already downloaded. exiting. && exit 0
curl -o ~/go.tar.gz https://dl.google.com/go/go1.14.2.linux-amd64.tar.gz
tar -C ~/ -xzvf ~/go.tar.gz
name: "make tidy"
command: make tidy && git diff --exit-code
- run:
name: "make mod-download"
command: make mod-download
- save_cache:
key: v1-pkg-cache
key: 'v2-pkg-cache-{{ checksum "go.sum" }}-{{ .Environment.GOVERSION }}'
paths:
- ~/go
- << pipeline.parameters.workspace-dir >>/go/<< pipeline.parameters.go-version >>/pkg/mod

tidy-lint:
machine:
image: ubuntu-1604:201903-01
environment:
GOPATH: "/home/circleci/go"
GOROOT: "/home/circleci/go"
GOBIN: "/home/circleci/go/bin"
PATH: "/home/circleci/go/bin:/usr/local/bin:/usr/bin:/bin"
lint:
executor: linux
steps:
- checkout
- restore_cache:
keys:
- v1-pkg-cache
- run:
name: "make tidy"
command: make tidy && git diff --exit-code
- setup
- run:
name: "install linter"
command: go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.23.6
command: "pushd .. && GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.23.6 && popd"
- run:
name: "make lint"
command: make lint
test-linux:
machine:
image: ubuntu-1604:201903-01
docker_layer_caching: true
environment:
GOPATH: "/home/circleci/go"
GOROOT: "/home/circleci/go"
GOBIN: "/home/circleci/go/bin"
PATH: "/home/circleci/go/bin:/usr/local/bin:/usr/bin:/bin"

build-test:
executor: linux
steps:
- checkout
- restore_cache:
keys:
- v1-pkg-cache
- setup
- run:
name: "make build-all"
name: "make build-all"
command: make build-all
- run:
name: "make sidecar"
command: make docker-sidecar
name: "make docker"
command: make docker
- run:
name: "make test"
command: |
mkdir -p $HOME/testground/plans
ln -s $HOME/project/plans/placebo $HOME/testground/plans/placebo
go test -v ./...
# The cache might be updated due to the build. Save it back.
- save_cache:
key: v1-pkg-cache
paths:
- ~/go

# https://circleci.com/docs/2.0/executor-intro/#windows
test-windows:
executor: win/default
steps:
- checkout
- run:
name: "install go 1.14"
command: |
$wc = New-Object System.Net.WebClient
$wc.DownloadFile("https://dl.google.com/go/go1.14.2.windows-amd64.zip", "C:\Users\circleci\go.zip")
unzip.exe -d C:\Users\circleci C:\Users\circleci\go.zip
- run:
name: "test build"
command: |
C:\Users\circleci\go\bin\go.exe build ./...
8 changes: 7 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@
**/.gitkeep
**/.gitmodules
**/Dockerfile
**/infra
**/infra
.circleci
**/*.md
Makefile
LICENSE-*
.env.*
**/*.toml
File renamed without changes.
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ define eachmod
@find . -type f -name go.mod -print0 | xargs -I '{}' -n1 -0 bash -c 'dir="$$(dirname {})" && echo "$${dir}" && cd "$${dir}" && $(1)'
endef

.PHONY: install tidy mod-download lint build-all docker-sidecar install test
.PHONY: install tidy mod-download lint build-all docker install test

install: goinstall docker-sidecar
install: goinstall docker

goinstall:
go install .
Expand All @@ -24,13 +24,18 @@ mod-download:
$(call eachmod,go mod download)

lint:
$(call eachmod,GOGC=75 golangci-lint run --build-tags balsam --concurrency 32 --deadline 4m ./...)
$(call eachmod,GOGC=75 golangci-lint run --concurrency 32 --deadline 4m ./...)

build-all:
$(call eachmod,go build -tags balsam -o /dev/null ./...)
$(call eachmod,go build -o /dev/null ./...)

docker: docker-testground docker-sidecar

docker-sidecar:
docker build -t iptestground/sidecar:edge -f Dockerfile.sidecar .

docker-testground:
docker build -t iptestground/testground:edge -f Dockerfile.testground .

test:
$(call eachmod,go test -tags balsam -p 1 -v $(GOTFLAGS) ./...)
$(call eachmod,go test -p 1 -v $(GOTFLAGS) ./...)
10 changes: 6 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ require (
github.com/BurntSushi/toml v0.3.1
github.com/Microsoft/hcsshim v0.8.7 // indirect
github.com/aws/aws-sdk-go v1.28.9
github.com/containerd/containerd v1.3.2 // indirect
github.com/containerd/continuity v0.0.0-20200107194136-26c1120b8d41 // indirect
github.com/containerd/containerd v1.3.4 // indirect
github.com/containerd/continuity v0.0.0-20200413184840-d3ef23f19fbb // indirect
github.com/containernetworking/cni v0.7.1
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/docker v1.4.2-0.20200206084213-b5fc6ea92cde
Expand All @@ -31,19 +31,21 @@ require (
github.com/morikuni/aec v1.0.0 // indirect
github.com/nwaples/rardecode v1.1.0 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/opencontainers/runc v0.1.1 // indirect
github.com/otiai10/copy v1.0.2
github.com/pborman/uuid v1.2.0
github.com/pierrec/lz4 v2.5.1+incompatible // indirect
github.com/pierrec/lz4 v2.5.2+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/stretchr/testify v1.4.0
github.com/testground/sdk-go v0.1.1
github.com/ulikunitz/xz v0.5.7 // indirect
github.com/urfave/cli v1.22.1
github.com/vishvananda/netlink v1.0.0
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
go.uber.org/zap v1.14.1
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a
google.golang.org/appengine v1.6.5 // indirect
google.golang.org/grpc v1.29.1 // indirect
k8s.io/api v0.17.0
k8s.io/apimachinery v0.17.0
k8s.io/client-go v0.0.0-20190706005506-4ed54556a14a
Expand Down
Loading

0 comments on commit a8e5359

Please sign in to comment.