Skip to content

Commit

Permalink
Merge branch 'travis-centos' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
mtrmac committed Aug 5, 2016
2 parents b1b8ecd + 286da39 commit c44991a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ notifications:
email: false

script:
- make check
- make check CHECK_BASE_IMAGES='fedora centos' SKIP_GOLINT_IF_MISSING=1
16 changes: 11 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM fedora

RUN dnf -y update && dnf install -y make git golang golang-github-cpuguy83-go-md2man \
RUN if (. /etc/os-release ; [ "$ID" != centos ]); then dnf=dnf; else dnf=yum; $dnf install -y epel-release; fi \
&& $dnf -y update && $dnf install -y make git golang golang-github-cpuguy83-go-md2man \
# gpgme bindings deps
libassuan-devel gpgme-devel \
gnupg \
Expand All @@ -11,6 +12,7 @@ RUN dnf -y update && dnf install -y make git golang golang-github-cpuguy83-go-md
swig \
redhat-rpm-config \
openssl-devel \
m2crypto \
patch

# Install three versions of the registry. The first is an older version that
Expand All @@ -31,14 +33,15 @@ RUN set -x \
&& rm -rf "$GOPATH" \
&& export DRV1="$(mktemp -d)" \
&& git clone https://github.com/docker/docker-registry.git "$DRV1" \
# drop M2Crypto dependency, that one does not build with just pip on CentOS, and we have a newer version in the distribution anyway.
&& sed -i.nom2 /M2Crypto==0.22.3/d "$DRV1/requirements/main.txt" \
# no need for setuptools since we have a version conflict with fedora
&& sed -i.bak s/setuptools==5.8//g "$DRV1/requirements/main.txt" \
&& sed -i.bak s/setuptools==5.8//g "$DRV1/depends/docker-registry-core/requirements/main.txt" \
&& pip install "$DRV1/depends/docker-registry-core" \
&& pip install file://"$DRV1#egg=docker-registry[bugsnag,newrelic,cors]" \
&& patch $(python -c 'import boto; import os; print os.path.dirname(boto.__file__)')/connection.py \
< "$DRV1/contrib/boto_header_patch.diff" \
&& dnf -y update && dnf install -y m2crypto
< "$DRV1/contrib/boto_header_patch.diff"

RUN set -x \
&& yum install -y which git tar wget hostname util-linux bsdtar socat ethtool device-mapper iptables tree findutils nmap-ncat e2fsprogs xfsprogs lsof docker iproute \
Expand All @@ -51,10 +54,13 @@ RUN set -x \
&& cp "$GOPATH/src/github.com/openshift/origin/images/dockerregistry/config.yml" /atomic-registry-config.yml \
&& mkdir /registry

ENV GOPATH /usr/share/gocode:/go
ENV GOPATH /usr/share/gocode:/go:/go/src/github.com/projectatomic/skopeo/vendor
ENV PATH $GOPATH/bin:/usr/share/gocode/bin:$PATH
RUN go get github.com/golang/lint/golint
# golint does not build against Go 1.4, and vet is not included in the package.
RUN if go version | grep -qF 'go1.4'; then yum install -y golang-vet ; else go get github.com/golang/lint/golint ; fi
WORKDIR /go/src/github.com/projectatomic/skopeo
COPY . /go/src/github.com/projectatomic/skopeo
# Go 1.4 does not support GO15VENDOREXPERIMENT; emulate by using GOPATH pointing to the vendor directory, and making vendor/src == vendor
RUN { ! go version | grep -qF 'go1.4' ; } || { rm -rf vendor/src; ln -s . vendor/src ; }

#ENTRYPOINT ["hack/dind"]
55 changes: 36 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,25 @@ MANINSTALLDIR=${PREFIX}/share/man
#BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions

GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null)
DOCKER_IMAGE := skopeo-dev$(if $(GIT_BRANCH),:$(GIT_BRANCH))
# Default Docker base image on which to run tests
DEFAULT_BASE := fedora
# Base image for most commands, overridable by command-line arguments
BASE_IMAGE := fedora
# Base images (one or more) used for (make check), overridable by command-line arguments
CHECK_BASE_IMAGES := $(BASE_IMAGE)
# Name for our containers: skopeo-dev[-base-image][:branch]
define docker_image_name
skopeo-dev$(if $(filter-out $(DEFAULT_BASE),$1),-$1)$(if $(GIT_BRANCH),:$(GIT_BRANCH))
endef
# set env like gobuildtag?
DOCKER_FLAGS := docker run --rm -i #$(DOCKER_ENVS)
DOCKER_RUN := docker run --rm -i #$(DOCKER_ENVS)
# if this session isn't interactive, then we don't want to allocate a
# TTY, which would fail, but if it is interactive, we do want to attach
# so that the user can send e.g. ^C through.
INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0)
ifeq ($(INTERACTIVE), 1)
DOCKER_FLAGS += -t
DOCKER_RUN += -t
endif
DOCKER_RUN_DOCKER := $(DOCKER_FLAGS) "$(DOCKER_IMAGE)"

GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null || true)

Expand All @@ -38,8 +46,11 @@ skopeo: cmd/skopeo
binary-local:
go build -ldflags "-X main.gitCommit=${GIT_COMMIT}" -o skopeo ./cmd/skopeo

build-container:
docker build ${DOCKER_BUILD_ARGS} -t "$(DOCKER_IMAGE)" .
build-container: build-container-$(BASE_IMAGE)
build-container-%:
dockerfile=$$(mktemp -p .); sed 's/^FROM fedora/FROM $*/' Dockerfile > "$$dockerfile"; \
docker build ${DOCKER_BUILD_ARGS} -f $$dockerfile -t "$(call docker_image_name,$*)" . ; exit=$$?; \
rm "$$dockerfile"; exit $$exit

clean:
rm -f skopeo
Expand All @@ -53,22 +64,28 @@ install-binary:
install -d -m 0755 ${INSTALLDIR}
install -m 755 skopeo ${INSTALLDIR}

shell: shell-$(BASE_IMAGE)
shell-%: build-container-%
$(DOCKER_RUN) "$(call docker_image_name,$*)" bash

shell: build-container
$(DOCKER_RUN_DOCKER) bash

check: validate test-unit test-integration
check: $(foreach image,$(CHECK_BASE_IMAGES),validate-$(image) test-unit-$(image) test-integration-$(image))

test-integration: test-integration-$(BASE_IMAGE)
# The tests can run out of entropy and block in containers, so replace /dev/random.
test-integration: build-container
$(DOCKER_RUN_DOCKER) bash -c 'rm -f /dev/random; ln -sf /dev/urandom /dev/random; SKOPEO_CONTAINER_TESTS=1 hack/make.sh test-integration'

test-unit: build-container
# Just call (make test unit-local) here instead of worrying about environment differences, e.g. GO15VENDOREXPERIMENT.
$(DOCKER_RUN_DOCKER) make test-unit-local

validate: build-container
$(DOCKER_RUN_DOCKER) hack/make.sh validate-git-marks validate-gofmt validate-lint validate-vet
test-integration-%: build-container-%
$(DOCKER_RUN) "$(call docker_image_name,$*)" bash -c 'rm -f /dev/random; ln -sf /dev/urandom /dev/random; SKOPEO_CONTAINER_TESTS=1 hack/make.sh test-integration'

test-unit: test-unit-$(BASE_IMAGE)
# Just call (make test unit-local) here instead of worrying about environment differences, e.g. GO15VENDOREXPERIMENT.
test-unit-%: build-container-%
$(DOCKER_RUN) "$(call docker_image_name,$*)" make test-unit-local

validate: validate-$(BASE_IMAGE)
# SKIP_GOLINT_IF_MISSING can be used to handle CentOS with Go 1.4; this should not be a part of regular development workflow,
# and will be dropped as soon as Go is upgraded.
validate-%: build-container-%
lint=validate-lint; if [ -n "$(SKIP_GOLINT_IF_MISSING)" ] && ! type golint &>/dev/null ; then lint= ; fi; \
$(DOCKER_RUN) "$(call docker_image_name,$*)" hack/make.sh validate-git-marks validate-gofmt $$lint validate-vet

# This target is only intended for development, e.g. executing it from an IDE. Use (make test) for CI or pre-release testing.
test-all-local: validate-local test-unit-local
Expand Down

0 comments on commit c44991a

Please sign in to comment.