From 24c89ff5bbaee7a6937a736fb0c453daa915b359 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 17 Aug 2017 12:29:44 -0700 Subject: [PATCH 01/14] Blocking pushes to master --- test-dragon-bot.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test-dragon-bot.sh b/test-dragon-bot.sh index 1867bc89..c26395ec 100755 --- a/test-dragon-bot.sh +++ b/test-dragon-bot.sh @@ -1,3 +1,25 @@ +# Add the git hooks to the local repo. This prevents pushes on master +SCRIPTDIR="$(dirname "$0")" +HOOKDIR="$SCRIPTDIR/.git/hooks" +SCRIPT="$HOOKDIR/pre-push" +cat << EOF > $SCRIPT +#!/bin/bash +protected_branch='master' +# check each branch being pushed +while read local_ref local_sha remote_ref remote_sha +do + remote_branch=$(echo $remote_ref | sed -e 's,.*/\(.*\),\1,') + if [ $protected_branch = $remote_branch ] + then + echo "ABORT PUSH: Not allowed to push directly to $protected_branch. Use --no-verify to force." + exit 1 # push will not execute + fi +done +exit 0 +EOF + +chmod +x $SCRIPT + # Remove the running container so we cna re-use the container name 'dragon-bot' printf "\n[-] Deleting old dragon-bot container from system\n" docker rm -f dragon-bot-test From 9021a4e45986058c1b25ae2f87030b1fd42df432 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 17 Aug 2017 16:21:08 -0700 Subject: [PATCH 02/14] Adding pipeline.yml file --- .gitlab-ci.yml | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 00000000..6276782b --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,34 @@ +image: python:3.6.2-alpine3.6 +services: + - dragon-bot + +before_script: + - pip install pylint + +stages: + - test + - build + - deploy + +linting_python: + stage: test + script: + - pylint app/*.py + only: + - /.*/ + tags: + - docker + +building_docker_container: + stage: build + script: + - docker build -t dragon-bot:latest . + only: + - master + +pushing_docker_container: + stage: deploy + script: + - docker push ldooks/dragon-bot:latest + only: + - master \ No newline at end of file From 0ce3d5df580f021b34ee6121f973a6f828e3bc0d Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 17 Aug 2017 16:22:02 -0700 Subject: [PATCH 03/14] Adding pipeline.yml file --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6276782b..fd436c31 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,7 @@ linting_python: building_docker_container: stage: build script: - - docker build -t dragon-bot:latest . + - docker build -t ldooks/dragon-bot:latest . only: - master From fe24e28e286a26f044e33e37dbb7451854341be0 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 17 Aug 2017 16:23:37 -0700 Subject: [PATCH 04/14] Adding pipeline.yml file --- .gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fd436c31..be1b6f5d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,4 @@ image: python:3.6.2-alpine3.6 -services: - - dragon-bot before_script: - pip install pylint From 9c40975d26c9cd29f6a2572e417ab32c76b86253 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 17 Aug 2017 16:24:29 -0700 Subject: [PATCH 05/14] only lint for python errors --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index be1b6f5d..8f57619b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,7 +11,7 @@ stages: linting_python: stage: test script: - - pylint app/*.py + - pylint -E app/*.py only: - /.*/ tags: From e918b095a663d39b95979e3f6f7dff3007309349 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 17 Aug 2017 16:25:57 -0700 Subject: [PATCH 06/14] Add all necessary python modules for linting --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8f57619b..0421c824 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,7 +1,7 @@ image: python:3.6.2-alpine3.6 before_script: - - pip install pylint + - pip install pylint requests discord.py docker pybooru pylint wolframalpha stages: - test From d0e583236c051203cfe0e325a4e3c73bde7bde4f Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 17 Aug 2017 16:30:59 -0700 Subject: [PATCH 07/14] trying with docker in docker image --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0421c824..ab38690c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,6 @@ -image: python:3.6.2-alpine3.6 +image: docker:latest +services: + - docker:dind before_script: - pip install pylint requests discord.py docker pybooru pylint wolframalpha From 47808e4fdf4389c027d5e07bb0997b88b1958b54 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 17 Aug 2017 16:36:55 -0700 Subject: [PATCH 08/14] trying pipelines again --- .gitlab-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ab38690c..f28a9b44 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,7 +3,8 @@ services: - docker:dind before_script: - - pip install pylint requests discord.py docker pybooru pylint wolframalpha + - apk add --no-cache python3 + - pip3 install pylint requests discord.py docker pybooru pylint wolframalpha stages: - test @@ -29,6 +30,7 @@ building_docker_container: pushing_docker_container: stage: deploy script: + - docker login -u ldooks -p $docker_hub_password - docker push ldooks/dragon-bot:latest only: - master \ No newline at end of file From 9c75b2b5a66d40498bde3a3298bfe8a1494e8e3f Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 17 Aug 2017 16:44:39 -0700 Subject: [PATCH 09/14] Updating docker password variable --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f28a9b44..d0a936a5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,7 @@ building_docker_container: pushing_docker_container: stage: deploy script: - - docker login -u ldooks -p $docker_hub_password + - docker login -u ldooks -p $DOCKER_PASSWORD - docker push ldooks/dragon-bot:latest only: - master \ No newline at end of file From cc91a1151b653ca27d0a7653841fefa4a8566d2a Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 17 Aug 2017 16:46:15 -0700 Subject: [PATCH 10/14] updating build step tags --- .gitlab-ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d0a936a5..38890c35 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,7 @@ linting_python: only: - /.*/ tags: - - docker + - python building_docker_container: stage: build @@ -26,6 +26,8 @@ building_docker_container: - docker build -t ldooks/dragon-bot:latest . only: - master + tags: + - docker pushing_docker_container: stage: deploy @@ -33,4 +35,6 @@ pushing_docker_container: - docker login -u ldooks -p $DOCKER_PASSWORD - docker push ldooks/dragon-bot:latest only: - - master \ No newline at end of file + - master + tags: + - docker \ No newline at end of file From 8285dbb92ecf9b4063c32e358718146d878189cd Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 17 Aug 2017 16:51:42 -0700 Subject: [PATCH 11/14] Try with build and deploy as one step --- .gitlab-ci.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 38890c35..62b3be29 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,7 +8,6 @@ before_script: stages: - test - - build - deploy linting_python: @@ -20,19 +19,11 @@ linting_python: tags: - python -building_docker_container: +build_and_push_container: stage: build - script: - - docker build -t ldooks/dragon-bot:latest . - only: - - master - tags: - - docker - -pushing_docker_container: - stage: deploy script: - docker login -u ldooks -p $DOCKER_PASSWORD + - docker build -t ldooks/dragon-bot:latest . - docker push ldooks/dragon-bot:latest only: - master From 858e6b11b0214a99fb66d79e72af7d9ec37068f7 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 17 Aug 2017 16:52:53 -0700 Subject: [PATCH 12/14] Fix paramenter --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 62b3be29..de961c85 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,7 +20,7 @@ linting_python: - python build_and_push_container: - stage: build + stage: deploy script: - docker login -u ldooks -p $DOCKER_PASSWORD - docker build -t ldooks/dragon-bot:latest . From b8542dd75532d2218cef76cd4fbbf5d8415a35ef Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 17 Aug 2017 16:53:40 -0700 Subject: [PATCH 13/14] Fix runner tag --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index de961c85..5f6d2130 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -17,7 +17,7 @@ linting_python: only: - /.*/ tags: - - python + - docker build_and_push_container: stage: deploy From a6d0946f50e8c23b09da944bfdfea05f25db9119 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Fri, 18 Aug 2017 00:01:07 +0000 Subject: [PATCH 14/14] Delete bitbucket-pipelines.yml --- bitbucket-pipelines.yml | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 bitbucket-pipelines.yml diff --git a/bitbucket-pipelines.yml b/bitbucket-pipelines.yml deleted file mode 100644 index 82c6fb47..00000000 --- a/bitbucket-pipelines.yml +++ /dev/null @@ -1,32 +0,0 @@ -# This is a sample build configuration for Docker. -# Check our guides at https://confluence.atlassian.com/x/O1toN for more examples. -# Only use spaces to indent your .yml configuration. -# ----- -# You can specify a custom docker image from Docker Hub as your build environment. -# image: atlassian/default-image:latest - -# enable Docker for your repository -options: - docker: true - -image: python:3.6.2 -pipelines: - default: - - step: - script: - - echo "Making sure the python actually runs" - - pip install docker discord.py pybooru requests pylint - - python dragon-bot.py test - - export IMAGE_NAME=ldooks/dragon-bot:latest - # build the Docker image (this will use the Dockerfile in the root of the repo) - - docker build -t $IMAGE_NAME . - branches: - master: - - step: - script: - - export IMAGE_NAME=ldooks/dragon-bot:latest - - docker build -t $IMAGE_NAME . - # authenticate with the Docker Hub registry - - docker login --username $DOCKER_HUB_USERNAME --password $DOCKER_HUB_PASSWORD - # push the new Docker image to the Docker registry - - docker push $IMAGE_NAME \ No newline at end of file