From 08b4f60b50906de569d7455c9e34c434834d8b81 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 95f5a5926977a19147350c1a5bc8db0335d310d6 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 cb3f9b554f4e93a5067b23e5a73943690be22861 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 f105c8e12e132701c6dd8b03ffefb1d38c0b4a7e 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 4e5d05d3e94349da77514febbcb316a67c14ddef 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 686ea884d6d5948d93edc5707bf2e04da9ca79f3 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 12507c0d0eea35347dfd62e6f6f8eb6f2b93abd5 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: