From 26d70050334974ea88ae1d5889dc28a4712bad07 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 12:55:30 +0300 Subject: [PATCH 01/19] get the codebase --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34fa441..6f2b910 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,5 +9,7 @@ jobs: docker-lint: runs-on: ubuntu-latest steps: - - name: lint dockerfile - run: echo hello + - name: Getting the codebase + uses: actions/checkout@v4 + with: + ref: dev From 58549226d0162ede43f9c90502f5517be4845b26 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 12:57:04 +0300 Subject: [PATCH 02/19] fix Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b1750b1..8a6e1cf 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM python:3.11-alpine WORKDIR /app COPY requirements.txt . -RUN pip install -r requirements.txt +RUN pip install --no-cache-dir -r requirements.txt COPY ./mysite ./mysite COPY ./polls ./polls From 1c6144c3f3781b059e339b2fc864380bc9fad412 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 12:57:22 +0300 Subject: [PATCH 03/19] add lint step --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f2b910..d7a0270 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,3 +13,7 @@ jobs: uses: actions/checkout@v4 with: ref: dev + - name: Lint the Dockerfile + uses: hadolint/hadolint-action@v3.1.0 + with: + dockerfile: Dockerfile From badc8d02cd54130db2b1af5d4e69c23e454b5059 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 13:01:14 +0300 Subject: [PATCH 04/19] rename stage --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7a0270..d938681 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ on: - dev jobs: - docker-lint: + linters: runs-on: ubuntu-latest steps: - name: Getting the codebase From 531e2dd76b13a47c27c85e8ab768f68725f2d667 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 15:41:14 +0300 Subject: [PATCH 05/19] pylint --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d938681..1808921 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,3 +17,8 @@ jobs: uses: hadolint/hadolint-action@v3.1.0 with: dockerfile: Dockerfile + - name: Lint the source code + uses: Silleellie/pylint-github-action@v2.1 + with: + lint-path: mysite # lint src package + python-version: 3.11 # python version which will lint the package From 381015795e3cf4ee2f0a63bc5713028d3cbdc2d8 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 15:41:44 +0300 Subject: [PATCH 06/19] fix ci --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1808921..79061ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,6 +19,6 @@ jobs: dockerfile: Dockerfile - name: Lint the source code uses: Silleellie/pylint-github-action@v2.1 - with: - lint-path: mysite # lint src package - python-version: 3.11 # python version which will lint the package + with: + lint-path: mysite # lint src package + python-version: 3.11 # python version which will lint the package From 03dca5f38c7419a421682094ef3753b0adee9c3d Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 17:15:42 +0300 Subject: [PATCH 07/19] pylint --- .github/workflows/ci.yml | 2 ++ README.md | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79061ee..99c3036 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,4 +21,6 @@ jobs: uses: Silleellie/pylint-github-action@v2.1 with: lint-path: mysite # lint src package + requirements-path: requirements.txt + readme-path: README.md python-version: 3.11 # python version which will lint the package diff --git a/README.md b/README.md index cdcff97..90cd8ec 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ # Django example app Application made by django's instruction for **DevOps** education purposes + +# Pylint + +![pylint]() From 51e7871c69a6923aa11a40fe07cd66693008acea Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Jun 2025 14:16:15 +0000 Subject: [PATCH 08/19] Updated pylint badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 90cd8ec..ce31c5e 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ Application made by django's instruction for **DevOps** education purposes # Pylint -![pylint]() +![pylint](https://img.shields.io/badge/PyLint-9.38-yellow?logo=python&logoColor=white) From a2daa9f641b79aa4728cfeb61de472eceb475f0c Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 18:49:41 +0300 Subject: [PATCH 09/19] add some files to lint --- .github/workflows/ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99c3036..8fb5c1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,10 @@ jobs: - name: Lint the source code uses: Silleellie/pylint-github-action@v2.1 with: - lint-path: mysite # lint src package + lint-path: | + mysite + polls + manage.py requirements-path: requirements.txt readme-path: README.md python-version: 3.11 # python version which will lint the package From c43c3e2c1f9c66c9ef28e3089548aca0dc4b46d0 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Jun 2025 15:50:14 +0000 Subject: [PATCH 10/19] Updated pylint badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ce31c5e..15ce7d5 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ Application made by django's instruction for **DevOps** education purposes # Pylint -![pylint](https://img.shields.io/badge/PyLint-9.38-yellow?logo=python&logoColor=white) +![pylint](https://img.shields.io/badge/PyLint-6.27-orange?logo=python&logoColor=white) From 2ce3e6978eea6afbbe96cc771c108dbad589348e Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 22:53:39 +0300 Subject: [PATCH 11/19] add fake test for educational --- polls/tests.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/polls/tests.py b/polls/tests.py index 01460c9..0cf692e 100644 --- a/polls/tests.py +++ b/polls/tests.py @@ -123,3 +123,6 @@ class QuestionDetailViewTests(TestCase): url = reverse("polls:detail", args=(past_question.id,)) response = self.client.get(url) self.assertContains(response, past_question.question_text) + def test_fake_test(self): + self.assertEqual(0, 1) + From 091e77605e1d6cab2da29574f91358166ca09562 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 22:54:27 +0300 Subject: [PATCH 12/19] add some steps --- .github/workflows/ci.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8fb5c1c..6245c03 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,3 +27,16 @@ jobs: requirements-path: requirements.txt readme-path: README.md python-version: 3.11 # python version which will lint the package + - name: Notify in telegram about fail + if: ${{ failure() }} + uses: appleboy/telegram-action@master + with: + to: ${{ secrets.TELEGRAM_TO }} + token: ${{ secrets.TELEGRAM_TOKEN }} + message: | + ${{ github.actor }} created commit: + Commit message: ${{ github.event.commits[0].message }} + Repository: ${{ github.repository }} + See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}} + - name: Check fail + run: echo "Unreachable" From 1312a4d7fae49ed1491ba2a1175b9d77350ac09a Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Jun 2025 19:55:04 +0000 Subject: [PATCH 13/19] Updated pylint badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 15ce7d5..f7d5d35 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ Application made by django's instruction for **DevOps** education purposes # Pylint -![pylint](https://img.shields.io/badge/PyLint-6.27-orange?logo=python&logoColor=white) +![pylint](https://img.shields.io/badge/PyLint-6.20-orange?logo=python&logoColor=white) From 9957c1a39e7fe29f1f89704e3c6e85ce03225738 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 22:57:32 +0300 Subject: [PATCH 14/19] add pytest to requirements --- requirements.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/requirements.txt b/requirements.txt index ab453d0..04d180b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,14 @@ asgiref==3.8.1 Django==5.2.1 django-debug-toolbar==5.2.0 +iniconfig==2.1.0 +packaging==25.0 pip==23.0.1 +pluggy==1.6.0 psycopg==3.2.9 psycopg-binary==3.2.9 +Pygments==2.19.1 +pytest==8.4.0 setuptools==66.1.1 sqlparse==0.5.3 typing_extensions==4.14.0 From 099b5d487fbf30b34200ed2868584962a74b9dc5 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 23:00:31 +0300 Subject: [PATCH 15/19] ignore __pycache__ --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c234e10..5e8a3f9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ venv polls/__pycache__ polls/migrations/__pycache__ .env +tests/__pycache__ From 6be0920cf8bfab77460f98518010baf3e7b8ea63 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 23:00:39 +0300 Subject: [PATCH 16/19] add some tests to pytest --- tests/__init__.py | 0 tests/test_fail.py | 2 ++ tests/test_success.py | 2 ++ 3 files changed, 4 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/test_fail.py create mode 100644 tests/test_success.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_fail.py b/tests/test_fail.py new file mode 100644 index 0000000..830f318 --- /dev/null +++ b/tests/test_fail.py @@ -0,0 +1,2 @@ +def test_fail(): + assert False diff --git a/tests/test_success.py b/tests/test_success.py new file mode 100644 index 0000000..b5d98d0 --- /dev/null +++ b/tests/test_success.py @@ -0,0 +1,2 @@ +def test_success(): + assert True From 0e40347a66baf1f0f3282dff416d71910471bbe8 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 23:01:51 +0300 Subject: [PATCH 17/19] add tests to pytest --- .github/workflows/ci.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6245c03..be21064 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,17 @@ jobs: requirements-path: requirements.txt readme-path: README.md python-version: 3.11 # python version which will lint the package + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Run tests + run: pytest + - name: Notify in telegram about fail if: ${{ failure() }} uses: appleboy/telegram-action@master @@ -38,5 +49,6 @@ jobs: Commit message: ${{ github.event.commits[0].message }} Repository: ${{ github.repository }} See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}} + - name: Check fail run: echo "Unreachable" From e988a1fa4da4a9c180a8a2d6fc5187d47f918e40 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 23:03:29 +0300 Subject: [PATCH 18/19] add new trigger --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be21064..2612c31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,10 @@ on: branches: - dev + pull_request: + branches: + - main + jobs: linters: runs-on: ubuntu-latest From 72fa1d1439328bbdeb1b67bb30b186cb2031b852 Mon Sep 17 00:00:00 2001 From: Basyrov Rustam Date: Thu, 5 Jun 2025 23:06:42 +0300 Subject: [PATCH 19/19] fix test --- tests/test_fail.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_fail.py b/tests/test_fail.py index 830f318..d29d95b 100644 --- a/tests/test_fail.py +++ b/tests/test_fail.py @@ -1,2 +1,3 @@ def test_fail(): - assert False + # Fixed + assert 1 == 1