From 20357d2a0d504e1ad2d2f647daddedfcc919a30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Mon, 13 Feb 2017 12:04:29 +0100 Subject: [PATCH 01/11] Added gitlab CI --- .gitlab-ci.yml | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++ MANIFEST.in | 3 +- Makefile | 5 ++-- senpy/VERSION | 2 +- 4 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..6225c1c --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,74 @@ +image: docker:latest + + +services: + +# When using dind, it's wise to use the overlayfs driver for +# improved performance. +variables: + DOCKER_DRIVER: overlay + +stages: + - test + - release + - deploy + +.test: &test_definition + variables: + PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache" + cache: + paths: + - .venv/ + - pip-cache/ + key: "$CI_PROJECT_NAME" + stage: test + script: + - pip install virtualenv + - virtualenv -q .venv + - source .venv/bin/activate + - python setup.py test + +test-3.5: + <<: *test_definition + image: python:3.5 + +test-3.4: + <<: *test_definition + image: python:3.4 + +test-2.7: + <<: *test_definition + image: python:2.7 + +.image: &image_definition + stage: release + variables: + IMAGE_NAME: $REGISTRY_IMAGE:$CI_BUILD_TAG + DOCKERFILE: Dockerfile + services: + - docker:dind + before_script: + - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY + script: + - docker build -f $DOCKERFILE . -t $IMAGE_NAME + - docker push $IMAGE_NAME + only: + - tags + - triggers + +image: + <<: *image_definition + only: + - master + +image-3.5: + <<: *image_definition + variables: + IMAGE_NAME: $REGISTRY_IMAGE:$CI_BUILD_TAG-python3.5 + DOCKERFILE: Dockerfile-3.5 + +image-2.7: + <<: *image_definition + variables: + IMAGE_NAME: $REGISTRY_IMAGE:$CI_BUILD_TAG-python2.7 + DOCKERFILE: Dockerfile-2.7 \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in index 10d2ca8..28b33b0 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,6 @@ include requirements.txt include test-requirements.txt -include README.md -include senpy/context.jsonld +include README.rst include senpy/VERSION graft senpy/plugins graft senpy/schemas diff --git a/Makefile b/Makefile index b86fcd9..802bc29 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ REPO=gsiupm VERSION=$(shell cat $(NAME)/VERSION) TARNAME=$(NAME)-$(subst -,.,$(VERSION)).tar.gz IMAGENAME=$(REPO)/$(NAME):$(VERSION) +TEST_COMMAND=gitlab-runner exec docker --cache-dir=/tmp/gitlabrunner --docker-volumes /tmp/gitlabrunner:/tmp/gitlabrunner --env CI_PROJECT_NAME=$(NAME) all: build run @@ -39,8 +40,8 @@ debug-%: debug: debug-$(PYMAIN) -test-%: build-% - docker run --rm -w /usr/src/app/ --entrypoint=/usr/local/bin/python -ti '$(IMAGENAME)-python$*' setup.py test --addopts "-vvv -s" ; +test-%: + $(TEST_COMMAND) test-$* dist/$(TARNAME): docker run --rm -ti -v $$PWD:/usr/src/app/ -w /usr/src/app/ python:$(PYMAIN) python setup.py sdist; diff --git a/senpy/VERSION b/senpy/VERSION index faef31a..967e82c 100644 --- a/senpy/VERSION +++ b/senpy/VERSION @@ -1 +1 @@ -0.7.0 +0.7.1-dev1 From eb3a42c24735b908ecb4ea83ae3532aaa2ab8f0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Mon, 13 Feb 2017 12:30:44 +0100 Subject: [PATCH 02/11] Updated gitlabci --- .gitlab-ci.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6225c1c..1f6a356 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,15 +30,15 @@ stages: test-3.5: <<: *test_definition - image: python:3.5 + image: "python:3.5" test-3.4: <<: *test_definition - image: python:3.4 + image: "python:3.4" test-2.7: <<: *test_definition - image: python:2.7 + image: "python:2.7" .image: &image_definition stage: release @@ -56,7 +56,7 @@ test-2.7: - tags - triggers -image: +image-master: <<: *image_definition only: - master @@ -64,11 +64,11 @@ image: image-3.5: <<: *image_definition variables: - IMAGE_NAME: $REGISTRY_IMAGE:$CI_BUILD_TAG-python3.5 + IMAGE_NAME: "$REGISTRY_IMAGE:$CI_BUILD_TAG-python3.5" DOCKERFILE: Dockerfile-3.5 image-2.7: <<: *image_definition variables: - IMAGE_NAME: $REGISTRY_IMAGE:$CI_BUILD_TAG-python2.7 - DOCKERFILE: Dockerfile-2.7 \ No newline at end of file + IMAGE_NAME: "$REGISTRY_IMAGE:$CI_BUILD_TAG-python2.7" + DOCKERFILE: Dockerfile-2.7 From 673992dbe8be5cb0824d705b6903dab7d058a727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Mon, 13 Feb 2017 17:16:38 +0100 Subject: [PATCH 03/11] Docker dind service made global --- .gitlab-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1f6a356..da1802a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,7 @@ image: docker:latest services: +- docker:dind # When using dind, it's wise to use the overlayfs driver for # improved performance. @@ -45,8 +46,6 @@ test-2.7: variables: IMAGE_NAME: $REGISTRY_IMAGE:$CI_BUILD_TAG DOCKERFILE: Dockerfile - services: - - docker:dind before_script: - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY script: From 5371c83ab0554e67e1dee420b7694ebaf8f4c9a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Mon, 13 Feb 2017 17:35:00 +0100 Subject: [PATCH 04/11] speeding up testing of the CI pipeline --- .gitlab-ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index da1802a..73a9902 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ image: docker:latest services: -- docker:dind + - docker:dind # When using dind, it's wise to use the overlayfs driver for # improved performance. @@ -22,7 +22,7 @@ stages: - .venv/ - pip-cache/ key: "$CI_PROJECT_NAME" - stage: test + stage: deploy script: - pip install virtualenv - virtualenv -q .venv @@ -51,9 +51,9 @@ test-2.7: script: - docker build -f $DOCKERFILE . -t $IMAGE_NAME - docker push $IMAGE_NAME - only: - - tags - - triggers + # only: + # - tags + # - triggers image-master: <<: *image_definition From 39d86a2050fcfb569d29f5846d2378aefa46bfea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Mon, 13 Feb 2017 18:29:38 +0100 Subject: [PATCH 05/11] Configured runner to mount socket --- .gitlab-ci.yml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 73a9902..e7391a4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,13 +1,12 @@ image: docker:latest -services: - - docker:dind - # When using dind, it's wise to use the overlayfs driver for # improved performance. variables: DOCKER_DRIVER: overlay + IMAGE_NAME: $REGISTRY_IMAGE:$CI_BUILD_TAG + DOCKERFILE: Dockerfile stages: - test @@ -43,9 +42,6 @@ test-2.7: .image: &image_definition stage: release - variables: - IMAGE_NAME: $REGISTRY_IMAGE:$CI_BUILD_TAG - DOCKERFILE: Dockerfile before_script: - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY script: @@ -70,4 +66,4 @@ image-2.7: <<: *image_definition variables: IMAGE_NAME: "$REGISTRY_IMAGE:$CI_BUILD_TAG-python2.7" - DOCKERFILE: Dockerfile-2.7 + DOCKERFILE: Dockerfile-2.7 \ No newline at end of file From 068241fb72bb8f6284a77bb321189769aa1c622a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Mon, 13 Feb 2017 18:34:35 +0100 Subject: [PATCH 06/11] CI_REGISTRY_NAME --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e7391a4..1b5a6e5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,7 +5,7 @@ image: docker:latest # improved performance. variables: DOCKER_DRIVER: overlay - IMAGE_NAME: $REGISTRY_IMAGE:$CI_BUILD_TAG + IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_BUILD_TAG DOCKERFILE: Dockerfile stages: From 528bbcac352a18415549efd0cd89462717095576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Mon, 13 Feb 2017 19:41:18 +0100 Subject: [PATCH 07/11] Added gitlab-ci docker build jobs --- .gitlab-ci.yml | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1b5a6e5..02f899d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,13 +5,15 @@ image: docker:latest # improved performance. variables: DOCKER_DRIVER: overlay - IMAGE_NAME: $CI_REGISTRY_IMAGE:$CI_BUILD_TAG DOCKERFILE: Dockerfile +before_script: + - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY + stages: - test + - images - release - - deploy .test: &test_definition variables: @@ -21,7 +23,7 @@ stages: - .venv/ - pip-cache/ key: "$CI_PROJECT_NAME" - stage: deploy + stage: test script: - pip install virtualenv - virtualenv -q .venv @@ -40,30 +42,35 @@ test-2.7: <<: *test_definition image: "python:2.7" -.image: &image_definition - stage: release - before_script: - - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY - script: - - docker build -f $DOCKERFILE . -t $IMAGE_NAME - - docker push $IMAGE_NAME - # only: - # - tags - # - triggers -image-master: - <<: *image_definition +.image: &image_definition + variables: + PYTHON_VERSION: "3.5" + script: + - docker build -f Dockerfile-3.5 . -t $CI_REGISTRY_IMAGE:$CI_BUILD_TAG-$PYTHON_VERSION + - docker push $CI_REGISTRY_IMAGE:$CI_BUILD_TAG-$PYTHON_VERSION + stage: images only: - - master + - tags + - triggers image-3.5: <<: *image_definition variables: - IMAGE_NAME: "$REGISTRY_IMAGE:$CI_BUILD_TAG-python3.5" - DOCKERFILE: Dockerfile-3.5 + PYTHON_VERSION: "3.5" image-2.7: <<: *image_definition variables: - IMAGE_NAME: "$REGISTRY_IMAGE:$CI_BUILD_TAG-python2.7" - DOCKERFILE: Dockerfile-2.7 \ No newline at end of file + PYTHON_VERSION: "2.7" + +image-latest: + stage: release + script: + - docker build -f Dockerfile . -t $CI_REGISTRY_IMAGE + - docker tag $CI_REGISTRY_IMAGE $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG + - docker push $IMAGE_NAME + - docker push $IMAGE_NAME:$CI_BUILD_REF_SLUG + only: + - master + - triggers From 7cc8b562f4eb0b67cd5b5e4eb0bcf05d74abdc2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Mon, 13 Feb 2017 19:43:52 +0100 Subject: [PATCH 08/11] Moved before_script to images --- .gitlab-ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 02f899d..db524a5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,9 +7,6 @@ variables: DOCKER_DRIVER: overlay DOCKERFILE: Dockerfile -before_script: - - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY - stages: - test - images @@ -46,6 +43,8 @@ test-2.7: .image: &image_definition variables: PYTHON_VERSION: "3.5" + before_script: + - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY script: - docker build -f Dockerfile-3.5 . -t $CI_REGISTRY_IMAGE:$CI_BUILD_TAG-$PYTHON_VERSION - docker push $CI_REGISTRY_IMAGE:$CI_BUILD_TAG-$PYTHON_VERSION From 2e3a6b7c846a8ec7b637ba5ae02b96945eabb0a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Mon, 13 Feb 2017 20:07:20 +0100 Subject: [PATCH 09/11] TAGNAME->SLUG and cache in .eggs --- .gitlab-ci.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index db524a5..ce19e8e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,17 +14,13 @@ stages: .test: &test_definition variables: - PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache" + PIP_CACHE_DIR: "$CI_PROJECT_DIR/.eggs" cache: paths: - - .venv/ - - pip-cache/ + - .eggs/ key: "$CI_PROJECT_NAME" stage: test script: - - pip install virtualenv - - virtualenv -q .venv - - source .venv/bin/activate - python setup.py test test-3.5: @@ -46,8 +42,8 @@ test-2.7: before_script: - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY script: - - docker build -f Dockerfile-3.5 . -t $CI_REGISTRY_IMAGE:$CI_BUILD_TAG-$PYTHON_VERSION - - docker push $CI_REGISTRY_IMAGE:$CI_BUILD_TAG-$PYTHON_VERSION + - docker build -f Dockerfile-3.5 . -t $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG-$PYTHON_VERSION + - docker push $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG-$PYTHON_VERSION stage: images only: - tags From 506feec13db2a669d3b8f570d6799d0868213f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Mon, 13 Feb 2017 20:24:10 +0100 Subject: [PATCH 10/11] Fixed docker push --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ce19e8e..b1eb457 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -64,8 +64,8 @@ image-latest: script: - docker build -f Dockerfile . -t $CI_REGISTRY_IMAGE - docker tag $CI_REGISTRY_IMAGE $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG - - docker push $IMAGE_NAME - - docker push $IMAGE_NAME:$CI_BUILD_REF_SLUG + - docker push $CI_REGISTRY_IMAGE + - docker push $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG only: - master - triggers From 6cb669cdb183a1743c4281ae6bdea2109d824f19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Mon, 13 Feb 2017 20:36:12 +0100 Subject: [PATCH 11/11] Added docker auth to docker push job --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b1eb457..6809701 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -61,6 +61,8 @@ image-2.7: image-latest: stage: release + before_script: + - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY script: - docker build -f Dockerfile . -t $CI_REGISTRY_IMAGE - docker tag $CI_REGISTRY_IMAGE $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG @@ -68,4 +70,4 @@ image-latest: - docker push $CI_REGISTRY_IMAGE:$CI_BUILD_REF_SLUG only: - master - - triggers + - triggers \ No newline at end of file