From 93319e874eef817ad41a5ae56940b9a3df5c58ef Mon Sep 17 00:00:00 2001 From: s3lph Date: Tue, 10 Jul 2018 20:25:34 +0200 Subject: [PATCH 1/7] Added a CI job that builds a docker image and pushes it to the project's registry. --- .gitlab-ci.yml | 8 ++++++++ doc | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9adc47d..002cfa4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,6 +4,7 @@ image: s3lph/matemat-ci:20180619-01 stages: - test - codestyle +- deploy test: stage: test @@ -18,3 +19,10 @@ codestyle: - pip3 install -r requirements.txt - pycodestyle matemat # - mypy --ignore-missing-imports --strict -p matemat + +docker_build_push: + stage: deploy + script: + - docker build -t "s3lph/matemat:$(git rev-parse HEAD)" . + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_TOKEN registry.gitlab.com + - docker push registry.gitlab.com/s3lph/matemat diff --git a/doc b/doc index 51e9404..9634785 160000 --- a/doc +++ b/doc @@ -1 +1 @@ -Subproject commit 51e940460ddbaebb7f2ffc48d00d9ef19cf8d33f +Subproject commit 9634785e5621b324f72598b3cee83bbc45c25d7b From 9988ed4ef024c54d9d0b8a0801c5523a250c9b82 Mon Sep 17 00:00:00 2001 From: s3lph Date: Tue, 10 Jul 2018 21:01:33 +0200 Subject: [PATCH 2/7] Added Docker and Git dependency to test image --- .gitlab-ci.yml | 2 +- testing/Dockerfile | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 002cfa4..7b27eca 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ --- -image: s3lph/matemat-ci:20180619-01 +image: s3lph/matemat-ci:20180710-01 stages: - test diff --git a/testing/Dockerfile b/testing/Dockerfile index 126a06f..35e0ca2 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -3,7 +3,8 @@ FROM debian:buster RUN useradd -d /home/matemat -m matemat RUN apt-get update -qy -RUN apt-get install -y --no-install-recommends python3-dev python3-pip python3-coverage python3-setuptools build-essential +RUN apt-get install -y --no-install-recommends git docker.io python3-dev python3-pip python3-coverage python3-setuptools build-essential +RUN usermod -aG docker matemat RUN pip3 install wheel pycodestyle mypy WORKDIR /home/matemat From 4292cf8696a8a355bc1d9a9594e66a1963069f5f Mon Sep 17 00:00:00 2001 From: s3lph Date: Tue, 10 Jul 2018 21:51:42 +0200 Subject: [PATCH 3/7] Run tests as root inside the container. --- .gitlab-ci.yml | 2 +- testing/Dockerfile | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7b27eca..52cb1fa 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ --- -image: s3lph/matemat-ci:20180710-01 +image: s3lph/matemat-ci:20180710-02 stages: - test diff --git a/testing/Dockerfile b/testing/Dockerfile index 35e0ca2..3bf3604 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -1,11 +1,6 @@ FROM debian:buster -RUN useradd -d /home/matemat -m matemat RUN apt-get update -qy RUN apt-get install -y --no-install-recommends git docker.io python3-dev python3-pip python3-coverage python3-setuptools build-essential -RUN usermod -aG docker matemat RUN pip3 install wheel pycodestyle mypy - -WORKDIR /home/matemat -USER matemat From bc19893d90fa8f37bd7bf56a72d6d457e1fc02d8 Mon Sep 17 00:00:00 2001 From: s3lph Date: Tue, 10 Jul 2018 22:08:35 +0200 Subject: [PATCH 4/7] Made unit tests unprivileged again (using sudo) --- .gitlab-ci.yml | 10 +++++----- testing/Dockerfile | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 52cb1fa..441403c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ --- -image: s3lph/matemat-ci:20180710-02 +image: s3lph/matemat-ci:20180710-03 stages: - test @@ -10,15 +10,15 @@ test: stage: test script: - pip3 install -r requirements.txt - - python3-coverage run --branch -m unittest discover matemat - - python3-coverage report -m --include 'matemat/*' --omit '*/test_*.py' + - sudo -u matemat python3-coverage run --branch -m unittest discover matemat + - sudo -u matemat python3-coverage report -m --include 'matemat/*' --omit '*/test_*.py' codestyle: stage: codestyle script: - pip3 install -r requirements.txt - - pycodestyle matemat -# - mypy --ignore-missing-imports --strict -p matemat + - sudp -u matemat pycodestyle matemat +# - sudp -u matemat mypy --ignore-missing-imports --strict -p matemat docker_build_push: stage: deploy diff --git a/testing/Dockerfile b/testing/Dockerfile index 3bf3604..5c0e1b3 100644 --- a/testing/Dockerfile +++ b/testing/Dockerfile @@ -1,6 +1,9 @@ FROM debian:buster +RUN useradd -d /home/matemat -m matemat RUN apt-get update -qy -RUN apt-get install -y --no-install-recommends git docker.io python3-dev python3-pip python3-coverage python3-setuptools build-essential +RUN apt-get install -y --no-install-recommends sudo git docker.io python3-dev python3-pip python3-coverage python3-setuptools build-essential RUN pip3 install wheel pycodestyle mypy + +WORKDIR /home/matemat From 824694c811fcf7a2e373e3f704a67e330e74fd87 Mon Sep 17 00:00:00 2001 From: s3lph Date: Tue, 10 Jul 2018 22:18:57 +0200 Subject: [PATCH 5/7] Fixed typo in Gitlab CI config. --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 441403c..df8e9e5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,8 +17,8 @@ codestyle: stage: codestyle script: - pip3 install -r requirements.txt - - sudp -u matemat pycodestyle matemat -# - sudp -u matemat mypy --ignore-missing-imports --strict -p matemat + - sudo -u matemat pycodestyle matemat +# - sudo -u matemat mypy --ignore-missing-imports --strict -p matemat docker_build_push: stage: deploy From 4b759d724b748ed6c261419e4e63a0d09a5cddd0 Mon Sep 17 00:00:00 2001 From: s3lph Date: Tue, 10 Jul 2018 22:25:56 +0200 Subject: [PATCH 6/7] Fixed docker push command in CI config. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index df8e9e5..78a845e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -25,4 +25,4 @@ docker_build_push: script: - docker build -t "s3lph/matemat:$(git rev-parse HEAD)" . - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_TOKEN registry.gitlab.com - - docker push registry.gitlab.com/s3lph/matemat + - docker push "s3lph/matemat:$(git rev-parse HEAD)" From 873d08e86a82c89db14fa05ac36d7e2de25d071b Mon Sep 17 00:00:00 2001 From: s3lph Date: Tue, 10 Jul 2018 22:33:44 +0200 Subject: [PATCH 7/7] Fixed docker image tag in CI config. --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 78a845e..f89c018 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,6 +23,6 @@ codestyle: docker_build_push: stage: deploy script: - - docker build -t "s3lph/matemat:$(git rev-parse HEAD)" . + - docker build -t "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)" . - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_TOKEN registry.gitlab.com - - docker push "s3lph/matemat:$(git rev-parse HEAD)" + - docker push "registry.gitlab.com/s3lph/matemat:$(git rev-parse HEAD)"