diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34fa441..2612c31 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,9 +5,54 @@ on: branches: - dev + pull_request: + branches: + - main + jobs: - docker-lint: + linters: runs-on: ubuntu-latest steps: - - name: lint dockerfile - run: echo hello + - name: Getting the codebase + uses: actions/checkout@v4 + with: + ref: dev + - name: Lint the Dockerfile + 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 + polls + manage.py + 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 + 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" 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__ 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 diff --git a/README.md b/README.md index cdcff97..f7d5d35 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](https://img.shields.io/badge/PyLint-6.20-orange?logo=python&logoColor=white) 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) + 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 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..d29d95b --- /dev/null +++ b/tests/test_fail.py @@ -0,0 +1,3 @@ +def test_fail(): + # Fixed + assert 1 == 1 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