No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Makefile 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. SHELL := /bin/bash
  2. GRADLE := $(shell command -v gradle)
  3. BLUBBER := $(shell command -v blubber)
  4. DOCKER := $(shell command -v docker)
  5. DOCKER_TAG := piplinelib-tests-$(shell date -u +%Y%m%d-%H%M%S)
  6. DOCKER_LABEL := wmf.gc=pipelinelib-tests
  7. DOCKER_BUILD := docker build --label $(DOCKER_LABEL) --tag $(DOCKER_TAG)
  8. DOCKER_RUN := docker run --rm --label $(DOCKER_LABEL) --name $(DOCKER_TAG)
  9. DOCKER_STOP := docker stop "$(DOCKER_TAG)"
  10. DOCKER_STOP_ALL = docker stop $(shell docker ps -qf label=$(DOCKER_LABEL))
  11. DOCKER_RMI = docker rmi $(shell docker images -qf label=$(DOCKER_LABEL))
  12. .PHONY: test
  13. clean:
  14. ifneq (,$(DOCKER))
  15. $(DOCKER_STOP_ALL) 2> /dev/null || true
  16. $(DOCKER_RMI) 2> /dev/null || true
  17. else
  18. @echo "Not using Docker. Nothing to do."
  19. endif
  20. doc: docs
  21. docs:
  22. gradle groovydoc
  23. test:
  24. ifneq (,$(GRADLE))
  25. gradle test
  26. @exit 0
  27. else ifneq (,$(and $(BLUBBER), $(DOCKER)))
  28. blubber .pipeline/blubber.yaml test | docker build -t "$(DOCKER_TAG)" -f - .
  29. docker run --rm -it "$(DOCKER_TAG)"
  30. @exit 0
  31. else
  32. @echo "Can't find Gradle or Blubber/Docker. Install one to run tests."
  33. @exit 1
  34. endif
  35. systemtest:
  36. ifneq (,$(and $(DOCKER), $(DOCKER_HOST)))
  37. $(eval JENKINS_HOST := $(patsubst tcp://%,%,$(DOCKER_HOST)))
  38. $(eval JENKINS_HOST := $(word 1, $(subst :, ,$(JENKINS_HOST))))
  39. $(eval JENKINS_URL := http://docker:docker@$(JENKINS_HOST):8080)
  40. $(eval JENKINS_BLUE_URL := $(JENKINS_URL)/blue/organizations/jenkins)
  41. $(eval BUILD_OUTPUT := $(shell mktemp))
  42. $(DOCKER_BUILD) -f systemtests/jenkins/Dockerfile .
  43. $(DOCKER_RUN) -d \
  44. -p 8080:8080 \
  45. -v /var/run/docker.sock:/var/run/docker.sock \
  46. $(DOCKER_TAG)
  47. @while ! curl -s http://$(JENKINS_HOST):8080/ > /dev/null; do \
  48. echo "waiting for jenkins..."; \
  49. sleep 1; \
  50. done
  51. @while curl -s http://$(JENKINS_HOST):8080/ | grep -q "is getting ready to work"; do \
  52. echo "waiting for jenkins..."; \
  53. sleep 1; \
  54. done
  55. curl -X POST $(JENKINS_URL)/job/repo1/build
  56. @echo "Build $(JENKINS_URL)/job/repo1/1 created"
  57. @while curl -sw %%{http_code} $(JENKINS_URL)/job/repo1/1/api/json | grep -q '404'; do \
  58. echo "waiting for build to start..."; \
  59. sleep 1; \
  60. done
  61. @while curl -s $(JENKINS_URL)/job/repo1/1/api/json | grep -q '"building":true'; do \
  62. sleep 1; \
  63. curl -s $(JENKINS_URL)/job/repo1/1/consoleText | \
  64. tail -n +$$(wc -l $(BUILD_OUTPUT) | awk '{ print $$1 }') | \
  65. tee -a $(BUILD_OUTPUT); \
  66. done
  67. ifeq (1,$(DEBUG))
  68. @echo "DEBUG: Build $(JENKINS_URL)/job/repo1/1 completed"
  69. @echo -n "DEBUG: Press <enter> to continue: "
  70. @read
  71. endif
  72. $(DOCKER_STOP)
  73. else
  74. @echo "Can't find Docker and your DOCKER_HOST. Set up both to run system tests."
  75. @exit 1
  76. endif