- # The targets in this Makefile set up and execute tests inside
- # a Docker container for the given artifact
-
-
- # Paths to build artifacts are based on the locations where EC
- # will provide them, relative to this Makefile.
- # For example, 64-bit Linux p4api.tgz will be provided in:
- # <workspace>/depot/<codeline>/p4-bin/bin.linux26x86_64
- # Whereas this Makefile is in:
- # <workspace>/depot/<codeline>/p4-php/sanity_test/Makefile
- # Therefore, the artifact is available in:
- # ../../p4-bin/bin.linux26x86_64/p4api.tgz
-
-
- # These are the targets EC or Humans call:
-
- p4php7.archive-test : p4php7.archive.ubuntu16 p4php7.archive.centos7
-
-
- # These are the targets that do the work
-
- # Check for programs that tests depend on
- depcheck : check-docker # list dependency-checking targets here
- $(info Dependency check passed)
-
- check-docker : ; $(info ) $(info Checking for Docker) @which docker > /dev/null
-
- # Reusable base images
- # These images are not removed with 'make clean'
- # Docker will use cached images if they exist, thereby speeding up tests
- # and lessening reliance on upstream package servers
-
- p4php7.base.ubuntu16 :
- $(MAKE) p4php7.base.common ORIG_TARGET:=$@
-
- p4php7.base.centos7 :
- $(MAKE) p4php7.base.common ORIG_TARGET:=$@
-
- p4php7.base.common : depcheck
- $(info )
- $(info ########################################)
- $(info # Creating Base Image $(ORIG_TARGET))
- $(info ########################################)
- $(info )
- $(eval BUILDDIR = $(ORIG_TARGET)-build)
- rm -rf $(BUILDDIR)
- mkdir $(BUILDDIR)
- cp Dockerfile.$(ORIG_TARGET) $(BUILDDIR)/Dockerfile
- cd $(BUILDDIR) && docker build -t="$(ORIG_TARGET)" .
- docker images | grep -q $(ORIG_TARGET) && echo "$(ORIG_TARGET) build succeeded"
-
- # TGZ archive of P4PHP source
-
- p4php7.archive.ubuntu16 : p4php7.base.ubuntu16
- $(MAKE) p4php7.archive.common ORIG_TARGET:=$@
-
- p4php7.archive.centos7 : p4php7.base.centos7
- $(MAKE) p4php7.archive.common ORIG_TARGET:=$@
-
- p4php7.archive.common :
- $(info )
- $(info ########################################)
- $(info # Testing $(ORIG_TARGET))
- $(info ########################################)
- $(info )
- $(eval TESTDIR = $(ORIG_TARGET)-test)
- rm -rf $(TESTDIR)
- mkdir $(TESTDIR)
- cp ../../p4-bin/bin.linux26x86_64/p4d $(TESTDIR)
- cp ../../p4-bin/bin.linux26x86_64/p4api.tgz $(TESTDIR)
- cp ../../p4-bin/bin.tools/p4php-php7.tgz $(TESTDIR)
- cp sanity.php $(TESTDIR)
- cp Dockerfile.$(ORIG_TARGET) $(TESTDIR)/Dockerfile
- cd $(TESTDIR) && docker build -t="$(TESTDIR)" .
- docker images | grep -q $(TESTDIR) && echo "$(ORIG_TARGET) test succeeded"
-
-
- # Remove remnants of all targets
- # Leave the base images for reuse
-
- clean :
- $(info )
- $(info ########################################)
- $(info # Removing Dockerfiles and Images)
- $(info ########################################)
- $(info )
- rm -rf *-test *-build
- docker ps -a -q | xargs -rn 1 docker stop
- docker ps -a -q | xargs -rn 1 docker rm
- docker images | grep none | awk '{print $$3}' | xargs -rn 1 docker rmi
- docker images | grep p4php7.archive.ubuntu16-test | awk '{print $$3}' | xargs -rn 1 docker rmi
- docker images | grep p4php7.archive.centos7-test | awk '{print $$3}' | xargs -rn 1 docker rmi
-