Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create main.yml #19

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Django-app workflow

on: [push]

jobs:
tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Install dependencies
run: |
# обновление pip
python -m pip install --upgrade pip
# установка flake8 и его плагинов
pip install flake8 pep8-naming flake8-broken-line flake8-return flake8-isort
# установка зависимостей
pip install -r requirements.txt

- name: Test with flake8 and django tests
run: |
# запуск проверки проекта по flake8
python -m flake8
# перейти в папку, содержащую manage.py —
#<корневая_папка_infra_actions>/<папка_проекта>/manage.py
cd infra_project/
# запустить написанные разработчиком тесты
python manage.py test

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ __pycache__/
.vscode/
*.code-workspace

# C extensions

*.so

# Distribution / packaging
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ COPY ./ /app
RUN pip install -r /app/requirements.txt
WORKDIR /app/infra_project/
CMD python manage.py runserver 0:5000

9 changes: 6 additions & 3 deletions infra_project/infra_app/tests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# infra_project/infra_app/tests.py

from http import HTTPStatus

from django.test import Client, TestCase


Expand All @@ -11,13 +14,13 @@ def test_about_url_exists_at_desired_location(self):
response = self.guest_client.get('/')
self.assertEqual(response.status_code, HTTPStatus.OK)

response = self.guest_client.get('/second_page/')
response = self.guest_client.get('/second/')
self.assertEqual(response.status_code, HTTPStatus.OK)

def test_page_shows_correct_content(self):
"""Проверка контента страниц."""
response = self.guest_client.get('/')
self.assertContains(response, 'У меня получилось!')

response = self.guest_client.get('/second_page/')
self.assertContains(response, 'А это вторая страница!')
response = self.guest_client.get('/second/')
self.assertContains(response, 'А это вторая страница')
12 changes: 0 additions & 12 deletions infra_project/infra_project/settings.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
"""
Django settings for infra_project project.

Generated by 'django-admin startproject' using Django 2.2.20.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
Expand Down
3 changes: 1 addition & 2 deletions infra_project/infra_project/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""infra_project URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Expand All @@ -14,7 +13,7 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.urls import include, path

urlpatterns = [
path('', include('infra_app.urls', namespace='infra_app')),
Expand Down
1 change: 0 additions & 1 deletion infra_project/manage.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys

Expand Down
12 changes: 12 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[flake8]
ignore =
W503,
F811
exclude =
tests/,
*/migrations/,
venv/,
env/
per-file-ignores =
*/settings.py:E501
max-complexity = 10