From 94f970b1c5aa7879832be5ee8d51b025c43a82ef Mon Sep 17 00:00:00 2001 From: ein Date: Sun, 30 Jan 2022 10:31:54 -0800 Subject: [PATCH 1/7] Adding a lint phase to the ci/cd pipeline. This should fail because animals.py is not formatted properly according to black --- .gitlab-ci.yml | 10 ++++++++++ app/animals.py | 4 +--- 2 files changed, 11 insertions(+), 3 deletions(-) mode change 100755 => 100644 app/animals.py diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d2b7e2c4..467c4bd8 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -9,8 +9,18 @@ variables: DOCKER_DRIVER: overlay2 stages: + - test - deploy + +lint_python_on_merge_request: + image: python:alpine + stage: test + script: + - echo "Linting Python code" + - pip install black && black --fast --check . + + build_and_push_container: stage: deploy script: diff --git a/app/animals.py b/app/animals.py old mode 100755 new mode 100644 index 402d5607..4c7b6161 --- a/app/animals.py +++ b/app/animals.py @@ -9,9 +9,7 @@ import get_from_reddit def get_red_panda(): red_panda = None while not red_panda: - red_panda = requests.get("https://some-random-api.ml/img/red_panda").json()[ - "link" - ] + red_panda = requests.get("https://some-random-api.ml/img/red_panda").json()["link"] return red_panda From 8b1c0ee2a345b41da81f46ae8c3fd660fe516d24 Mon Sep 17 00:00:00 2001 From: ein Date: Sun, 30 Jan 2022 10:33:36 -0800 Subject: [PATCH 2/7] Making pip quiet --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 467c4bd8..5635ee97 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,7 @@ lint_python_on_merge_request: stage: test script: - echo "Linting Python code" - - pip install black && black --fast --check . + - pip install -q black && black --fast --check . build_and_push_container: From 839c6f18cf283c88acda95b1342749779a4ea714 Mon Sep 17 00:00:00 2001 From: ein Date: Sun, 30 Jan 2022 10:34:19 -0800 Subject: [PATCH 3/7] Making pip quiet --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5635ee97..39a38943 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,7 @@ lint_python_on_merge_request: stage: test script: - echo "Linting Python code" - - pip install -q black && black --fast --check . + - pip install --upgrade -q pip && pip install -q black && black --fast --check . build_and_push_container: From 747e1318d4f94628c7c2e25c4fea359f6469dabc Mon Sep 17 00:00:00 2001 From: ein Date: Sun, 30 Jan 2022 10:36:28 -0800 Subject: [PATCH 4/7] Adding pip install --user --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 39a38943..476b6d79 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,7 @@ lint_python_on_merge_request: stage: test script: - echo "Linting Python code" - - pip install --upgrade -q pip && pip install -q black && black --fast --check . + - pip install --upgrade --user -q pip && pip install --user -q black && black --fast --check . build_and_push_container: From f029efc8fb5bdf2f892c6069f81607ca8f8c2231 Mon Sep 17 00:00:00 2001 From: ein Date: Sun, 30 Jan 2022 10:37:34 -0800 Subject: [PATCH 5/7] Removing --user --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 476b6d79..39a38943 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -18,7 +18,7 @@ lint_python_on_merge_request: stage: test script: - echo "Linting Python code" - - pip install --upgrade --user -q pip && pip install --user -q black && black --fast --check . + - pip install --upgrade -q pip && pip install -q black && black --fast --check . build_and_push_container: From 5f78ebe9c15ae63603b310479c026b01c9b948d9 Mon Sep 17 00:00:00 2001 From: ein Date: Sun, 30 Jan 2022 10:38:15 -0800 Subject: [PATCH 6/7] formatting animals.py so that the CI/cd pipeline passes --- app/animals.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/animals.py b/app/animals.py index 4c7b6161..402d5607 100644 --- a/app/animals.py +++ b/app/animals.py @@ -9,7 +9,9 @@ import get_from_reddit def get_red_panda(): red_panda = None while not red_panda: - red_panda = requests.get("https://some-random-api.ml/img/red_panda").json()["link"] + red_panda = requests.get("https://some-random-api.ml/img/red_panda").json()[ + "link" + ] return red_panda From e101b5461ce9a59e3dbe4036d9c4c282780a4eb8 Mon Sep 17 00:00:00 2001 From: ein Date: Sun, 30 Jan 2022 10:42:08 -0800 Subject: [PATCH 7/7] Removign new line from gitlab-ci.yaml --- .gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 39a38943..159d8343 100755 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -20,7 +20,6 @@ lint_python_on_merge_request: - echo "Linting Python code" - pip install --upgrade -q pip && pip install -q black && black --fast --check . - build_and_push_container: stage: deploy script: