From 6244e5567edad2a4a7262fdc31766006d83f5c34 Mon Sep 17 00:00:00 2001 From: Luke Robles 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 26662efeaeca0878d0c14f352bede2125c0a619a Mon Sep 17 00:00:00 2001 From: Luke Robles 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 1fbc7b16192f520ac1d774a2f50d9ee38d115708 Mon Sep 17 00:00:00 2001 From: Luke Robles 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 6d388d55b19e103b2e62bceb9ea111b764e4039e Mon Sep 17 00:00:00 2001 From: Luke Robles 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 8803bfdce530d9ba94e0e3462475f2e40122685a Mon Sep 17 00:00:00 2001 From: Luke Robles 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 ca57fa9822dd04cda4b78cb049f0dff8b01f7952 Mon Sep 17 00:00:00 2001 From: Luke Robles 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 95bec785b13ae0c23f0b560ab04b26dd52104061 Mon Sep 17 00:00:00 2001 From: Luke Robles 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: