From a67d265951973d20d167acb05d02a3a06bdf96c4 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 67b09403b1d116c8561e93807e558c2a56764b73 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 6d6aa003c60869316fceb341b32a0bacf1617371 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 ee2fa5bcd52e236dabf5bc54ab216b82724ea0f0 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 6d04ad8b86af2d87202aa6e2b9dc1bdf42a25ea2 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 337252a2e2e4386b306c4305cfbb92c774c83ffd 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 8169595fd4c142168726e32e6ff795bcecbb0d69 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: