From c3f6bc8b26772cc137c9f555f5c462548ccdec70 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 e442e41633c5aefbc37eee1b775c276b5611c13c 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 dd5398c9329e791203bfbf6fbbad529b0a549da8 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 3f6330d6ad596de26074c41df039a27855e5fc14 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 bc3fcda980736d1d83229ab0d52579ae15bb83e3 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 07dcf673c863d93d7d9985388365f95e7673ffcb 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 e990f34d6b59fbcdf9b092f08f5230c3a9f6ff9e 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: