Skip to content

Commit

Permalink
Initial travis CI integration
Browse files Browse the repository at this point in the history
  • Loading branch information
Claes Mogren committed Jun 25, 2018
1 parent 16bf723 commit 67b24bd
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 277 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ aws-cni
verify-aws
verify-network
*~
.idea/
*.iml
.DS_Store
30 changes: 30 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This is how to tell Travis to use the fast container-based test
# runner instead of the slow VM-based one.
sudo: false

language: go

# Only the last two Go releases are supported by the Go team with security updates.
# Any older versions are considered deprecated.
go:
- "1.10.x"
- "1.9.x"

# Only clone the most recent commit.
git:
depth: 1

go_import_path: github.com/aws/amazon-vpc-cni-k8s

# Install needed tools
install:
- go get -u github.com/golang/dep/cmd/dep
- go get -u golang.org/x/lint/golint
- dep ensure

# Tests to run
script:
- make build-linux
- make lint
- make vet
- make unit-test
37 changes: 21 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,36 @@
# language governing permissions and limitations under the License.
#

# build binary
static:
go build -o aws-k8s-agent main.go
go build -o aws-cni plugins/routed-eni/cni.go
go build verify-aws.go
go build verify-network.go
.PHONY: build-linux clean docker docker-build lint unit-test vet

# Default to build the Linux binary
build-linux:
GOOS=linux CGO_ENABLED=0 go build -o aws-k8s-agent
GOOS=linux CGO_ENABLED=0 go build -o aws-cni ./plugins/routed-eni/

docker-build:
docker run -v $(shell pwd):/usr/src/app/src/github.com/aws/amazon-vpc-cni-k8s \
--workdir=/usr/src/app/src/github.com/aws/amazon-vpc-cni-k8s \
--env GOPATH=/usr/src/app \
golang:1.10 make static
golang:1.10 make build-linux


# build docker image
# Build docker image
docker: docker-build
@docker build -f scripts/dockerfiles/Dockerfile.release -t "amazon/amazon-k8s-cni:latest" .
@echo "Built Docker image \"amazon/amazon-k8s-cni:latest\""

# unit-test
unit-test:
go test -v -cover -race -timeout 150s ./pkg/awsutils/...
go test -v -cover -race -timeout 10s ./plugins/routed-eni/...
go test -v -cover -race -timeout 10s ./plugins/routed-eni/driver
go test -v -cover -race -timeout 10s ./pkg/k8sapi/...
go test -v -cover -race -timeout 10s ./pkg/networkutils/...
go test -v -cover -race -timeout 10s ./ipamd/...

#golint
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 150s ./pkg/awsutils/...
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 10s ./plugins/routed-eni/...
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 10s ./plugins/routed-eni/driver
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 10s ./pkg/k8sapi/...
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 10s ./pkg/networkutils/...
GOOS=linux CGO_ENABLED=1 go test -v -cover -race -timeout 10s ./ipamd/...

# golint
# To install: go get -u golang.org/x/lint/golint
lint:
golint pkg/awsutils/*.go
golint plugins/routed-eni/*.go
Expand All @@ -56,3 +57,7 @@ vet:
go tool vet ./plugins/routed-eni
go tool vet ./pkg/k8sapi
go tool vet ./pkg/networkutils

clean:
rm -f aws-k8s-agent
rm -f aws-cni
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ L-IPAM requires following [IAM policy](https://docs.aws.amazon.com/IAM/latest/Us

## Building

* `make static` builds the binary files
* `make` defaults to `make build-linux` that builds the Linux binaries.
* `make docker-build` uses a docker container (golang:1.10) to build the binaries.
* `make docker` will create a docker container using the docker-build with the finished binaries, with a tag of `amazon/amazon-k8s-cni:latest`
* `unit-test`, `lint` and `vet` provide ways to run the respective tests/tools and should be run before submitting a PR.
Expand Down
5 changes: 2 additions & 3 deletions plugins/routed-eni/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ import (
const (
ipamDAddress = "localhost:50051"
defaultLogFilePath = "/var/log/aws-routed-eni/plugin.log"
maxVethNameLen = 10
)

// NetConf stores the common network config for CNI plugin
// NetConf stores the common network config for the CNI plugin
type NetConf struct {
// CNIVersion is the version pluging
// CNIVersion is the plugin version
CNIVersion string `json:"cniVersion,omitempty"`

// Name is the plugin name
Expand Down
2 changes: 1 addition & 1 deletion rpc/rpc.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";

package rpc;;
package rpc;

// The service definition.
service CNIBackend {
Expand Down
1 change: 1 addition & 0 deletions scripts/install-aws.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env bash
echo "=====Starting installing AWS-CNI ========="
sed -i s/__VETHPREFIX__/${AWS_VPC_K8S_CNI_VETHPREFIX:-"eni"}/g /app/aws.conf
cp /app/aws-cni /host/opt/cni/bin/
Expand Down
152 changes: 0 additions & 152 deletions verify-aws.go

This file was deleted.

104 changes: 0 additions & 104 deletions verify-network.go

This file was deleted.

0 comments on commit 67b24bd

Please sign in to comment.