Skip to content

Commit

Permalink
Makefile: run 00-fmt as part of build process
Browse files Browse the repository at this point in the history
A couple of changes were made so that we  can detect formatting issues
before building anything and error out early. Mainly there are three new
targets. Two of them are for checking and reformatting code.  The third
one is for splitting building and formatting.  Since the docker scripts
doesn't add any tests files, calling the formatting target would cause a
failure. Using the build target prevents this and behaves the same way
the all target did before.

Closes: #1445 (Run gofmt as part of the regular build)
Signed-off-by: Alexander Alemayhu <alexander@alemayhu.com>
  • Loading branch information
aalemayhu authored and tgraf committed Sep 2, 2017
1 parent 8bfca7f commit 3ab2ea9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Expand Up @@ -65,7 +65,7 @@ cd /tmp/cilium-net-build/src/github.com/cilium/cilium && \
export GOROOT=/usr/local/go && \
export GOPATH=/tmp/cilium-net-build && \
export PATH="$GOROOT/bin:/usr/local/clang+llvm/bin:$GOPATH/bin:$PATH" && \
make clean-container all && \
make clean-container build && \
make PKG_BUILD=1 install && \
groupadd -f cilium && \

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.dev
Expand Up @@ -6,7 +6,7 @@ RUN cd /tmp/cilium-net-build/src/github.com/cilium/cilium && \
export GOROOT=/usr/local/go && \
export GOPATH=/tmp/cilium-net-build && \
export PATH="$GOROOT/bin:/usr/local/clang+llvm/bin:$GOPATH/bin:$PATH" && \
make clean-container all && \
make clean-container build && \
make PKG_BUILD=1 install && \
groupadd -f cilium
ADD plugins/cilium-cni/cni-install.sh /cni-install.sh
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Expand Up @@ -6,7 +6,9 @@ GOLANGVERSION = $(shell go version 2>/dev/null | grep -Eo '(go[0-9].[0-9])')

GOTEST_OPTS = -test.v -check.v

all: $(SUBDIRS)
all: precheck-gofmt build

build: $(SUBDIRS)

$(SUBDIRS): force
@ $(MAKE) -C $@ all
Expand Down Expand Up @@ -125,6 +127,11 @@ release:
git tag v$(VERSION)
git archive --format tar $(BRANCH) | gzip > ../cilium_$(VERSION).orig.tar.gz

gofmt:
for pkg in $(GOFILES); do go fmt $$pkg; done

precheck-gofmt:
tests/00-fmt.sh

.PHONY: force
force :;
2 changes: 1 addition & 1 deletion contrib/packaging/docker/build_dockerfile.sh
Expand Up @@ -25,7 +25,7 @@ cd /tmp/cilium-net-build/src/github.com/cilium/cilium && \\
export GOROOT=/usr/local/go && \\
export GOPATH=/tmp/cilium-net-build && \\
export PATH="\$GOROOT/bin:/usr/local/clang+llvm/bin:\$GOPATH/bin:\$PATH" && \\
make clean-container all && \\
make clean-container build && \\
make PKG_BUILD=1 install && \\
groupadd -f cilium
EOF
Expand Down

0 comments on commit 3ab2ea9

Please sign in to comment.