From 4cb26457d1254c74f40c2358ce53baf360cc45bf Mon Sep 17 00:00:00 2001 From: Iliyan Vutov Date: Wed, 16 Oct 2024 18:29:02 +0300 Subject: [PATCH 001/104] U24 --- .python-version | 1 + app/app.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 .python-version create mode 100644 app/app.py diff --git a/.python-version b/.python-version new file mode 100644 index 000000000..b6d8b7612 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.11.8 diff --git a/app/app.py b/app/app.py new file mode 100644 index 000000000..67e0180c0 --- /dev/null +++ b/app/app.py @@ -0,0 +1,14 @@ +import os + +from flask import Flask + +app = Flask(__name__) + + +@app.route("/") +def hello_world(): + return "Hello, World!" + + +if __name__ == "__main__": + app.run(port=os.environ.get("PORT", 3000), host="0.0.0.0") From ae1daf88d06f2d900bc1b650f9966192246e661b Mon Sep 17 00:00:00 2001 From: Iliyan Vutov Date: Wed, 23 Oct 2024 19:23:42 +0300 Subject: [PATCH 002/104] Add requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..047e9501a --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +Flask==3.0.0 From 63b2492b829944f58a8ffd2e2a5d7d8295b72f8e Mon Sep 17 00:00:00 2001 From: Iliyan Vutov Date: Wed, 23 Oct 2024 19:24:30 +0300 Subject: [PATCH 003/104] Add requirements.txt --- requirements.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 047e9501a..b5ba78cca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,9 @@ -Flask==3.0.0 +blinker==1.6.3 ; python_version >= "3.10" and python_version < "4.0" +click==8.1.7 ; python_version >= "3.10" and python_version < "4.0" +colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows" +flask==3.0.0 ; python_version >= "3.10" and python_version < "4.0" +itsdangerous==2.1.2 ; python_version >= "3.10" and python_version < "4.0" +jinja2==3.1.2 ; python_version >= "3.10" and python_version < "4.0" +markupsafe==2.1.3 ; python_version >= "3.10" and python_version < "4.0" +werkzeug==3.0.0 ; python_version >= "3.10" and python_version < "4.0" + From 05cc45af275c51f499b8203da1d6b20ab95ef833 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Wed, 23 Oct 2024 19:41:41 +0300 Subject: [PATCH 004/104] Practice 1 Dockerfile with python --- Dockerfile | 12 ++++++++++++ requirements.txt | 1 + 2 files changed, 13 insertions(+) create mode 100644 Dockerfile create mode 100644 requirements.txt diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..b7d9b34b8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM ubuntu:22.04 +RUN apt-get update -y && +RUN apt-get upgrade -y && +RUN apt-get install -y python3 +COPY requirements.txt requirements.txt +RUN `pip install -r requirements.txt` +RUN useradd -ms /bin/bash myuser +USER myuser +COPY app /app +WORKDIR /app +EXPOSE 5000 +CMD ["python3", "app.py"] \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..0f800fccf --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +flask==3.0.0 \ No newline at end of file From c20043421950e9e1c87920673ca23971e44a5453 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Wed, 23 Oct 2024 19:47:00 +0300 Subject: [PATCH 005/104] Add missing escape for the pipes --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index b7d9b34b8..d29100469 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:22.04 -RUN apt-get update -y && -RUN apt-get upgrade -y && +RUN apt-get update -y && \ +RUN apt-get upgrade -y && \ RUN apt-get install -y python3 COPY requirements.txt requirements.txt RUN `pip install -r requirements.txt` From 5ba9f55ef90d32f7d963bac1fc081727bbdbcb57 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Wed, 23 Oct 2024 19:48:57 +0300 Subject: [PATCH 006/104] Additional changes to RUN command --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index d29100469..a077783e8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:22.04 RUN apt-get update -y && \ -RUN apt-get upgrade -y && \ -RUN apt-get install -y python3 + apt-get upgrade -y && \ + apt-get install -y python3 COPY requirements.txt requirements.txt RUN `pip install -r requirements.txt` RUN useradd -ms /bin/bash myuser From dc712576cdce12f13e5ba015d893e4aa31ea55bd Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Wed, 23 Oct 2024 19:55:20 +0300 Subject: [PATCH 007/104] Add python3-pip --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index a077783e8..619b50497 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM ubuntu:22.04 RUN apt-get update -y && \ apt-get upgrade -y && \ - apt-get install -y python3 + apt-get install -y python3 && \ + apt-get install python3-pip COPY requirements.txt requirements.txt RUN `pip install -r requirements.txt` RUN useradd -ms /bin/bash myuser From 69d4ef65a358c28598d91e15139bb8559a998732 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Wed, 23 Oct 2024 20:01:16 +0300 Subject: [PATCH 008/104] Add -y --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 619b50497..e1aeb7eae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM ubuntu:22.04 RUN apt-get update -y && \ apt-get upgrade -y && \ apt-get install -y python3 && \ - apt-get install python3-pip + apt-get install -y python3-pip COPY requirements.txt requirements.txt RUN `pip install -r requirements.txt` RUN useradd -ms /bin/bash myuser From 01f66ac53c5777c8acf0eb28489247918a479068 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Wed, 23 Oct 2024 20:07:42 +0300 Subject: [PATCH 009/104] Refactor again --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e1aeb7eae..dc9a6cba4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,9 +4,9 @@ RUN apt-get update -y && \ apt-get install -y python3 && \ apt-get install -y python3-pip COPY requirements.txt requirements.txt -RUN `pip install -r requirements.txt` RUN useradd -ms /bin/bash myuser USER myuser +RUN `pip install -r requirements.txt` COPY app /app WORKDIR /app EXPOSE 5000 From e934bddb41af233ae733b40e23595419ee1a0f2c Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Wed, 23 Oct 2024 20:10:09 +0300 Subject: [PATCH 010/104] Refactor 2 --- Dockerfile | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index dc9a6cba4..bc1eb138c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,14 @@ FROM ubuntu:22.04 -RUN apt-get update -y && \ - apt-get upgrade -y && \ - apt-get install -y python3 && \ - apt-get install -y python3-pip -COPY requirements.txt requirements.txt -RUN useradd -ms /bin/bash myuser -USER myuser -RUN `pip install -r requirements.txt` -COPY app /app +RUN apt-get update && \ + apt-get install -y && \ + apt-get install python3 -y && \ + apt-get install pip -y && \ + groupadd -g 1234 notroot && \ + useradd -m -u 1234 -g notroot notroot +USER notroot WORKDIR /app +COPY requirements.txt . +RUN pip install -r requirements.txt +COPY app . EXPOSE 5000 CMD ["python3", "app.py"] \ No newline at end of file From de09d4a7512b123546d5af5caf7e7a2214102483 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Wed, 23 Oct 2024 20:13:47 +0300 Subject: [PATCH 011/104] change port inside app.py to 5000 from 3000 --- app/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/app.py b/app/app.py index 67e0180c0..1c2c83d55 100644 --- a/app/app.py +++ b/app/app.py @@ -11,4 +11,4 @@ def hello_world(): if __name__ == "__main__": - app.run(port=os.environ.get("PORT", 3000), host="0.0.0.0") + app.run(port=os.environ.get("PORT", 5000), host="0.0.0.0") From 6340897fc906d08b10295c6e21b211e0fee1f589 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Wed, 23 Oct 2024 20:43:50 +0300 Subject: [PATCH 012/104] Refactorring --- Dockerfile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index bc1eb138c..8985d30b3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ FROM ubuntu:22.04 RUN apt-get update && \ - apt-get install -y && \ - apt-get install python3 -y && \ - apt-get install pip -y && \ - groupadd -g 1234 notroot && \ - useradd -m -u 1234 -g notroot notroot + apt-get install -y \ + python3 -y \ + python3-pip -y && \ + groupadd -g 1234 notroot && \ + useradd -m -u 1234 -g notroot notroot USER notroot WORKDIR /app COPY requirements.txt . From ccf2ffed00d08a31cfbf3d1d55929102dd70e6d7 Mon Sep 17 00:00:00 2001 From: Iliyan Vutov Date: Mon, 28 Oct 2024 18:01:20 +0200 Subject: [PATCH 013/104] Ansible homework --- M1-3-Ansible/README.md | 36 ++++++++++++++++++++++++++++++++++++ requirements.txt | 4 ++++ 2 files changed, 40 insertions(+) create mode 100644 M1-3-Ansible/README.md diff --git a/M1-3-Ansible/README.md b/M1-3-Ansible/README.md new file mode 100644 index 000000000..e44faf9c3 --- /dev/null +++ b/M1-3-Ansible/README.md @@ -0,0 +1,36 @@ +# M1-3-1 Configuration Management + +## Ansible Task + +Create an Ansible playbook that build, push and then run the Docker image for the Python +application. Let your playbook has the following variables: + +* `image_name` - contains the name of your image without the tag, i.e. `vutoff/python-app` +* `image_tag` - contains the tag you tagged your image with, i.e. `v0.2` +* `listen_port` - contains the listening port you're binding your app to. + +Make sure that you set environment variable `PORT` when you define your container +in the Ansible playbook that takes its value from `listen_port` variable. + +Use Ansible modules. Do not shell out. + +### Requirements + +* Make sure you have Python installed. Any version above 3.8 would suffice. +* The `requirements.txt` file in this directory contains the required Ansible version. Run + +```sh +pip install -r requirements.txt +``` + +* Make sure that Docker is running on your local machine. + +### Mind the following + +* If you're running Docker Desktop or Rancher Desktop, mind the location of the `docker.sock` file. The location of the socket file is + * Docker Desktop - `${HOME}/.docker/run/docker.sock` + * Rancher DEsktop - ${HOME}/.rd/run/docker.sock + +* If you're using one of the above, when you write your Ansible playbook you +must specify the path to the docker socket with the parameter `docker_host`, +i.e. `docker_host: "unix://{{ ansible_env.HOME }}/.rd/docker.sock"`. diff --git a/requirements.txt b/requirements.txt index b5ba78cca..38a10fb15 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,7 @@ +ansible==10.3.0 +ansible-compat==24.9.1 +ansible-core==2.17.5 +ansible-lint==24.9.2 blinker==1.6.3 ; python_version >= "3.10" and python_version < "4.0" click==8.1.7 ; python_version >= "3.10" and python_version < "4.0" colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows" From b91e922d2af02823c35b9c20b5605417edd612e4 Mon Sep 17 00:00:00 2001 From: Iliyan Vutov Date: Mon, 28 Oct 2024 18:01:20 +0200 Subject: [PATCH 014/104] Ansible homework --- M1-3-Ansible/README.md | 36 ++++++++++++++++++++++++++++++++++++ app/app_test.py | 17 +++++++++++++++++ requirements.txt | 4 ++++ 3 files changed, 57 insertions(+) create mode 100644 M1-3-Ansible/README.md create mode 100644 app/app_test.py diff --git a/M1-3-Ansible/README.md b/M1-3-Ansible/README.md new file mode 100644 index 000000000..e44faf9c3 --- /dev/null +++ b/M1-3-Ansible/README.md @@ -0,0 +1,36 @@ +# M1-3-1 Configuration Management + +## Ansible Task + +Create an Ansible playbook that build, push and then run the Docker image for the Python +application. Let your playbook has the following variables: + +* `image_name` - contains the name of your image without the tag, i.e. `vutoff/python-app` +* `image_tag` - contains the tag you tagged your image with, i.e. `v0.2` +* `listen_port` - contains the listening port you're binding your app to. + +Make sure that you set environment variable `PORT` when you define your container +in the Ansible playbook that takes its value from `listen_port` variable. + +Use Ansible modules. Do not shell out. + +### Requirements + +* Make sure you have Python installed. Any version above 3.8 would suffice. +* The `requirements.txt` file in this directory contains the required Ansible version. Run + +```sh +pip install -r requirements.txt +``` + +* Make sure that Docker is running on your local machine. + +### Mind the following + +* If you're running Docker Desktop or Rancher Desktop, mind the location of the `docker.sock` file. The location of the socket file is + * Docker Desktop - `${HOME}/.docker/run/docker.sock` + * Rancher DEsktop - ${HOME}/.rd/run/docker.sock + +* If you're using one of the above, when you write your Ansible playbook you +must specify the path to the docker socket with the parameter `docker_host`, +i.e. `docker_host: "unix://{{ ansible_env.HOME }}/.rd/docker.sock"`. diff --git a/app/app_test.py b/app/app_test.py new file mode 100644 index 000000000..a1b1bacb2 --- /dev/null +++ b/app/app_test.py @@ -0,0 +1,17 @@ +import unittest + +from app import app + + +class TestApp(unittest.TestCase): + def setUp(self): + self.client = app.test_client() + + def test_hello_world(self): + response = self.client.get("/") + self.assertEqual(response.status_code, 200) + self.assertEqual(response.data, b"Hello, World!") + + +if __name__ == "__main__": + unittest.main() diff --git a/requirements.txt b/requirements.txt index b5ba78cca..38a10fb15 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,7 @@ +ansible==10.3.0 +ansible-compat==24.9.1 +ansible-core==2.17.5 +ansible-lint==24.9.2 blinker==1.6.3 ; python_version >= "3.10" and python_version < "4.0" click==8.1.7 ; python_version >= "3.10" and python_version < "4.0" colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows" From 9c9959b5bf6db346139d47bb03110c0e78514efe Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 4 Nov 2024 20:59:55 +0200 Subject: [PATCH 015/104] =?UTF-8?q?=C2=A7GitHub=20Actions=20Demo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/github-actions-demo.yml | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/github-actions-demo.yml diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml new file mode 100644 index 000000000..c2453b33b --- /dev/null +++ b/.github/workflows/github-actions-demo.yml @@ -0,0 +1,36 @@ +name: GitHub Actions Demo +run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 +on: [push] +jobs: + Initial: + runs-on: ubuntu-latest + steps: + - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - name: Check out repository code + uses: actions/checkout@v4 + - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." + - run: echo "🖥️ The workflow is now ready to test your code on the runner." + - name: List files in the repository + run: | + ls ${{ github.workspace }} + - run: echo "🍏 This job's status is ${{ job.status }}." + + Build: + runs-on: ubuntu-latest + needs: Initial + steps: + - run: echo "🎉 Build" + + Test: + runs-on: ubuntu-latest + needs: Build + steps: + - run: echo "🎉 Test" + + Deploy: + runs-on: ubuntu-latest + needs: Test + steps: + - run: echo "🎉 Deploy" \ No newline at end of file From a4f488cfe6c63a7af4c7b89cb1ba203db90b2cd8 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 4 Nov 2024 21:15:13 +0200 Subject: [PATCH 016/104] =?UTF-8?q?add=20lint=C2=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/github-actions-demo.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index c2453b33b..97fdc632c 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -16,6 +16,11 @@ jobs: run: | ls ${{ github.workspace }} - run: echo "🍏 This job's status is ${{ job.status }}." + lint: + runs-on: ubuntu-latest + needs: Initial + steps: + - run: echo "🎉 Build" Build: runs-on: ubuntu-latest From 5724ad42490f84e1a18fe1e6e384af691f71eb0d Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 4 Nov 2024 21:20:46 +0200 Subject: [PATCH 017/104] add tests to pipeline --- .github/workflows/github-actions-demo.yml | 24 +++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 97fdc632c..de530dca4 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -16,12 +16,7 @@ jobs: run: | ls ${{ github.workspace }} - run: echo "🍏 This job's status is ${{ job.status }}." - lint: - runs-on: ubuntu-latest - needs: Initial - steps: - - run: echo "🎉 Build" - + Build: runs-on: ubuntu-latest needs: Initial @@ -33,6 +28,23 @@ jobs: needs: Build steps: - run: echo "🎉 Test" + + lint: + runs-on: ubuntu-latest + needs: build + steps: + - run: echo "🎉 Lint" + + configure-secrets: + runs-on: ubuntu-latest + needs: build + steps: + - name: Retrieve secret + env: + super_secret: ${{ secrets.SUPERSECRET }} + run: | + echo "$super_secret" + Deploy: runs-on: ubuntu-latest From d63241ddd47e116c7e356fb32c654007b93d873c Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 4 Nov 2024 21:23:43 +0200 Subject: [PATCH 018/104] changes to workflows --- .github/workflows/github-actions-demo.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index de530dca4..e553198c8 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -31,13 +31,13 @@ jobs: lint: runs-on: ubuntu-latest - needs: build + needs: Build steps: - run: echo "🎉 Lint" configure-secrets: runs-on: ubuntu-latest - needs: build + needs: Build steps: - name: Retrieve secret env: From bde7d2b06e6547ba496da6a4749b39a74485292e Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 4 Nov 2024 21:30:41 +0200 Subject: [PATCH 019/104] some other adjustments --- .github/workflows/github-actions-demo.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index e553198c8..63ce8b707 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -1,5 +1,5 @@ name: GitHub Actions Demo -run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 +run-name: ${{ github.actor }} is testing out GitHub Actions on: [push] jobs: Initial: @@ -23,19 +23,19 @@ jobs: steps: - run: echo "🎉 Build" - Test: + Lint: runs-on: ubuntu-latest needs: Build steps: - - run: echo "🎉 Test" - - lint: + - run: echo "🎉 Lint" + + Test: runs-on: ubuntu-latest needs: Build steps: - - run: echo "🎉 Lint" + - run: echo "🎉 Test" - configure-secrets: + Configure-secrets: runs-on: ubuntu-latest needs: Build steps: @@ -48,6 +48,6 @@ jobs: Deploy: runs-on: ubuntu-latest - needs: Test + needs: [Lint, Test, Configure-secrets] steps: - run: echo "🎉 Deploy" \ No newline at end of file From b1db746ef3e6a5a0e6a850a0ab925b0ec246172f Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 19:50:23 +0200 Subject: [PATCH 020/104] First 3 steps for practice tasks (initial) --- .editorconfig | 33 +++++++++++++++ .github/workflows/github-actions-demo.yml | 50 ++++++++++++++++++----- 2 files changed, 72 insertions(+), 11 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..26e04eaf7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,33 @@ +# EditorConfig is awesome: https://editorconfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true + +# Matches multiple files with brace expansion notation +# Set default charset +[*.{js,py}] +charset = utf-8 + +# 4 space indentation +[*.py] +indent_style = space +indent_size = 4 + +# Tab indentation (no size specified) +[Makefile] +indent_style = tab + +# Indentation override for all JS under lib directory +[lib/**.js] +indent_style = space +indent_size = 2 + +# Matches the exact files either package.json or .travis.yml +[{package.json,.travis.yml}] +indent_style = space +indent_size = 2 \ No newline at end of file diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 63ce8b707..ccfb731de 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -1,39 +1,67 @@ name: GitHub Actions Demo run-name: ${{ github.actor }} is testing out GitHub Actions -on: [push] +on: + push: + branches-ignore: + - 'main' jobs: + Pylint: + runs-on: ubuntu-latest + steps: + - name: Check .editorconfig + uses: actions/checkout@v2 + with: + fetch-depth: 0 + run: + pip install editorconfig-checker + editorconfig-checker + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.10' + cache: 'pip' + - name: Install dependencies + run: + pip install pylint black flake8 markdown-lint-cli + - name: Analysing the code with pylint + run: + pylint $(git ls-files '*.py') + - name: Check markdown files + run: + markdownlint-cli . + Initial: runs-on: ubuntu-latest steps: - - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" - - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." + - run: echo "The job was automatically triggered by a ${{ github.event_name }} event." + - run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub!" + - run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - name: Check out repository code uses: actions/checkout@v4 - - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." + - run: echo "The ${{ github.repository }} repository has been cloned to the runner." + - run: echo "The workflow is now ready to test your code on the runner." - name: List files in the repository run: | ls ${{ github.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." + - run: echo "This job's status is ${{ job.status }}." Build: runs-on: ubuntu-latest needs: Initial steps: - - run: echo "🎉 Build" + - run: echo "Build" Lint: runs-on: ubuntu-latest needs: Build steps: - - run: echo "🎉 Lint" + - run: echo "Lint" Test: runs-on: ubuntu-latest needs: Build steps: - - run: echo "🎉 Test" + - run: echo "Test" Configure-secrets: runs-on: ubuntu-latest @@ -50,4 +78,4 @@ jobs: runs-on: ubuntu-latest needs: [Lint, Test, Configure-secrets] steps: - - run: echo "🎉 Deploy" \ No newline at end of file + - run: echo "Deploy" \ No newline at end of file From 0d826c0eb1752995dfae0b4670d4c7baaffe8027 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 20:31:49 +0200 Subject: [PATCH 021/104] After Vutov Test 1 --- .github/workflows/github-actions-demo.yml | 89 +++++------------------ 1 file changed, 19 insertions(+), 70 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index ccfb731de..bc13903a6 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -8,74 +8,23 @@ jobs: Pylint: runs-on: ubuntu-latest steps: - - name: Check .editorconfig - uses: actions/checkout@v2 - with: - fetch-depth: 0 - run: - pip install editorconfig-checker + - name: Check .editorconfig + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.10' + cache: 'pip' + - run: | + pip install pylint black flake8 editorconfig-checker + npm install -g markdownlint-cli editorconfig-checker - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.10' - cache: 'pip' - - name: Install dependencies - run: - pip install pylint black flake8 markdown-lint-cli - - name: Analysing the code with pylint - run: - pylint $(git ls-files '*.py') - - name: Check markdown files - run: - markdownlint-cli . - - Initial: - runs-on: ubuntu-latest - steps: - - run: echo "The job was automatically triggered by a ${{ github.event_name }} event." - - run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub!" - - run: echo "The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - - name: Check out repository code - uses: actions/checkout@v4 - - run: echo "The ${{ github.repository }} repository has been cloned to the runner." - - run: echo "The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ github.workspace }} - - run: echo "This job's status is ${{ job.status }}." - - Build: - runs-on: ubuntu-latest - needs: Initial - steps: - - run: echo "Build" - - Lint: - runs-on: ubuntu-latest - needs: Build - steps: - - run: echo "Lint" - - Test: - runs-on: ubuntu-latest - needs: Build - steps: - - run: echo "Test" - - Configure-secrets: - runs-on: ubuntu-latest - needs: Build - steps: - - name: Retrieve secret - env: - super_secret: ${{ secrets.SUPERSECRET }} - run: | - echo "$super_secret" - - - Deploy: - runs-on: ubuntu-latest - needs: [Lint, Test, Configure-secrets] - steps: - - run: echo "Deploy" \ No newline at end of file + + - name: Analysing the code with pylint + run: + pylint $(git ls-files '*.py') + - name: Check markdown files + run: + markdownlint-cli . From 280b82a65cc8153a062687bc9612c10711be9054 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 20:34:11 +0200 Subject: [PATCH 022/104] indent --- .github/workflows/github-actions-demo.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index bc13903a6..b326b32ef 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -10,8 +10,8 @@ jobs: steps: - name: Check .editorconfig uses: actions/checkout@v2 - with: - fetch-depth: 0 + with: + fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v3 with: From fd0603ce3a0c292344c9afc6438ad733496e3988 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 20:37:09 +0200 Subject: [PATCH 023/104] Indentation 2 --- .github/workflows/github-actions-demo.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index b326b32ef..51b61e42b 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -18,13 +18,13 @@ jobs: python-version: '3.10' cache: 'pip' - run: | - pip install pylint black flake8 editorconfig-checker - npm install -g markdownlint-cli - editorconfig-checker + pip install pylint black flake8 editorconfig-checker + npm install -g markdownlint-cli + editorconfig-checker - name: Analysing the code with pylint - run: + - run: pylint $(git ls-files '*.py') - name: Check markdown files - run: + - run: markdownlint-cli . From 9cc1cb32aad7a263f252842ffd12953d141e4f27 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 20:38:48 +0200 Subject: [PATCH 024/104] Indentation 3 --- .github/workflows/github-actions-demo.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 51b61e42b..b6a5a9eba 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -23,8 +23,8 @@ jobs: editorconfig-checker - name: Analysing the code with pylint - - run: - pylint $(git ls-files '*.py') + run: + pylint $(git ls-files '*.py') - name: Check markdown files - - run: - markdownlint-cli . + run: + markdownlint-cli . From ebd80c85450848d64e10f6a656ddb1f967019a9f Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 20:40:52 +0200 Subject: [PATCH 025/104] Change syntaxis 1 --- .github/workflows/github-actions-demo.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index b6a5a9eba..41327bf67 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -23,8 +23,8 @@ jobs: editorconfig-checker - name: Analysing the code with pylint - run: + run: | pylint $(git ls-files '*.py') - name: Check markdown files - run: + run: | markdownlint-cli . From f1b1c7f8d621a51e8e2b763aff0c7b48e9a8c51f Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 20:44:18 +0200 Subject: [PATCH 026/104] Change syntaxis 2 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 41327bf67..8843c1b0f 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -24,7 +24,7 @@ jobs: - name: Analysing the code with pylint run: | - pylint $(git ls-files '*.py') + pylint **/*.py - name: Check markdown files run: | markdownlint-cli . From 1766c2d24f0f60f7496361d5a4570e3b2613426f Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 20:46:59 +0200 Subject: [PATCH 027/104] Change syntaxis 3 --- .github/workflows/github-actions-demo.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 8843c1b0f..74f0c7a65 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -24,7 +24,9 @@ jobs: - name: Analysing the code with pylint run: | - pylint **/*.py + find . -name '*.py' | xargs pylint + black --check --diff . + flake8 . - name: Check markdown files run: | markdownlint-cli . From 593a33677dfc4a854e18fef9b354266520c4165e Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 20:49:55 +0200 Subject: [PATCH 028/104] Change syntaxis 4 --- .github/workflows/github-actions-demo.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 74f0c7a65..39947e30c 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -21,8 +21,7 @@ jobs: pip install pylint black flake8 editorconfig-checker npm install -g markdownlint-cli editorconfig-checker - - - name: Analysing the code with pylint + - name: Lint Python code run: | find . -name '*.py' | xargs pylint black --check --diff . From 813346b0267df5fb79d849e5904c3a93f1904cbf Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 20:50:30 +0200 Subject: [PATCH 029/104] Change syntaxis 5 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 39947e30c..c40145a0d 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -22,7 +22,7 @@ jobs: npm install -g markdownlint-cli editorconfig-checker - name: Lint Python code - run: | + - run: | find . -name '*.py' | xargs pylint black --check --diff . flake8 . From fda9b761662d3f53b5c316df250ca906c6eefc4c Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 20:53:33 +0200 Subject: [PATCH 030/104] Change syntaxis 6 --- .github/workflows/github-actions-demo.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index c40145a0d..dc4356d08 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -23,9 +23,9 @@ jobs: editorconfig-checker - name: Lint Python code - run: | - find . -name '*.py' | xargs pylint - black --check --diff . - flake8 . + find . -name '*.py' | xargs pylint + black --check --diff . + flake8 . - name: Check markdown files - run: | - markdownlint-cli . + - run: + markdownlint-cli . From c4d2072b9679160032d8c86d255ae1c1d56b8752 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 20:54:12 +0200 Subject: [PATCH 031/104] Change syntaxis 7 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index dc4356d08..db5e5194e 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -27,5 +27,5 @@ jobs: black --check --diff . flake8 . - name: Check markdown files - - run: + - run: | markdownlint-cli . From e48845ee5cca9ebda29de28708fb59a52060cc4e Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 20:54:46 +0200 Subject: [PATCH 032/104] Change syntaxis 8 --- .github/workflows/github-actions-demo.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index db5e5194e..f62319243 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -23,9 +23,9 @@ jobs: editorconfig-checker - name: Lint Python code - run: | - find . -name '*.py' | xargs pylint - black --check --diff . - flake8 . + find . -name '*.py' | xargs pylint + black --check --diff . + flake8 . - name: Check markdown files - - run: | - markdownlint-cli . + - run: + markdownlint-cli . From 14bc8151523a987033225d3fa8aa0f2b24b94f11 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 20:56:15 +0200 Subject: [PATCH 033/104] Change syntaxis 9 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index f62319243..80ce78596 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -28,4 +28,4 @@ jobs: flake8 . - name: Check markdown files - run: - markdownlint-cli . + markdownlint-cli . \ No newline at end of file From 3f7c731c72ada5a6550eb7f4476228c2ff3d2b70 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 20:59:48 +0200 Subject: [PATCH 034/104] Change syntaxis 10 --- .github/workflows/github-actions-demo.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 80ce78596..0e0f7dd95 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -17,15 +17,15 @@ jobs: with: python-version: '3.10' cache: 'pip' - - run: | + - name: Install dependencies + run: | pip install pylint black flake8 editorconfig-checker npm install -g markdownlint-cli editorconfig-checker - name: Lint Python code - - run: | - find . -name '*.py' | xargs pylint - black --check --diff . - flake8 . + run: | + find . -name '*.py' | xargs pylint + black --check --diff . + flake8 . - name: Check markdown files - - run: - markdownlint-cli . \ No newline at end of file + run: markdownlint-cli . \ No newline at end of file From c8ffb06d86d58de7bf045e459a56ca0c2e5bac25 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 21:10:00 +0200 Subject: [PATCH 035/104] Change syntaxis 11 --- .github/workflows/github-actions-demo.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 0e0f7dd95..174a867d6 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -19,13 +19,13 @@ jobs: cache: 'pip' - name: Install dependencies run: | - pip install pylint black flake8 editorconfig-checker - npm install -g markdownlint-cli - editorconfig-checker + pip install pylint black flake8 + npm install -g markdownlint-cli editorconfig-checker + editorconfig-checker - name: Lint Python code run: | - find . -name '*.py' | xargs pylint - black --check --diff . - flake8 . + find . -name '*.py' | xargs pylint + black --check --diff . + flake8 . - name: Check markdown files run: markdownlint-cli . \ No newline at end of file From 9db0033b2e55dae1c647bae82891ac6993cee91c Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 21:11:29 +0200 Subject: [PATCH 036/104] Change syntaxis 12 --- .github/workflows/github-actions-demo.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 174a867d6..431ed028f 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -1,9 +1,9 @@ name: GitHub Actions Demo run-name: ${{ github.actor }} is testing out GitHub Actions -on: - push: - branches-ignore: - - 'main' +on: [push] + #push: + # branches-ignore: + # - 'main' jobs: Pylint: runs-on: ubuntu-latest From 994bf2e25e89b70d16acbf8815eaa48dd5a81ed6 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 21:22:30 +0200 Subject: [PATCH 037/104] Change syntaxis 13 --- .github/workflows/github-actions-demo.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 431ed028f..da7754681 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -18,6 +18,9 @@ jobs: python-version: '3.10' cache: 'pip' - name: Install dependencies + uses: actions/setup-node@v3 + with: + node-version: '20' run: | pip install pylint black flake8 npm install -g markdownlint-cli editorconfig-checker From bf90c375447ffa587820d50c9f94e1a3b08392b6 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 21:26:21 +0200 Subject: [PATCH 038/104] Change syntaxis 14 --- .github/workflows/github-actions-demo.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index da7754681..a14969a6a 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -17,10 +17,11 @@ jobs: with: python-version: '3.10' cache: 'pip' - - name: Install dependencies + - name: Set up Node.js uses: actions/setup-node@v3 with: node-version: '20' + - name: Install dependencies run: | pip install pylint black flake8 npm install -g markdownlint-cli editorconfig-checker From d333b0bdd3ccc7f970ae13a51fa95cb7e800d264 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 21:28:26 +0200 Subject: [PATCH 039/104] Change syntaxis 15 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index a14969a6a..b395d8f3a 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -20,7 +20,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v3 with: - node-version: '20' + node-version: '22' - name: Install dependencies run: | pip install pylint black flake8 From 3b666bef028c6b19a51cc9f4d35debd0037cf77a Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 11 Nov 2024 21:31:06 +0200 Subject: [PATCH 040/104] Change syntaxis 16 --- .editorconfig | 2 +- .github/workflows/github-actions-demo.yml | 3 ++- Dockerfile | 2 +- README.md | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.editorconfig b/.editorconfig index 26e04eaf7..3b3098110 100644 --- a/.editorconfig +++ b/.editorconfig @@ -30,4 +30,4 @@ indent_size = 2 # Matches the exact files either package.json or .travis.yml [{package.json,.travis.yml}] indent_style = space -indent_size = 2 \ No newline at end of file +indent_size = 2 diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index b395d8f3a..5c90aa208 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -32,4 +32,5 @@ jobs: black --check --diff . flake8 . - name: Check markdown files - run: markdownlint-cli . \ No newline at end of file + run: markdownlint-cli . + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8985d30b3..8b24cbdce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,4 +11,4 @@ COPY requirements.txt . RUN pip install -r requirements.txt COPY app . EXPOSE 5000 -CMD ["python3", "app.py"] \ No newline at end of file +CMD ["python3", "app.py"] diff --git a/README.md b/README.md index d19dfd95a..30e691ba2 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# devops-programme \ No newline at end of file +# devops-programme From fc6c0b98c229b6b72295214444623832c98e4318 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 07:12:58 +0200 Subject: [PATCH 041/104] Change syntaxis 17 --- .github/workflows/github-actions-demo.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 5c90aa208..63ef4c0d5 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -33,4 +33,3 @@ jobs: flake8 . - name: Check markdown files run: markdownlint-cli . - \ No newline at end of file From e589427d715436deb43d600c678496c2e84ebed1 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 07:16:52 +0200 Subject: [PATCH 042/104] Change syntaxis 18 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 30e691ba2..25e0e448e 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# devops-programme +# devops-programme From f5e6f26c40ef68b9521c1cfc9f93b42ccb7f6398 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 07:27:35 +0200 Subject: [PATCH 043/104] Add unittest 1 --- .github/workflows/github-actions-demo.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 63ef4c0d5..34097cfd4 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -26,6 +26,10 @@ jobs: pip install pylint black flake8 npm install -g markdownlint-cli editorconfig-checker editorconfig-checker + - name: Run unit tests + run: | + cd app + python -m unittest - name: Lint Python code run: | find . -name '*.py' | xargs pylint From e929bba50bfcd8a795c7afd6826626a7ef9febbd Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 07:29:07 +0200 Subject: [PATCH 044/104] Add unittest 2 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 34097cfd4..efceb3725 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -29,7 +29,7 @@ jobs: - name: Run unit tests run: | cd app - python -m unittest + python -m unittest discover -v - name: Lint Python code run: | find . -name '*.py' | xargs pylint From 3438ac3d2623037213d6f73a76cc71c13a31cccd Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 07:33:27 +0200 Subject: [PATCH 045/104] Add gitleaks 1 --- .github/workflows/github-actions-demo.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index efceb3725..84cda04bb 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -21,6 +21,10 @@ jobs: uses: actions/setup-node@v3 with: node-version: '22' + - name: Check for hardcoded secrets + uses: gitleaks/gitleaks-action@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Install dependencies run: | pip install pylint black flake8 From d9268d0212ee8265840a6317baca484116424c79 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 07:59:49 +0200 Subject: [PATCH 046/104] Add Sonar 1 --- sonar-project.properties | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 sonar-project.properties diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 000000000..6754deae0 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,22 @@ +sonar.projectKey=u34-georgi-telerik +sonar.organization=u34-georgi-telerik + +# This is the name and version displayed in the SonarCloud UI. +sonar.projectName=devops-programme +sonar.projectVersion=1.0 + +# Path is relative to the sonar-project.properties file +sonar.sources=app +sonar.tests=app + +# Test patterns +sonar.test.inclusions=app/**/*_test.py,app/**/test_*.py + +# Python version +sonar.python.version=3.10 + +# Coverage reports +sonar.python.coverage.reportPaths=app/coverage-reports/coverage.xml + +# Encoding of the source code. Default is default system encoding +sonar.sourceEncoding=UTF-8 \ No newline at end of file From 0b2fa92ced3406fed1a60d19c5d6f381a96aca83 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 08:01:11 +0200 Subject: [PATCH 047/104] Add Sonar 2 --- .github/workflows/github-actions-demo.yml | 12 ++++++++++++ sonar-project.properties | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 84cda04bb..a2eed0d62 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -41,3 +41,15 @@ jobs: flake8 . - name: Check markdown files run: markdownlint-cli . + sonarcloud: + needs: test-lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/sonar-project.properties b/sonar-project.properties index 6754deae0..f943dca5a 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -19,4 +19,4 @@ sonar.python.version=3.10 sonar.python.coverage.reportPaths=app/coverage-reports/coverage.xml # Encoding of the source code. Default is default system encoding -sonar.sourceEncoding=UTF-8 \ No newline at end of file +sonar.sourceEncoding=UTF-8 From 67b1d8b6e1bf6b3c99e2a40c772584615c12532b Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 08:02:29 +0200 Subject: [PATCH 048/104] Add Sonar 3 --- .github/workflows/github-actions-demo.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index a2eed0d62..88f8780b8 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -41,10 +41,10 @@ jobs: flake8 . - name: Check markdown files run: markdownlint-cli . - sonarcloud: - needs: test-lint - runs-on: ubuntu-latest - steps: + sonarcloud: + needs: test-lint + runs-on: ubuntu-latest + steps: - uses: actions/checkout@v2 with: fetch-depth: 0 From d3a0158d2ddae3f210a32a854c0f6195c50121e3 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 08:03:52 +0200 Subject: [PATCH 049/104] Add Sonar 4 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 88f8780b8..0fb6c7fbd 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -42,7 +42,7 @@ jobs: - name: Check markdown files run: markdownlint-cli . sonarcloud: - needs: test-lint + needs: Pylint runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 2bfa1e8b990409fd08680807659602994d964ac6 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 08:05:09 +0200 Subject: [PATCH 050/104] Add Sonar 5 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 0fb6c7fbd..02b785961 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -52,4 +52,4 @@ jobs: uses: SonarSource/sonarcloud-github-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 5336c0ad3e4ad59c6ee7da8f8e590ff5c1ab35b9 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 08:09:37 +0200 Subject: [PATCH 051/104] Add Sonar 6 --- .github/workflows/github-actions-demo.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 02b785961..13b6caf68 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -7,6 +7,7 @@ on: [push] jobs: Pylint: runs-on: ubuntu-latest + continue-on-error: true # To remove steps: - name: Check .editorconfig uses: actions/checkout@v2 @@ -42,7 +43,7 @@ jobs: - name: Check markdown files run: markdownlint-cli . sonarcloud: - needs: Pylint + #needs: Pylint runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 9a0344260ee8b988d78ada49d82b697da1d0f0d2 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 08:14:40 +0200 Subject: [PATCH 052/104] Add Sonar 7 --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index f943dca5a..a7d9262cc 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,4 +1,4 @@ -sonar.projectKey=u34-georgi-telerik +sonar.projectKey=u34-georgi-telerik_devops-programme sonar.organization=u34-georgi-telerik # This is the name and version displayed in the SonarCloud UI. From 7c82cb1da5bd5090578b5619d64610f28e560ef9 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 09:47:24 +0200 Subject: [PATCH 053/104] Add Sonar 9 --- .github/workflows/github-actions-demo.yml | 30 ++++++++++++++++------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 13b6caf68..c42eb1531 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -42,15 +42,27 @@ jobs: flake8 . - name: Check markdown files run: markdownlint-cli . - sonarcloud: + security: #needs: Pylint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - uses: actions/checkout@v2 + - name: Run Snyk to check for vulnerabilities + uses: snyk/actions/python@master + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + with: + command: monitor + args: --all-projects --severity-threshold=high + #sonarcloud: + # #needs: Pylint + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # with: + # fetch-depth: 0 + # - name: SonarCloud Scan + # uses: SonarSource/sonarcloud-github-action@master + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 0b038ba76eec66222ab9a917f3239dd3b4ea42a7 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 09:51:01 +0200 Subject: [PATCH 054/104] Add Snyk 1 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index c42eb1531..45c23ed77 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -52,7 +52,7 @@ jobs: env: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} with: - command: monitor + command: test args: --all-projects --severity-threshold=high #sonarcloud: # #needs: Pylint From 6eee43820260530f4b675ff2657472f217e91898 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 10:07:40 +0200 Subject: [PATCH 055/104] Add Snyk 2 --- .github/workflows/github-actions-demo.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 45c23ed77..35fd88954 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -29,6 +29,7 @@ jobs: - name: Install dependencies run: | pip install pylint black flake8 + pip install -r requirements.txt npm install -g markdownlint-cli editorconfig-checker editorconfig-checker - name: Run unit tests @@ -53,7 +54,7 @@ jobs: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} with: command: test - args: --all-projects --severity-threshold=high + args: --file=requirements.txt --severity-threshold=high #--all-projects --severity-threshold=high #sonarcloud: # #needs: Pylint # runs-on: ubuntu-latest From 41d58e361787dc6af1cb7752a83703897415fba7 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 10:24:39 +0200 Subject: [PATCH 056/104] Add Snyk 4 --- .github/workflows/github-actions-demo.yml | 3 +- requirements.txt | 206 +++++++++++++++++++--- 2 files changed, 187 insertions(+), 22 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 35fd88954..7057cb4bf 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -29,7 +29,6 @@ jobs: - name: Install dependencies run: | pip install pylint black flake8 - pip install -r requirements.txt npm install -g markdownlint-cli editorconfig-checker editorconfig-checker - name: Run unit tests @@ -54,7 +53,7 @@ jobs: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} with: command: test - args: --file=requirements.txt --severity-threshold=high #--all-projects --severity-threshold=high + args: --severity-threshold=high #--all-projects --severity-threshold=high #sonarcloud: # #needs: Pylint # runs-on: ubuntu-latest diff --git a/requirements.txt b/requirements.txt index 8159843f2..7591b8dc2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,20 +1,186 @@ -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> b91e922d2af02823c35b9c20b5605417edd612e4 -ansible==10.3.0 -ansible-compat==24.9.1 -ansible-core==2.17.5 -ansible-lint==24.9.2 -blinker==1.6.3 ; python_version >= "3.10" and python_version < "4.0" -click==8.1.7 ; python_version >= "3.10" and python_version < "4.0" -colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows" -flask==3.0.0 ; python_version >= "3.10" and python_version < "4.0" -itsdangerous==2.1.2 ; python_version >= "3.10" and python_version < "4.0" -jinja2==3.1.2 ; python_version >= "3.10" and python_version < "4.0" -markupsafe==2.1.3 ; python_version >= "3.10" and python_version < "4.0" -werkzeug==3.0.0 ; python_version >= "3.10" and python_version < "4.0" - -======= -flask==3.0.0 ->>>>>>> practice1 +aerospike==15.1.0 +aiohttp==3.10.10 +ansible_base==2.10.17 +ansible_tower_cli==3.3.9 +antsibull_docs_parser==1.1.0 +apache_libcloud==3.8.0 +argcomplete==3.5.1 +asana_kazoo==2.0.8dev +asgiref==3.8.1 +astroid==3.3.5 +atheris==2.3.0 +bambou==3.1.3 +BeautifulSoup==3.2.2 +beautifulsoup4==4.12.3 +capacity==1.3.14 +cffi==1.17.1 +chardet==5.2.0 +ciscoisesdk==2.2.3 +clc==0.0.1 +colorama==0.4.6 +configobj==5.0.9 +ConfigParser==7.1.0 +cps==3.3.6 +cvprac==1.4.0 +datadog==0.50.1 +datadog_api_client==2.30.0 +deepdiff==8.0.1 +dnacentersdk==2.7.5 +docker_compose==1.29.2 +docutils==0.21.2 +dopy==0.3.7 +dpapi_ng==0.2.0 +elasticapm==0 +flatdict==4.0.1 +footmark==1.22.0 +fqdn==1.5.1 +functions_framework==3.8.1 +genie==24.10 +github3.py==4.0.1 +gssapi==1.9.0 +hcl==0.2.1 +heroku3==5.2.1 +hpe3par_sdk==2.0 +hpe3parclient==4.2.13 +hpOneView==5.3.0 +HTMLParser==0.0.2 +hvac==2.3.0 +hypothesis==6.118.8 +infi==0.0.1 +infinisdk==240.2.1 +infoblox_client==0.6.0 +ipython==8.29.0 +ipywidgets==8.1.5 +isodate==0.7.2 +isoduration==20.11.0 +jnius==1.1.0 +jsondiff==2.2.1 +jsonpatch==1.33 +jsonpointer==3.0.0 +jxmlease==1.0.3 +kerberos==1.3.1 +keystoneauth1==5.8.0 +kick==1.1.0 +krb5==0.7.0 +kubernetes_validate==1.31.0 +libdnf5==0.0.1a1 +librouteros==3.2.1 +linode_api4==5.23.0 +lmdb==1.5.1 +lxml==5.3.0 +manageiq_client==0.6.1 +matplotlib==3.9.2 +matrix_client==0.4.0 +msrestazure==0.6.4.post1 +multidict==6.1.0 +munch==4.0.0 +MySQL-python==1.2.5 +nc_dnsapi==0.1.5 +ncclient==0.6.16 +netaddr==1.3.0 +netapp_lib==2021.6.25 +ntc_templates==7.4.0 +objectpath==0.6.1 +oci==2.138.1 +omdrivers==1.2.490 +omsdk==1.2.518 +ordereddict==1.1 +ovh==1.2.0 +ovirt_imageio==2.5.0 +packet==0.5 +paho_mqtt==2.1.0 +pam==0.2.0 +passlib==1.7.4 +pdpyras==5.3.0 +petname==2.6 +pexpect==4.9.0 +pika==1.3.2 +Pillow==11.0.0 +pkgutil_resolve_name==1.3.10 +placebo==0.10.0 +prettytable==3.12.0 +proxmoxer==2.1.0 +psphere==0.6.0 +psutil==6.1.0 +psycopg==3.2.3 +psycopg2==2.9.10 +pubnub_blocks_client==1.1.0 +purity_fb==1.12.3 +py==1.11.0 +pyats==24.10 +pycdlib==1.14.0 +PyChef==0.3.0 +pycountry==24.6.1 +pydotplus==2.0.2 +pyFG==0.50 +pyFMG==0.8.6.3 +pyghmi==1.5.72 +PyGithub==2.5.0 +PyJWT==2.9.0 +pylxca==4.0.0 +pymongo==4.10.1 +pymssql==2.3.1 +pymysql==1.1.1 +pynetbox==7.4.1 +pyodbc==5.2.0 +pyone==6.10.1 +pyOpenSSL==24.2.1 +pyperf==2.8.0 +PyPowerFlex==1.13.0 +pypsexec==0.3.0 +pypsrp==0.8.1 +pypureomapi==0.8 +pyrfc==3.3.1 +pysnmp==7.1.13 +python-dotenv==1.0.1 +python_bcrypt==0.3.2 +python_dateutil==2.9.0.post0 +python_debian==0.1.49 +python_ldap==3.4.4 +python_memcached==1.62 +pytz==2024.2 +pyVim==3.0.3 +pyVmomi==8.0.3.0.1 +pyxcli==1.2.1 +pyzipper==0.3.6 +requests_oauthlib==2.0.0 +requests_toolbelt==1.0.0 +rfc3339_validator==0.1.4 +rfc3986_validator==0.1.1 +rfc3987==1.3.8 +salt==3007.1 +sansldap==0.1.0 +semantic_version==2.10.0 +setuptools==75.4.0 +simplejson==3.19.3 +smbprotocol==1.15.0 +SoftLayer==6.2.5 +spotinst_sdk==1.0.56 +sshpubkeys==3.3.1 +storops==1.2.11 +suds_jurko==0.6 +taiga==0.1.1 +testinfra==6.0.0 +textfsm==1.1.3 +tokenize_rt==6.1.0 +tomli_w==1.1.0 +ttp==0.9.5 +ucsmsdk==0.9.21 +uri_template==1.3.0 +urllib3_secure_extra==0.1.0 +urllib_gssapi==1.0.2 +uvloop==0.21.0 +vdirect_client==4.9.0.post4 +vexatapi==0.0.2 +voluptuous==0.15.2 +watchdog==6.0.0 +webcolors==24.11.1 +websocket_client==1.8.0 +XenAPI==24.37.0 +xkcdpass==1.19.9 +xmljson==0.2.1 +xmlrpclib==1.0.1 +xmltodict==0.14.2 +xmpppy==0.7.1 +yarl==1.17.1 +zabbix_api==0.5.6 From 5f2d55a401cb793bf1cc503d9e74eb9d09efb8cb Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 10:44:35 +0200 Subject: [PATCH 057/104] Add Snyk 5 --- .github/workflows/github-actions-demo.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 7057cb4bf..35fd88954 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -29,6 +29,7 @@ jobs: - name: Install dependencies run: | pip install pylint black flake8 + pip install -r requirements.txt npm install -g markdownlint-cli editorconfig-checker editorconfig-checker - name: Run unit tests @@ -53,7 +54,7 @@ jobs: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} with: command: test - args: --severity-threshold=high #--all-projects --severity-threshold=high + args: --file=requirements.txt --severity-threshold=high #--all-projects --severity-threshold=high #sonarcloud: # #needs: Pylint # runs-on: ubuntu-latest From 583134122d2efe5549fd6e45dd3dca84554ad29f Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 10:54:16 +0200 Subject: [PATCH 058/104] Add Snyk 6 --- requirements.txt | 182 ++++------------------------------------------- 1 file changed, 13 insertions(+), 169 deletions(-) diff --git a/requirements.txt b/requirements.txt index 7591b8dc2..355b229a8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,186 +1,30 @@ -aerospike==15.1.0 -aiohttp==3.10.10 -ansible_base==2.10.17 -ansible_tower_cli==3.3.9 -antsibull_docs_parser==1.1.0 -apache_libcloud==3.8.0 -argcomplete==3.5.1 -asana_kazoo==2.0.8dev -asgiref==3.8.1 -astroid==3.3.5 +ansible==10.3.0 +ansible-compat==24.9.1 +ansible-core==2.17.5 +ansible-lint==24.9.2 atheris==2.3.0 -bambou==3.1.3 BeautifulSoup==3.2.2 -beautifulsoup4==4.12.3 -capacity==1.3.14 -cffi==1.17.1 -chardet==5.2.0 -ciscoisesdk==2.2.3 -clc==0.0.1 -colorama==0.4.6 -configobj==5.0.9 -ConfigParser==7.1.0 cps==3.3.6 -cvprac==1.4.0 -datadog==0.50.1 -datadog_api_client==2.30.0 -deepdiff==8.0.1 -dnacentersdk==2.7.5 docker_compose==1.29.2 -docutils==0.21.2 -dopy==0.3.7 -dpapi_ng==0.2.0 elasticapm==0 -flatdict==4.0.1 -footmark==1.22.0 -fqdn==1.5.1 -functions_framework==3.8.1 genie==24.10 -github3.py==4.0.1 -gssapi==1.9.0 -hcl==0.2.1 -heroku3==5.2.1 -hpe3par_sdk==2.0 -hpe3parclient==4.2.13 -hpOneView==5.3.0 -HTMLParser==0.0.2 -hvac==2.3.0 -hypothesis==6.118.8 -infi==0.0.1 -infinisdk==240.2.1 -infoblox_client==0.6.0 -ipython==8.29.0 -ipywidgets==8.1.5 -isodate==0.7.2 -isoduration==20.11.0 jnius==1.1.0 -jsondiff==2.2.1 -jsonpatch==1.33 -jsonpointer==3.0.0 -jxmlease==1.0.3 -kerberos==1.3.1 -keystoneauth1==5.8.0 -kick==1.1.0 -krb5==0.7.0 -kubernetes_validate==1.31.0 -libdnf5==0.0.1a1 -librouteros==3.2.1 -linode_api4==5.23.0 -lmdb==1.5.1 -lxml==5.3.0 -manageiq_client==0.6.1 -matplotlib==3.9.2 -matrix_client==0.4.0 -msrestazure==0.6.4.post1 -multidict==6.1.0 -munch==4.0.0 MySQL-python==1.2.5 -nc_dnsapi==0.1.5 -ncclient==0.6.16 -netaddr==1.3.0 -netapp_lib==2021.6.25 -ntc_templates==7.4.0 -objectpath==0.6.1 -oci==2.138.1 -omdrivers==1.2.490 -omsdk==1.2.518 -ordereddict==1.1 -ovh==1.2.0 -ovirt_imageio==2.5.0 -packet==0.5 -paho_mqtt==2.1.0 -pam==0.2.0 -passlib==1.7.4 -pdpyras==5.3.0 -petname==2.6 -pexpect==4.9.0 -pika==1.3.2 -Pillow==11.0.0 -pkgutil_resolve_name==1.3.10 -placebo==0.10.0 -prettytable==3.12.0 -proxmoxer==2.1.0 -psphere==0.6.0 -psutil==6.1.0 -psycopg==3.2.3 -psycopg2==2.9.10 -pubnub_blocks_client==1.1.0 -purity_fb==1.12.3 -py==1.11.0 pyats==24.10 -pycdlib==1.14.0 -PyChef==0.3.0 -pycountry==24.6.1 -pydotplus==2.0.2 pyFG==0.50 pyFMG==0.8.6.3 -pyghmi==1.5.72 -PyGithub==2.5.0 -PyJWT==2.9.0 -pylxca==4.0.0 -pymongo==4.10.1 -pymssql==2.3.1 -pymysql==1.1.1 -pynetbox==7.4.1 -pyodbc==5.2.0 pyone==6.10.1 -pyOpenSSL==24.2.1 -pyperf==2.8.0 -PyPowerFlex==1.13.0 -pypsexec==0.3.0 -pypsrp==0.8.1 -pypureomapi==0.8 pyrfc==3.3.1 -pysnmp==7.1.13 -python-dotenv==1.0.1 -python_bcrypt==0.3.2 -python_dateutil==2.9.0.post0 -python_debian==0.1.49 python_ldap==3.4.4 -python_memcached==1.62 -pytz==2024.2 -pyVim==3.0.3 -pyVmomi==8.0.3.0.1 pyxcli==1.2.1 -pyzipper==0.3.6 -requests_oauthlib==2.0.0 -requests_toolbelt==1.0.0 -rfc3339_validator==0.1.4 -rfc3986_validator==0.1.1 -rfc3987==1.3.8 -salt==3007.1 -sansldap==0.1.0 -semantic_version==2.10.0 -setuptools==75.4.0 -simplejson==3.19.3 -smbprotocol==1.15.0 -SoftLayer==6.2.5 -spotinst_sdk==1.0.56 -sshpubkeys==3.3.1 -storops==1.2.11 suds_jurko==0.6 -taiga==0.1.1 -testinfra==6.0.0 -textfsm==1.1.3 -tokenize_rt==6.1.0 -tomli_w==1.1.0 -ttp==0.9.5 -ucsmsdk==0.9.21 -uri_template==1.3.0 -urllib3_secure_extra==0.1.0 -urllib_gssapi==1.0.2 -uvloop==0.21.0 -vdirect_client==4.9.0.post4 -vexatapi==0.0.2 -voluptuous==0.15.2 -watchdog==6.0.0 -webcolors==24.11.1 -websocket_client==1.8.0 -XenAPI==24.37.0 -xkcdpass==1.19.9 -xmljson==0.2.1 xmlrpclib==1.0.1 -xmltodict==0.14.2 -xmpppy==0.7.1 -yarl==1.17.1 -zabbix_api==0.5.6 +blinker==1.6.3 ; python_version >= "3.10" and python_version < "4.0" +click==8.1.7 ; python_version >= "3.10" and python_version < "4.0" +colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows" +flask==3.0.0 ; python_version >= "3.10" and python_version < "4.0" +itsdangerous==2.1.2 ; python_version >= "3.10" and python_version < "4.0" +jinja2==3.1.2 ; python_version >= "3.10" and python_version < "4.0" +markupsafe==2.1.3 ; python_version >= "3.10" and python_version < "4.0" +werkzeug==3.0.0 ; python_version >= "3.10" and python_version < "4.0" +flask==3.0.0 From f794f7beaebac65163178ee73bc1e94945059e20 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 11:00:59 +0200 Subject: [PATCH 059/104] Add Snyk 6 --- .github/workflows/github-actions-demo.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 35fd88954..4d03a2389 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -29,7 +29,6 @@ jobs: - name: Install dependencies run: | pip install pylint black flake8 - pip install -r requirements.txt npm install -g markdownlint-cli editorconfig-checker editorconfig-checker - name: Run unit tests @@ -48,6 +47,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - name: Install Snyk dependencies + run: pip install -r requirements.txt - name: Run Snyk to check for vulnerabilities uses: snyk/actions/python@master env: From 83e2b9d0bc4873c3d4876627e66c408662d7dd0e Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 11:03:42 +0200 Subject: [PATCH 060/104] Add Snyk 7 --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 355b229a8..6a3b89bd9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ ansible-compat==24.9.1 ansible-core==2.17.5 ansible-lint==24.9.2 atheris==2.3.0 -BeautifulSoup==3.2.2 +beautifulsoup4==4.12.3 cps==3.3.6 docker_compose==1.29.2 elasticapm==0 From fd3358a1d0b56efe09911b210f33a3cda0d50c6f Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 11:15:33 +0200 Subject: [PATCH 061/104] Add Snyk 8 --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 6a3b89bd9..6b011eae1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,7 +4,6 @@ ansible-core==2.17.5 ansible-lint==24.9.2 atheris==2.3.0 beautifulsoup4==4.12.3 -cps==3.3.6 docker_compose==1.29.2 elasticapm==0 genie==24.10 From 6ebd1fdd7c9bf6548843eaea987e98a3292a088a Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 12:17:32 +0200 Subject: [PATCH 062/104] Add Docker 1 --- .github/workflows/github-actions-demo.yml | 64 ++++++++++++++++------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 4d03a2389..105de24a7 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -42,29 +42,53 @@ jobs: flake8 . - name: Check markdown files run: markdownlint-cli . - security: - #needs: Pylint + docker-build: + needs: Pylint runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - name: Install Snyk dependencies - run: pip install -r requirements.txt - - name: Run Snyk to check for vulnerabilities - uses: snyk/actions/python@master - env: - SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 with: - command: test - args: --file=requirements.txt --severity-threshold=high #--all-projects --severity-threshold=high - #sonarcloud: + context: . + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }} + ${{ secrets.DOCKERHUB_USERNAME }}/u34:latest + #snyk: # #needs: Pylint # runs-on: ubuntu-latest # steps: - # - uses: actions/checkout@v2 - # with: - # fetch-depth: 0 - # - name: SonarCloud Scan - # uses: SonarSource/sonarcloud-github-action@master - # env: - # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + # - uses: actions/checkout@v2 + # - name: Install Snyk dependencies + # run: pip install -r requirements.txt + # - name: Run Snyk to check for vulnerabilities + # uses: snyk/actions/python@master + # env: + # SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + # with: + # command: test + # args: --file=requirements.txt --severity-threshold=high #--all-projects --severity-threshold=high + sonarcloud: + #needs: Pylint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 82ff2445b5b012dc762c9962acaf74290387df5a Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 12:32:16 +0200 Subject: [PATCH 063/104] Add Docker 2 --- requirements.txt | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/requirements.txt b/requirements.txt index 6b011eae1..8159843f2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,23 +1,11 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> b91e922d2af02823c35b9c20b5605417edd612e4 ansible==10.3.0 ansible-compat==24.9.1 ansible-core==2.17.5 ansible-lint==24.9.2 -atheris==2.3.0 -beautifulsoup4==4.12.3 -docker_compose==1.29.2 -elasticapm==0 -genie==24.10 -jnius==1.1.0 -MySQL-python==1.2.5 -pyats==24.10 -pyFG==0.50 -pyFMG==0.8.6.3 -pyone==6.10.1 -pyrfc==3.3.1 -python_ldap==3.4.4 -pyxcli==1.2.1 -suds_jurko==0.6 -xmlrpclib==1.0.1 blinker==1.6.3 ; python_version >= "3.10" and python_version < "4.0" click==8.1.7 ; python_version >= "3.10" and python_version < "4.0" colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows" @@ -26,4 +14,7 @@ itsdangerous==2.1.2 ; python_version >= "3.10" and python_version < "4.0" jinja2==3.1.2 ; python_version >= "3.10" and python_version < "4.0" markupsafe==2.1.3 ; python_version >= "3.10" and python_version < "4.0" werkzeug==3.0.0 ; python_version >= "3.10" and python_version < "4.0" + +======= flask==3.0.0 +>>>>>>> practice1 From c9dde79918f8fc40f699594d05c683783bbbc6e6 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 12:35:19 +0200 Subject: [PATCH 064/104] Add Docker 3 --- requirements.txt | 7 ------- 1 file changed, 7 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8159843f2..0fc5d5bda 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,3 @@ -<<<<<<< HEAD -<<<<<<< HEAD -======= ->>>>>>> b91e922d2af02823c35b9c20b5605417edd612e4 ansible==10.3.0 ansible-compat==24.9.1 ansible-core==2.17.5 @@ -14,7 +10,4 @@ itsdangerous==2.1.2 ; python_version >= "3.10" and python_version < "4.0" jinja2==3.1.2 ; python_version >= "3.10" and python_version < "4.0" markupsafe==2.1.3 ; python_version >= "3.10" and python_version < "4.0" werkzeug==3.0.0 ; python_version >= "3.10" and python_version < "4.0" - -======= flask==3.0.0 ->>>>>>> practice1 From 31e67da16bbdfe147a8909c4f3a9443bfff370bf Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 17:01:05 +0200 Subject: [PATCH 065/104] Add Trivy 1 --- .github/workflows/github-actions-demo.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 105de24a7..c27be5656 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -66,6 +66,21 @@ jobs: tags: | ${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }} ${{ secrets.DOCKERHUB_USERNAME }}/u34:latest + trivy: + needs: docker-build + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Scan Docker image with Trivy + uses: aquasecurity/trivy-action@master + with: + image-ref: ${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }} + format: 'table' + exit-code: '1' + ignore-unfixed: true + severity: 'CRITICAL,HIGH' #snyk: # #needs: Pylint # runs-on: ubuntu-latest @@ -81,7 +96,7 @@ jobs: # command: test # args: --file=requirements.txt --severity-threshold=high #--all-projects --severity-threshold=high sonarcloud: - #needs: Pylint + #needs: [Pylint, docker-build, image-scan] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 858e1add77b96fdcdba3e0c07f6291699879f393 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 17:09:03 +0200 Subject: [PATCH 066/104] Add Trivy 2 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index c27be5656..8b675260e 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -80,7 +80,7 @@ jobs: format: 'table' exit-code: '1' ignore-unfixed: true - severity: 'CRITICAL,HIGH' + severity: 'CRITICAL' #with HIGH it fails in some Ansible Collections within the Docker #snyk: # #needs: Pylint # runs-on: ubuntu-latest From 6114a057f66c4d72dc2e074e78eb79485a5d7d98 Mon Sep 17 00:00:00 2001 From: u34-georgi-telerik Date: Tue, 12 Nov 2024 17:29:25 +0200 Subject: [PATCH 067/104] Create CONTRIBUTING --- CONTRIBUTING | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 CONTRIBUTING diff --git a/CONTRIBUTING b/CONTRIBUTING new file mode 100644 index 000000000..280a59718 --- /dev/null +++ b/CONTRIBUTING @@ -0,0 +1,37 @@ +# Contributing to U34 +Thank you for your interest in contributing to U34! We welcome and appreciate all contributions, whether they are bug reports, feature requests, or code changes. + +Before you start, please take a moment to review the following guidelines to ensure a smooth and effective contribution process. + +## Code of Conduct + +By participating in this project, you agree to abide by the [Contributor Covenant Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/). Please familiarize yourself with the code of conduct and ensure your contributions align with it. + +## How to Contribute + +There are several ways you can contribute to U34: + +1. **Report Bugs**: If you encounter any bugs or issues, please report them by [opening a new issue](https://github.com/u34-georgi-telerik/devops-programme/issues/new/choose) on the project's GitHub repository. Be sure to provide a clear and detailed description of the problem, including steps to reproduce the issue. + +2. **Suggest Features**: Have an idea for a new feature or an improvement to an existing one? [Open a new issue](https://github.com/u34-georgi-telerik/devops-programme/issues/new/choose) and describe your proposal. We'll be happy to discuss it with you. + +3. **Submit Code Changes**: If you'd like to contribute code changes, follow these steps: + - Fork the repository and create a new branch for your changes. + - Make your changes and ensure they align with the project's coding style and guidelines. + - Write tests for your changes, if applicable. + - Commit your changes and push them to your forked repository. + - [Open a pull request](https://github.com/u34-georgi-telerik/devops-programme/pulls) against the main branch of the original repository. + +4. **Provide Feedback**: Even if you don't have a specific bug report or feature request, we welcome any feedback or suggestions you may have about the project. You can [open a new issue](https://github.com/u34-georgi-telerik/devops-programme/issues/new/choose) or reach out to the project maintainers directly. + +## Development Environment Setup + +To set up your development environment, please follow these steps: + +1. Clone the repository: `git clone https://github.com/u34-georgi-telerik/devops-programme.git` +2. Install the required dependencies: `pip install -r requirements.txt` +3. Run the test suite: `pytest` + +If you have any questions or need further assistance, don't hesitate to [open an issue](https://github.com/u34-georgi-telerik/devops-programme/issues/new/choose) or reach out to the project maintainers. + +We look forward to your contributions and appreciate your involvement in making U34 even better! From 1ad314331270aa7b53163646991759ef4a66f866 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 17:40:58 +0200 Subject: [PATCH 068/104] Add Optional 1 --- .github/workflows/github-actions-demo.yml | 30 ++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 8b675260e..20c7d174b 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -62,25 +62,49 @@ jobs: uses: docker/build-push-action@v2 with: context: . - push: true + # changed initial 'push: true' to 'false' + push: false # we need to check for vulnerabilities first + tags: | ${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }} ${{ secrets.DOCKERHUB_USERNAME }}/u34:latest - trivy: + trivy-scan: needs: docker-build runs-on: ubuntu-latest + outputs: + has_critical_vulnerabilities: ${{ trivy.outputs.exit_code }} steps: - name: Checkout code uses: actions/checkout@v2 - name: Scan Docker image with Trivy uses: aquasecurity/trivy-action@master + continue-on-error: true # Ignore Trivy scan errors because some of them are in used modules, how to deal? with: image-ref: ${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }} format: 'table' exit-code: '1' ignore-unfixed: true severity: 'CRITICAL' #with HIGH it fails in some Ansible Collections within the Docker + push-to-docker: + needs: [docker-build, trivy-scan] + runs-on: ubuntu-latest + if: ${{ needs.trivy-scan.outputs.has_critical_vulnerabilities == '0' }} + steps: + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Push Docker image + uses: docker/build-push-action@v2 + with: + context: . + push: true + tags: | + ${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }} + ${{ secrets.DOCKERHUB_USERNAME }}/u34:latest #snyk: # #needs: Pylint # runs-on: ubuntu-latest @@ -96,7 +120,7 @@ jobs: # command: test # args: --file=requirements.txt --severity-threshold=high #--all-projects --severity-threshold=high sonarcloud: - #needs: [Pylint, docker-build, image-scan] + needs: [Pylint, push-to-docker] runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 875f39b8609c8475b0c17a340c7befd62eb28525 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 17:53:26 +0200 Subject: [PATCH 069/104] Add Optional 2 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 20c7d174b..bce4d9855 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -72,7 +72,7 @@ jobs: needs: docker-build runs-on: ubuntu-latest outputs: - has_critical_vulnerabilities: ${{ trivy.outputs.exit_code }} + has_critical_vulnerabilities: ${{ trivy-scan.outputs.exit_code }} steps: - name: Checkout code uses: actions/checkout@v2 From 9102d7fdf677855ca9eb6236771b51f7bd2619ad Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 17:54:49 +0200 Subject: [PATCH 070/104] Add Optional 3 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index bce4d9855..688980738 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -72,7 +72,7 @@ jobs: needs: docker-build runs-on: ubuntu-latest outputs: - has_critical_vulnerabilities: ${{ trivy-scan.outputs.exit_code }} + has_critical_vulnerabilities: ${{ steps.trivy-scan.outputs.exit_code }} steps: - name: Checkout code uses: actions/checkout@v2 From 0f50994bc6f399b9ad64e49dd3d6e39328e8c044 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 17:55:53 +0200 Subject: [PATCH 071/104] Add Optional 4 --- .github/workflows/github-actions-demo.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 688980738..7c316e934 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -68,11 +68,11 @@ jobs: tags: | ${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }} ${{ secrets.DOCKERHUB_USERNAME }}/u34:latest - trivy-scan: + trivy: needs: docker-build runs-on: ubuntu-latest outputs: - has_critical_vulnerabilities: ${{ steps.trivy-scan.outputs.exit_code }} + has_critical_vulnerabilities: ${{ steps.trivy.outputs.exit_code }} steps: - name: Checkout code uses: actions/checkout@v2 @@ -87,9 +87,9 @@ jobs: ignore-unfixed: true severity: 'CRITICAL' #with HIGH it fails in some Ansible Collections within the Docker push-to-docker: - needs: [docker-build, trivy-scan] + needs: [docker-build, trivy] runs-on: ubuntu-latest - if: ${{ needs.trivy-scan.outputs.has_critical_vulnerabilities == '0' }} + if: ${{ needs.trivy.outputs.has_critical_vulnerabilities == '0' }} steps: - name: Login to Docker Hub uses: docker/login-action@v1 From cfe9731f6684c0845e7214e1271392ca9c2aa542 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 18:09:44 +0200 Subject: [PATCH 072/104] Add Optional 5 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 7c316e934..05d478ce5 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -58,7 +58,7 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push Docker image + - name: Build and do not push Docker image uses: docker/build-push-action@v2 with: context: . From e1c6ce9e1194e06b50931bd834efca33ea55c3e6 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 18:26:30 +0200 Subject: [PATCH 073/104] Add Optional 6 --- .github/workflows/github-actions-demo.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 05d478ce5..36e1b3e50 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -91,6 +91,8 @@ jobs: runs-on: ubuntu-latest if: ${{ needs.trivy.outputs.has_critical_vulnerabilities == '0' }} steps: + - name: Checkout code # Ensures Dockerfile is available + uses: actions/checkout@v2 - name: Login to Docker Hub uses: docker/login-action@v1 with: From 494e3789014b88fc7db928b8cb31aa4430f3c993 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 12 Nov 2024 18:47:39 +0200 Subject: [PATCH 074/104] Add Optional 7 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 36e1b3e50..b53d7cd74 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -87,7 +87,7 @@ jobs: ignore-unfixed: true severity: 'CRITICAL' #with HIGH it fails in some Ansible Collections within the Docker push-to-docker: - needs: [docker-build, trivy] + needs: trivy runs-on: ubuntu-latest if: ${{ needs.trivy.outputs.has_critical_vulnerabilities == '0' }} steps: From 9d9a8904ca0586e7e53160df34c57e8f6d41aa10 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Mon, 18 Nov 2024 16:19:53 +0200 Subject: [PATCH 075/104] Add Optional 9 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index b53d7cd74..59d3f7ad6 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -120,7 +120,7 @@ jobs: # SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} # with: # command: test - # args: --file=requirements.txt --severity-threshold=high #--all-projects --severity-threshold=high + # args: --all-projects --severity-threshold=high sonarcloud: needs: [Pylint, push-to-docker] runs-on: ubuntu-latest From 94bfdb4394dba43981c782c8fb476758206f6cfe Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 12:59:10 +0200 Subject: [PATCH 076/104] Few changes for parallel run 1 --- .github/workflows/github-actions-demo.yml | 161 +++++++++++++--------- 1 file changed, 93 insertions(+), 68 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 59d3f7ad6..5e34a62d5 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -1,104 +1,142 @@ name: GitHub Actions Demo run-name: ${{ github.actor }} is testing out GitHub Actions on: [push] - #push: - # branches-ignore: - # - 'main' + jobs: - Pylint: + pre-commit: runs-on: ubuntu-latest - continue-on-error: true # To remove steps: - - name: Check .editorconfig - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: Set up Python - uses: actions/setup-python@v3 + - uses: actions/checkout@v2 + - uses: actions/setup-python@v3 with: python-version: '3.10' cache: 'pip' - - name: Set up Node.js - uses: actions/setup-node@v3 + - name: Install pre-commit + run: | + python -m pip install pre-commit + pre-commit install + - name: Run pre-commit + run: pre-commit run --all-files + + editorconfig-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Check .editorconfig exists + run: | + if [ ! -f .editorconfig ]; then + echo ".editorconfig file not found in root directory" + exit 1 + fi + - name: Install editorconfig-checker + run: | + npm install -g editorconfig-checker + editorconfig-checker + + secrets-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 with: - node-version: '22' + fetch-depth: 0 - name: Check for hardcoded secrets uses: gitleaks/gitleaks-action@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Install dependencies + + markdown-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '22' + - name: Install markdownlint + run: npm install -g markdownlint-cli + - name: Check markdown files + run: markdownlint-cli . + + code-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.10' + cache: 'pip' + - name: Install linting tools + run: pip install pylint black flake8 + - name: Lint Python code run: | - pip install pylint black flake8 - npm install -g markdownlint-cli editorconfig-checker - editorconfig-checker + find . -name '*.py' | xargs pylint + black --check --diff . + flake8 . + + unit-tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.10' + cache: 'pip' - name: Run unit tests run: | - cd app - python -m unittest discover -v - - name: Lint Python code - run: | - find . -name '*.py' | xargs pylint - black --check --diff . - flake8 . - - name: Check markdown files - run: markdownlint-cli . + cd app + python -m unittest discover -v + docker-build: - needs: Pylint + needs: [pre-commit, editorconfig-check, secrets-check, markdown-check, code-lint, unit-tests] runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v2 - + - uses: actions/checkout@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - - name: Login to Docker Hub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and do not push Docker image + - name: Build Docker image uses: docker/build-push-action@v2 with: context: . - # changed initial 'push: true' to 'false' - push: false # we need to check for vulnerabilities first - + push: false tags: | ${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }} ${{ secrets.DOCKERHUB_USERNAME }}/u34:latest + trivy: needs: docker-build runs-on: ubuntu-latest outputs: has_critical_vulnerabilities: ${{ steps.trivy.outputs.exit_code }} steps: - - name: Checkout code - uses: actions/checkout@v2 - + - uses: actions/checkout@v2 - name: Scan Docker image with Trivy uses: aquasecurity/trivy-action@master - continue-on-error: true # Ignore Trivy scan errors because some of them are in used modules, how to deal? + continue-on-error: true with: image-ref: ${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }} format: 'table' exit-code: '1' ignore-unfixed: true - severity: 'CRITICAL' #with HIGH it fails in some Ansible Collections within the Docker + severity: 'CRITICAL' + push-to-docker: needs: trivy runs-on: ubuntu-latest if: ${{ needs.trivy.outputs.has_critical_vulnerabilities == '0' }} steps: - - name: Checkout code # Ensures Dockerfile is available - uses: actions/checkout@v2 + - uses: actions/checkout@v2 - name: Login to Docker Hub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Push Docker image uses: docker/build-push-action@v2 with: @@ -107,29 +145,16 @@ jobs: tags: | ${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }} ${{ secrets.DOCKERHUB_USERNAME }}/u34:latest - #snyk: - # #needs: Pylint - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v2 - # - name: Install Snyk dependencies - # run: pip install -r requirements.txt - # - name: Run Snyk to check for vulnerabilities - # uses: snyk/actions/python@master - # env: - # SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} - # with: - # command: test - # args: --all-projects --severity-threshold=high + sonarcloud: - needs: [Pylint, push-to-docker] + needs: [push-to-docker] runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file From 3efb8727ba474c7c3a1ad6c73c54f0d148522c0d Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 13:04:47 +0200 Subject: [PATCH 077/104] Few changes for parallel run 2 --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 0fc5d5bda..25a8cd9a3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,3 +11,4 @@ jinja2==3.1.2 ; python_version >= "3.10" and python_version < "4.0" markupsafe==2.1.3 ; python_version >= "3.10" and python_version < "4.0" werkzeug==3.0.0 ; python_version >= "3.10" and python_version < "4.0" flask==3.0.0 +pre-commit==4.0.1 From e93f6c48124ec5253c94b357749c7d247e0c3a81 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 13:16:17 +0200 Subject: [PATCH 078/104] Few changes for parallel run 7 --- .pre-commit-config.yaml | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..667030caf --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,39 @@ +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-merge-conflict + - id: check-case-conflict + - id: check-docstring-first + - id: detect-private-key + +- repo: https://github.com/psf/black + rev: 24.1.1 + hooks: + - id: black + +- repo: https://github.com/PyCQA/flake8 + rev: 7.0.0 + hooks: + - id: flake8 + additional_dependencies: [flake8-docstrings] + +- repo: https://github.com/PyCQA/pylint + rev: v3.0.3 + hooks: + - id: pylint + args: [--disable=C0111] + +- repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.39.0 + hooks: + - id: markdownlint + +- repo: https://github.com/zricethezav/gitleaks + rev: v8.18.2 + hooks: + - id: gitleaks From 53c92cc73bb9c2b5336f296e314fccde8f3ecc13 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 13:20:24 +0200 Subject: [PATCH 079/104] Few changes for parallel run 8 --- .pre-commit-config.yaml | 44 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 667030caf..ec0e20ce0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,25 +15,25 @@ repos: rev: 24.1.1 hooks: - id: black - -- repo: https://github.com/PyCQA/flake8 - rev: 7.0.0 - hooks: - - id: flake8 - additional_dependencies: [flake8-docstrings] - -- repo: https://github.com/PyCQA/pylint - rev: v3.0.3 - hooks: - - id: pylint - args: [--disable=C0111] - -- repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.39.0 - hooks: - - id: markdownlint - -- repo: https://github.com/zricethezav/gitleaks - rev: v8.18.2 - hooks: - - id: gitleaks +# +#- repo: https://github.com/PyCQA/flake8 +# rev: 7.0.0 +# hooks: +# - id: flake8 +# additional_dependencies: [flake8-docstrings] +# +#- repo: https://github.com/PyCQA/pylint +# rev: v3.0.3 +# hooks: +# - id: pylint +# args: [--disable=C0111] +# +#- repo: https://github.com/igorshubovych/markdownlint-cli +# rev: v0.39.0 +# hooks: +# - id: markdownlint +# +#- repo: https://github.com/zricethezav/gitleaks +# rev: v8.18.2 +# hooks: +# - id: gitleaks From 6c044c08661d3478db5ee0ffc89f80151e583e32 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 13:22:43 +0200 Subject: [PATCH 080/104] pre-commit fix 1 --- .pre-commit-config.yaml | 78 ++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ec0e20ce0..90b471eed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,39 +1,39 @@ -repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-added-large-files - - id: check-merge-conflict - - id: check-case-conflict - - id: check-docstring-first - - id: detect-private-key - -- repo: https://github.com/psf/black - rev: 24.1.1 - hooks: - - id: black -# -#- repo: https://github.com/PyCQA/flake8 -# rev: 7.0.0 -# hooks: -# - id: flake8 -# additional_dependencies: [flake8-docstrings] -# -#- repo: https://github.com/PyCQA/pylint -# rev: v3.0.3 -# hooks: -# - id: pylint -# args: [--disable=C0111] -# -#- repo: https://github.com/igorshubovych/markdownlint-cli -# rev: v0.39.0 -# hooks: -# - id: markdownlint -# -#- repo: https://github.com/zricethezav/gitleaks -# rev: v8.18.2 -# hooks: -# - id: gitleaks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files + - id: check-merge-conflict + - id: check-case-conflict + - id: check-docstring-first + - id: detect-private-key +# +#- repo: https://github.com/psf/black +# rev: 24.1.1 +# hooks: +# - id: black +# +#- repo: https://github.com/PyCQA/flake8 +# rev: 7.0.0 +# hooks: +# - id: flake8 +# additional_dependencies: [flake8-docstrings] +# +#- repo: https://github.com/PyCQA/pylint +# rev: v3.0.3 +# hooks: +# - id: pylint +# args: [--disable=C0111] +# +#- repo: https://github.com/igorshubovych/markdownlint-cli +# rev: v0.39.0 +# hooks: +# - id: markdownlint +# +#- repo: https://github.com/zricethezav/gitleaks +# rev: v8.18.2 +# hooks: +# - id: gitleaks From 054c344de5822ded64116e535e5dff0077cc72f9 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 13:26:00 +0200 Subject: [PATCH 081/104] pre-commit fix 2 --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 90b471eed..d6457ab83 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,6 @@ repos: rev: v4.5.0 hooks: - id: trailing-whitespace - - id: end-of-file-fixer - id: check-yaml - id: check-added-large-files - id: check-merge-conflict From aa11e4766ff8786096d0b68c33ecc2969931ccd9 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 13:58:44 +0200 Subject: [PATCH 082/104] editor-config fix 2 --- .github/workflows/github-actions-demo.yml | 2 +- .pre-commit-config.yaml | 76 +++++++++++------------ app/app.py | 18 ++++-- app/app_test.py | 21 ++++++- requirements.txt | 1 - 5 files changed, 72 insertions(+), 46 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 5e34a62d5..f2c75d6c3 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -157,4 +157,4 @@ jobs: uses: SonarSource/sonarcloud-github-action@master env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d6457ab83..204d6e686 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,38 +1,38 @@ -repos: -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 - hooks: - - id: trailing-whitespace - - id: check-yaml - - id: check-added-large-files - - id: check-merge-conflict - - id: check-case-conflict - - id: check-docstring-first - - id: detect-private-key -# -#- repo: https://github.com/psf/black -# rev: 24.1.1 -# hooks: -# - id: black -# -#- repo: https://github.com/PyCQA/flake8 -# rev: 7.0.0 -# hooks: -# - id: flake8 -# additional_dependencies: [flake8-docstrings] -# -#- repo: https://github.com/PyCQA/pylint -# rev: v3.0.3 -# hooks: -# - id: pylint -# args: [--disable=C0111] -# -#- repo: https://github.com/igorshubovych/markdownlint-cli -# rev: v0.39.0 -# hooks: -# - id: markdownlint -# -#- repo: https://github.com/zricethezav/gitleaks -# rev: v8.18.2 -# hooks: -# - id: gitleaks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: trailing-whitespace + - id: check-yaml + - id: check-added-large-files + - id: check-merge-conflict + - id: check-case-conflict + - id: check-docstring-first + - id: detect-private-key +# +#- repo: https://github.com/psf/black +# rev: 24.1.1 +# hooks: +# - id: black +# +#- repo: https://github.com/PyCQA/flake8 +# rev: 7.0.0 +# hooks: +# - id: flake8 +# additional_dependencies: [flake8-docstrings] +# +#- repo: https://github.com/PyCQA/pylint +# rev: v3.0.3 +# hooks: +# - id: pylint +# args: [--disable=C0111] +# +#- repo: https://github.com/igorshubovych/markdownlint-cli +# rev: v0.39.0 +# hooks: +# - id: markdownlint +# +#- repo: https://github.com/zricethezav/gitleaks +# rev: v8.18.2 +# hooks: +# - id: gitleaks diff --git a/app/app.py b/app/app.py index 1c2c83d55..94c7ae8d8 100644 --- a/app/app.py +++ b/app/app.py @@ -1,14 +1,24 @@ -import os +""" +app.py +This module initializes and runs the Flask application. +""" +import os from flask import Flask app = Flask(__name__) - @app.route("/") def hello_world(): + """ + Return a simple greeting message. + """ return "Hello, World!" - if __name__ == "__main__": - app.run(port=os.environ.get("PORT", 5000), host="0.0.0.0") + """ + Entry point for the Flask application. + The app runs on the port specified in the environment variable 'PORT' + or defaults to 5000 and listens on all interfaces. + """ + app.run(port=os.environ.get("PORT", 5000), host="0.0.0.0") \ No newline at end of file diff --git a/app/app_test.py b/app/app_test.py index a1b1bacb2..fb8e9f3a6 100644 --- a/app/app_test.py +++ b/app/app_test.py @@ -1,17 +1,34 @@ -import unittest +""" +app_test.py +This module contains unit tests for the Flask application defined in app.py. +""" +import unittest from app import app class TestApp(unittest.TestCase): + """ + Unit test case for the Flask application. + """ + def setUp(self): + """ + Set up a test client for the Flask application. + """ self.client = app.test_client() def test_hello_world(self): + """ + Test the '/' route to ensure it returns the correct response. + """ response = self.client.get("/") self.assertEqual(response.status_code, 200) self.assertEqual(response.data, b"Hello, World!") if __name__ == "__main__": - unittest.main() + """ + Entry point for running the unit tests. + """ + unittest.main() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 25a8cd9a3..851e9685f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,5 +10,4 @@ itsdangerous==2.1.2 ; python_version >= "3.10" and python_version < "4.0" jinja2==3.1.2 ; python_version >= "3.10" and python_version < "4.0" markupsafe==2.1.3 ; python_version >= "3.10" and python_version < "4.0" werkzeug==3.0.0 ; python_version >= "3.10" and python_version < "4.0" -flask==3.0.0 pre-commit==4.0.1 From 9c832a1d6fcbbc8f6540067e760e0de5ac78f620 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 14:02:59 +0200 Subject: [PATCH 083/104] editor-config fix 3 --- app/app.py | 2 +- app/app_test.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/app.py b/app/app.py index 94c7ae8d8..59900ae8b 100644 --- a/app/app.py +++ b/app/app.py @@ -21,4 +21,4 @@ def hello_world(): The app runs on the port specified in the environment variable 'PORT' or defaults to 5000 and listens on all interfaces. """ - app.run(port=os.environ.get("PORT", 5000), host="0.0.0.0") \ No newline at end of file + app.run(port=os.environ.get("PORT", 5000), host="0.0.0.0") diff --git a/app/app_test.py b/app/app_test.py index fb8e9f3a6..220481c32 100644 --- a/app/app_test.py +++ b/app/app_test.py @@ -31,4 +31,4 @@ def test_hello_world(self): """ Entry point for running the unit tests. """ - unittest.main() \ No newline at end of file + unittest.main() From ff9fae94553de9d5642e99ab586bdd0efb95aa90 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 14:14:02 +0200 Subject: [PATCH 084/104] markdown-check fix 1 --- .github/workflows/github-actions-demo.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index f2c75d6c3..cb9dd624b 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -53,7 +53,9 @@ jobs: with: node-version: '22' - name: Install markdownlint - run: npm install -g markdownlint-cli + run: | + npm install -g markdownlint-cli + echo "::add-path::$(npm bin -g)" - name: Check markdown files run: markdownlint-cli . @@ -67,7 +69,7 @@ jobs: python-version: '3.10' cache: 'pip' - name: Install linting tools - run: pip install pylint black flake8 + run: pip install pylint black flake8 flask - name: Lint Python code run: | find . -name '*.py' | xargs pylint From f3cf76db3310c8f6d5b12ab73f55e19893af268e Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 14:17:32 +0200 Subject: [PATCH 085/104] markdown-check fix 2 --- .github/workflows/github-actions-demo.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index cb9dd624b..3e162eee3 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -55,7 +55,7 @@ jobs: - name: Install markdownlint run: | npm install -g markdownlint-cli - echo "::add-path::$(npm bin -g)" + echo "$(npm config get prefix)/bin" >> $GITHUB_PATH - name: Check markdown files run: markdownlint-cli . From 6b395d61c4e835c803d4bdb2f046fd23eabe4b9f Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 14:22:53 +0200 Subject: [PATCH 086/104] markdown-check fix 3 --- .github/workflows/github-actions-demo.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 3e162eee3..8d92a121a 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -48,16 +48,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: '22' - - name: Install markdownlint - run: | - npm install -g markdownlint-cli - echo "$(npm config get prefix)/bin" >> $GITHUB_PATH - - name: Check markdown files - run: markdownlint-cli . + - name: Run markdown lint with npx + run: npx markdownlint-cli . code-lint: runs-on: ubuntu-latest From 4e4dbbc7ba1450e3fa5295ad638c2640ddb9d222 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 14:30:26 +0200 Subject: [PATCH 087/104] markdown-check fix 4 --- M1-3-Ansible/README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/M1-3-Ansible/README.md b/M1-3-Ansible/README.md index e44faf9c3..bfc936600 100644 --- a/M1-3-Ansible/README.md +++ b/M1-3-Ansible/README.md @@ -2,7 +2,8 @@ ## Ansible Task -Create an Ansible playbook that build, push and then run the Docker image for the Python +Create an Ansible playbook that build, push +and then run the Docker image for the Python application. Let your playbook has the following variables: * `image_name` - contains the name of your image without the tag, i.e. `vutoff/python-app` @@ -17,7 +18,8 @@ Use Ansible modules. Do not shell out. ### Requirements * Make sure you have Python installed. Any version above 3.8 would suffice. -* The `requirements.txt` file in this directory contains the required Ansible version. Run +* The `requirements.txt` in this folder contains the required Ansible version. +* Run ```sh pip install -r requirements.txt @@ -27,7 +29,8 @@ pip install -r requirements.txt ### Mind the following -* If you're running Docker Desktop or Rancher Desktop, mind the location of the `docker.sock` file. The location of the socket file is +* If you're running Docker Desktop or Rancher Desktop, mind the location +* of the `docker.sock` file. The location of the socket file is * Docker Desktop - `${HOME}/.docker/run/docker.sock` * Rancher DEsktop - ${HOME}/.rd/run/docker.sock From 0e28e40b95872907e1f9386a866013659b9582b2 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 14:42:34 +0200 Subject: [PATCH 088/104] markdown-check fix 5 --- app/app.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/app.py b/app/app.py index 59900ae8b..708d729f5 100644 --- a/app/app.py +++ b/app/app.py @@ -16,9 +16,9 @@ def hello_world(): return "Hello, World!" if __name__ == "__main__": - """ - Entry point for the Flask application. - The app runs on the port specified in the environment variable 'PORT' - or defaults to 5000 and listens on all interfaces. - """ + + # Entry point for the Flask application. + # The app runs on the port specified in the environment variable 'PORT' + # or defaults to 5000 and listens on all interfaces. + app.run(port=os.environ.get("PORT", 5000), host="0.0.0.0") From 00c47044dd1df2ff1227bdf92099c9a108d7311d Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 14:44:18 +0200 Subject: [PATCH 089/104] code-lint fix 1 --- app/app_test.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/app_test.py b/app/app_test.py index 220481c32..8d30402bd 100644 --- a/app/app_test.py +++ b/app/app_test.py @@ -26,9 +26,8 @@ def test_hello_world(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.data, b"Hello, World!") - if __name__ == "__main__": - """ - Entry point for running the unit tests. - """ + + # Entry point for running the unit tests. + unittest.main() From 728aa222c9282155da5bdb3e70c5282405b5a2d1 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 14:48:17 +0200 Subject: [PATCH 090/104] code-lint fix 2 --- .github/workflows/github-actions-demo.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 8d92a121a..4a0fbd20c 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -61,11 +61,10 @@ jobs: python-version: '3.10' cache: 'pip' - name: Install linting tools - run: pip install pylint black flake8 flask + run: pip install pylint flake8 flask - name: Lint Python code run: | find . -name '*.py' | xargs pylint - black --check --diff . flake8 . unit-tests: From 34f93f629437dc85c9ae7b8fa1b12d6badd8236e Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 14:50:30 +0200 Subject: [PATCH 091/104] code-lint fix 3 --- app/app.py | 2 ++ app/app_test.py | 1 + 2 files changed, 3 insertions(+) diff --git a/app/app.py b/app/app.py index 708d729f5..94dffc93c 100644 --- a/app/app.py +++ b/app/app.py @@ -8,6 +8,7 @@ app = Flask(__name__) + @app.route("/") def hello_world(): """ @@ -15,6 +16,7 @@ def hello_world(): """ return "Hello, World!" + if __name__ == "__main__": # Entry point for the Flask application. diff --git a/app/app_test.py b/app/app_test.py index 8d30402bd..aad6eb6d4 100644 --- a/app/app_test.py +++ b/app/app_test.py @@ -26,6 +26,7 @@ def test_hello_world(self): self.assertEqual(response.status_code, 200) self.assertEqual(response.data, b"Hello, World!") + if __name__ == "__main__": # Entry point for running the unit tests. From 1dfff7281aedc44fe05d3d9ac2a460fb6aeb54db Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 15:06:20 +0200 Subject: [PATCH 092/104] pre-commit optimizations 3 --- .pre-commit-config.yaml | 52 ++++++++++++++--------------------------- 1 file changed, 17 insertions(+), 35 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 204d6e686..d35406e2f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,38 +1,20 @@ +--- repos: -- repo: https://github.com/pre-commit/pre-commit-hooks + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.5.0 hooks: - - id: trailing-whitespace - - id: check-yaml - - id: check-added-large-files - - id: check-merge-conflict - - id: check-case-conflict - - id: check-docstring-first - - id: detect-private-key -# -#- repo: https://github.com/psf/black -# rev: 24.1.1 -# hooks: -# - id: black -# -#- repo: https://github.com/PyCQA/flake8 -# rev: 7.0.0 -# hooks: -# - id: flake8 -# additional_dependencies: [flake8-docstrings] -# -#- repo: https://github.com/PyCQA/pylint -# rev: v3.0.3 -# hooks: -# - id: pylint -# args: [--disable=C0111] -# -#- repo: https://github.com/igorshubovych/markdownlint-cli -# rev: v0.39.0 -# hooks: -# - id: markdownlint -# -#- repo: https://github.com/zricethezav/gitleaks -# rev: v8.18.2 -# hooks: -# - id: gitleaks + - id: check-merge-conflict + - id: check-added-large-files + args: ['--maxkb=500'] + - id: detect-private-key + + - repo: https://github.com/zricethezav/gitleaks + rev: v8.18.1 + hooks: + - id: gitleaks + + - repo: https://github.com/adrienverge/yamllint + rev: v1.33.0 + hooks: + - id: yamllint + args: [--format, parsable, --strict] From 693fe18f17767334288a79026d862961dbc8ef60 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 15:31:27 +0200 Subject: [PATCH 093/104] pre-commit optimizations 4 --- .github/workflows/github-actions-demo.yml | 21 +++++++++++++++------ .pre-commit-config.yaml | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 4a0fbd20c..96bcb7146 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -1,6 +1,9 @@ -name: GitHub Actions Demo -run-name: ${{ github.actor }} is testing out GitHub Actions -on: [push] +--- +name: GitHub Actions Homework Demo +on: + push: + branches: + - main jobs: pre-commit: @@ -82,7 +85,13 @@ jobs: python -m unittest discover -v docker-build: - needs: [pre-commit, editorconfig-check, secrets-check, markdown-check, code-lint, unit-tests] + needs: + - pre-commit + - editorconfig-check + - secrets-check + - markdown-check + - code-lint + - unit-tests runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -98,7 +107,7 @@ jobs: with: context: . push: false - tags: | + tags: >- ${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }} ${{ secrets.DOCKERHUB_USERNAME }}/u34:latest @@ -135,7 +144,7 @@ jobs: with: context: . push: true - tags: | + tags: >- ${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }} ${{ secrets.DOCKERHUB_USERNAME }}/u34:latest diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d35406e2f..af2b535b8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -17,4 +17,4 @@ repos: rev: v1.33.0 hooks: - id: yamllint - args: [--format, parsable, --strict] + args: [--format, parsable, --no-warnings] From 343c281eeedeb6c19cf31cfe2bf4bf29509a7fa1 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 15:37:38 +0200 Subject: [PATCH 094/104] pre-commit optimizations 5 --- .github/workflows/github-actions-demo.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 96bcb7146..ae2f00bcb 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -107,7 +107,7 @@ jobs: with: context: . push: false - tags: >- + tags: | ${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }} ${{ secrets.DOCKERHUB_USERNAME }}/u34:latest @@ -144,7 +144,7 @@ jobs: with: context: . push: true - tags: >- + tags: | ${{ secrets.DOCKERHUB_USERNAME }}/u34:${{ github.sha }} ${{ secrets.DOCKERHUB_USERNAME }}/u34:latest From 67c2cd181b73835f7a175f70d8c2459330f15e5c Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 15:48:58 +0200 Subject: [PATCH 095/104] add snyk 1 --- .github/workflows/github-actions-demo.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index ae2f00bcb..550c5b6d4 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -128,6 +128,18 @@ jobs: ignore-unfixed: true severity: 'CRITICAL' + snyk: + needs: docker-build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Run Snyk to check for vulnerabilities + uses: snyk/actions/python@master + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + with: + command: test + push-to-docker: needs: trivy runs-on: ubuntu-latest From 4a4b2068eba6c88dab4cb1aff8773d6319512a60 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 15:50:27 +0200 Subject: [PATCH 096/104] add snyk 2 --- .github/workflows/github-actions-demo.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 550c5b6d4..7f219832c 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -141,7 +141,9 @@ jobs: command: test push-to-docker: - needs: trivy + needs: + - trivy + - snyk runs-on: ubuntu-latest if: ${{ needs.trivy.outputs.has_critical_vulnerabilities == '0' }} steps: From 50d73f995331d0bd9e5aa4f0a9bc96eaebb154fd Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 15:57:57 +0200 Subject: [PATCH 097/104] add snyk 3 --- .github/workflows/github-actions-demo.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 7f219832c..68856d5d9 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -135,6 +135,7 @@ jobs: - uses: actions/checkout@v2 - name: Run Snyk to check for vulnerabilities uses: snyk/actions/python@master + continue-on-error: true env: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} with: From 45fd88b021876df4c3996cc49fa88a50c4eb55b2 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 16:21:06 +0200 Subject: [PATCH 098/104] add docker compose 1 --- .github/workflows/github-actions-demo.yml | 1 + docker-compose.yml | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 docker-compose.yml diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 68856d5d9..4d2d7f646 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -1,5 +1,6 @@ --- name: GitHub Actions Homework Demo +run-name: ${{ github.actor }} is testing out GitHub Actions on: push: branches: diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..bd271a1c5 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,9 @@ +--- +version: '3.8' +services: + app: + build: . + ports: + - "5000:5000" + volumes: + - .:/app From e8c7407b5e1e3b28c33aa15e91748875c037d5e8 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 16:30:00 +0200 Subject: [PATCH 099/104] add docker compose 3 --- .github/workflows/github-actions-demo.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/github-actions-demo.yml index 4d2d7f646..f029c41f3 100644 --- a/.github/workflows/github-actions-demo.yml +++ b/.github/workflows/github-actions-demo.yml @@ -142,6 +142,23 @@ jobs: with: command: test + docker-compose: + needs: docker-build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Docker Compose + run: | + BASEURL="https://github.com/docker/compose/releases/latest/download" + FILENAME="docker-compose-$(uname -s)-$(uname -m)" + sudo curl -L "${BASEURL}/${FILENAME}" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + - name: Build and Run Container with Docker Compose + run: | + docker-compose up -d --build + docker-compose ps + docker-compose logs + push-to-docker: needs: - trivy From 2d45b9d3f31006512032f7d9e9caa6a2100ffb68 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 16:44:40 +0200 Subject: [PATCH 100/104] restructuring the repo --- .../workflows/{github-actions-demo.yml => ci-pipeline.yml} | 0 .markdownlint.json | 6 ++++++ 2 files changed, 6 insertions(+) rename .github/workflows/{github-actions-demo.yml => ci-pipeline.yml} (100%) create mode 100644 .markdownlint.json diff --git a/.github/workflows/github-actions-demo.yml b/.github/workflows/ci-pipeline.yml similarity index 100% rename from .github/workflows/github-actions-demo.yml rename to .github/workflows/ci-pipeline.yml diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 000000000..1b47b467f --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,6 @@ +{ + "default": true, + "MD013": { + "line_length": 120 + } + } \ No newline at end of file From 7b3f1c3f54b3500352a8e56e08baf1c987c6d8a8 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 17:01:45 +0200 Subject: [PATCH 101/104] restructuring the repo --- {M1-3-Ansible => ansible}/README.md | 9 ++-- ansible/playbook.yml | 76 +++++++++++++++++++++++++++++ app/README.md | 36 ++++++++++++++ 3 files changed, 115 insertions(+), 6 deletions(-) rename {M1-3-Ansible => ansible}/README.md (82%) create mode 100644 ansible/playbook.yml create mode 100644 app/README.md diff --git a/M1-3-Ansible/README.md b/ansible/README.md similarity index 82% rename from M1-3-Ansible/README.md rename to ansible/README.md index bfc936600..e44faf9c3 100644 --- a/M1-3-Ansible/README.md +++ b/ansible/README.md @@ -2,8 +2,7 @@ ## Ansible Task -Create an Ansible playbook that build, push -and then run the Docker image for the Python +Create an Ansible playbook that build, push and then run the Docker image for the Python application. Let your playbook has the following variables: * `image_name` - contains the name of your image without the tag, i.e. `vutoff/python-app` @@ -18,8 +17,7 @@ Use Ansible modules. Do not shell out. ### Requirements * Make sure you have Python installed. Any version above 3.8 would suffice. -* The `requirements.txt` in this folder contains the required Ansible version. -* Run +* The `requirements.txt` file in this directory contains the required Ansible version. Run ```sh pip install -r requirements.txt @@ -29,8 +27,7 @@ pip install -r requirements.txt ### Mind the following -* If you're running Docker Desktop or Rancher Desktop, mind the location -* of the `docker.sock` file. The location of the socket file is +* If you're running Docker Desktop or Rancher Desktop, mind the location of the `docker.sock` file. The location of the socket file is * Docker Desktop - `${HOME}/.docker/run/docker.sock` * Rancher DEsktop - ${HOME}/.rd/run/docker.sock diff --git a/ansible/playbook.yml b/ansible/playbook.yml new file mode 100644 index 000000000..c2bbbc1d5 --- /dev/null +++ b/ansible/playbook.yml @@ -0,0 +1,76 @@ +- name: Build, push and run Docker container + hosts: localhost + vars: + image_name: "ghristov/practice1" + image_tag: "e934bdd" + listen_port: 5000 + full_image_name: "{{ image_name }}:{{ image_tag }}" + dockerfile_path: "../" + + tasks: + - name: Is Docker Python SDK installed + pip: + name: docker + state: present + become: true + + - name: Is Dockerfile exists in parent dir + stat: + path: "{{ dockerfile_path }}/Dockerfile" + register: dockerfile_check + + - name: Fail if Dockerfile is missing + fail: + msg: "Dockerfile not found" + when: not dockerfile_check.stat.exists + + - name: Build Docker image + community.docker.docker_image: + name: "{{ image_name }}" + tag: "{{ image_tag }}" + source: build + build: + path: "{{ dockerfile_path }}" + pull: yes + force_source: yes + state: present + register: build_result + + - name: Log into Docker registry + community.docker.docker_login: + username: "{{ docker_username }}" + password: "{{ docker_password }}" + when: docker_username is defined and docker_password is defined + register: login_result + + - name: Push Docker image to registry + community.docker.docker_image: + name: "{{ full_image_name }}" + push: yes + source: local + when: + - docker_username is defined + - docker_password is defined + - build_result is succeeded + register: push_result + + - name: If existing container then remove + community.docker.docker_container: + name: ansible-test + state: absent + force_kill: yes + ignore_errors: yes + + - name: Run Docker container + community.docker.docker_container: + name: ansible-test + image: "{{ full_image_name }}" + state: started + recreate: yes + pull: false + ports: + - "{{ listen_port }}:{{ listen_port }}" + env: + PORT: "{{ listen_port | string }}" + restart_policy: unless-stopped + when: build_result is succeeded diff --git a/app/README.md b/app/README.md new file mode 100644 index 000000000..cf15ef803 --- /dev/null +++ b/app/README.md @@ -0,0 +1,36 @@ +## Simple Flask Application +This is a basic Flask application that demonstrates setting up a route and returning a response. + +Getting Started + +Prerequisites: + +Python 3.x installed. +Flask package installed: pip install Flask +Running the application: + +Save the code as app.py. +Open your terminal and navigate to the directory containing app.py. +Run the application: python app.py +This will start the Flask development server, typically accessible at http://localhost:5000/ by default. + +Explanation: + +The app.py file initializes a Flask application instance using Flask(__name__). +The @app.route("/") decorator defines a route handler for the root path (/). +The hello_world() function is the view function associated with the root route. It returns a simple "Hello, World!" message. +The if __name__ == "__main__": block ensures the application code only runs when executed directly (not imported as a module). +Inside this block, app.run() starts the development server. It listens on all interfaces (0.0.0.0) and uses the port specified by the environment variable PORT (defaulting to 5000). +Deployment: + +For production deployment, consider using a WSGI server like Gunicorn. Refer to the Flask documentation for more details on deployment strategies: https://flask.palletsprojects.com/en/2.2.x/deploying/ + +Further Development: + +This application serves as a basic example. You can explore Flask's rich features to build more complex web applications: + +Define additional routes for different functionalities. +Use templates for dynamic content generation. +Handle HTTP methods (GET, POST, etc.) for user interaction. +Integrate with databases for persistent data storage. +By building upon this foundation, you can create robust and scalable web applications using Flask. \ No newline at end of file From fee522df54f52b3f71026a33611fb0c3a98788c0 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 17:11:03 +0200 Subject: [PATCH 102/104] restructuring the repo 3 --- .markdownlint.json | 2 +- ansible/README.md | 4 +--- app/README.md | 15 ++++++++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.markdownlint.json b/.markdownlint.json index 1b47b467f..23feb0510 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -3,4 +3,4 @@ "MD013": { "line_length": 120 } - } \ No newline at end of file + } diff --git a/ansible/README.md b/ansible/README.md index e44faf9c3..553cbbe5a 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -1,6 +1,4 @@ -# M1-3-1 Configuration Management - -## Ansible Task +# Configuration Management with Ansible Create an Ansible playbook that build, push and then run the Docker image for the Python application. Let your playbook has the following variables: diff --git a/app/README.md b/app/README.md index cf15ef803..f622641f9 100644 --- a/app/README.md +++ b/app/README.md @@ -1,4 +1,5 @@ -## Simple Flask Application +# Simple Flask Application + This is a basic Flask application that demonstrates setting up a route and returning a response. Getting Started @@ -12,7 +13,7 @@ Running the application: Save the code as app.py. Open your terminal and navigate to the directory containing app.py. Run the application: python app.py -This will start the Flask development server, typically accessible at http://localhost:5000/ by default. +This will start the Flask development server, typically accessible at localhost port 5000 by default. Explanation: @@ -20,10 +21,14 @@ The app.py file initializes a Flask application instance using Flask(__name__). The @app.route("/") decorator defines a route handler for the root path (/). The hello_world() function is the view function associated with the root route. It returns a simple "Hello, World!" message. The if __name__ == "__main__": block ensures the application code only runs when executed directly (not imported as a module). -Inside this block, app.run() starts the development server. It listens on all interfaces (0.0.0.0) and uses the port specified by the environment variable PORT (defaulting to 5000). +Inside this block, app.run() starts the development server. It listens on all interfaces (0.0.0.0) and uses the port +specified by the environment variable PORT (defaulting to 5000). + Deployment: -For production deployment, consider using a WSGI server like Gunicorn. Refer to the Flask documentation for more details on deployment strategies: https://flask.palletsprojects.com/en/2.2.x/deploying/ +For production deployment, consider using a WSGI server like Gunicorn. +Refer to the Flask documentation for more details on deployment strategies at +flask.palletsprojects.com project Further Development: @@ -33,4 +38,4 @@ Define additional routes for different functionalities. Use templates for dynamic content generation. Handle HTTP methods (GET, POST, etc.) for user interaction. Integrate with databases for persistent data storage. -By building upon this foundation, you can create robust and scalable web applications using Flask. \ No newline at end of file +By building upon this foundation, you can create robust and scalable web applications using Flask. From 4d2f42de06073c55858b4162ff73009d54b8135f Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 17:14:43 +0200 Subject: [PATCH 103/104] restructuring the repo 4 --- ansible/README.md | 9 ++++----- app/README.md | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ansible/README.md b/ansible/README.md index 553cbbe5a..9e1611817 100644 --- a/ansible/README.md +++ b/ansible/README.md @@ -1,4 +1,4 @@ -# Configuration Management with Ansible +# Configuration Management with Ansible Create an Ansible playbook that build, push and then run the Docker image for the Python application. Let your playbook has the following variables: @@ -12,7 +12,7 @@ in the Ansible playbook that takes its value from `listen_port` variable. Use Ansible modules. Do not shell out. -### Requirements +## Requirements * Make sure you have Python installed. Any version above 3.8 would suffice. * The `requirements.txt` file in this directory contains the required Ansible version. Run @@ -23,11 +23,10 @@ pip install -r requirements.txt * Make sure that Docker is running on your local machine. -### Mind the following +## Mind the following -* If you're running Docker Desktop or Rancher Desktop, mind the location of the `docker.sock` file. The location of the socket file is +* If you're running Docker Desktop, mind the location of the `docker.sock` file. The location of the socket file is * Docker Desktop - `${HOME}/.docker/run/docker.sock` - * Rancher DEsktop - ${HOME}/.rd/run/docker.sock * If you're using one of the above, when you write your Ansible playbook you must specify the path to the docker socket with the parameter `docker_host`, diff --git a/app/README.md b/app/README.md index f622641f9..362f6f575 100644 --- a/app/README.md +++ b/app/README.md @@ -1,4 +1,4 @@ -# Simple Flask Application +# Simple Flask Application This is a basic Flask application that demonstrates setting up a route and returning a response. @@ -26,8 +26,8 @@ specified by the environment variable PORT (defaulting to 5000). Deployment: -For production deployment, consider using a WSGI server like Gunicorn. -Refer to the Flask documentation for more details on deployment strategies at +For production deployment, consider using a WSGI server like Gunicorn. +Refer to the Flask documentation for more details on deployment strategies at flask.palletsprojects.com project Further Development: From 8135625855f80df88a7e8344126e792ea9251cd4 Mon Sep 17 00:00:00 2001 From: Georgi Hristov Date: Tue, 19 Nov 2024 17:20:52 +0200 Subject: [PATCH 104/104] run on a branch --- .github/workflows/ci-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index f029c41f3..7ffeb2391 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -4,7 +4,7 @@ run-name: ${{ github.actor }} is testing out GitHub Actions on: push: branches: - - main + - github-actions-practice jobs: pre-commit: