-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* reorganized the folders, created the initial setup, and created the base html * added the make live command * fixed missing the command in PHONY * Created pipeline for CI, fixed the requirements of the project and make a new test for testing CI * Created pipeline for CI, fixed the requirements of the project and make a new test for testing CI * Fixed the error of requirements.test.txt and removed livereload untill find a way to use it with tests * Fixed the error of missing pflake on requirements * Fixed the test, removed --forked from test * Update views.py
- Loading branch information
Showing
9 changed files
with
135 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
pull_request: | ||
branches: | ||
- "main" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
lint: | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
python-version: ['3.12'] | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip-${{ matrix.python-version }}- | ||
- name: Install Project | ||
run: pip install '.[test]' | ||
- name: Look for style errors | ||
run: flake8 app --ignore=F401,F821,E501 | ||
- name: Checking for importing style | ||
run: isort --profile=black --check --diff app | ||
- name: Look for auto format errors | ||
run: black --check --diff app | ||
|
||
tests: | ||
needs: lint | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ['3.10', '3.12'] | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Cache dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip-${{ matrix.python-version }}- | ||
- name: Install Project | ||
run: pip install '.[test]' | ||
- name: Run tests | ||
run: pytest -v --junitxml=test-result.xml | ||
- name: Publish Test Results | ||
uses: EnricoMi/publish-unit-test-result-action@v2.16.1 | ||
if: always() | ||
with: | ||
files: test-result.xml | ||
check_name: Test Result (Python ${{ matrix.python-version }}) | ||
permissions: | ||
contents: read | ||
issues: read | ||
checks: write | ||
pull-requests: write | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
import pytest | ||
from django.test import TestCase | ||
from django.urls import reverse | ||
|
||
# Create your tests here. | ||
|
||
@pytest.mark.unit | ||
def test_acess_index_true(client): | ||
""" | ||
Test if the index view returns a 200 status code when accesseds | ||
""" | ||
url = reverse("index") | ||
response = client.get(url) | ||
assert response.status_code == 200 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,20 @@ | ||
from django.shortcuts import render | ||
|
||
from .models import Post | ||
|
||
|
||
def base(request): | ||
return render(request, "app/base.html") | ||
|
||
|
||
def index(request): | ||
return render(request, "app/index.html") | ||
|
||
|
||
def blog(request): | ||
posts = Post.objects.all().order_by("-created_at") | ||
return render(request, "app/blog.html", {"posts": posts}) | ||
|
||
|
||
def post(request): | ||
return render(request, "app/post.html") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[pytest] | ||
DJANGO_SETTINGS_MODULE = kamila_project.settings | ||
python_files = tests.py test_*.py | ||
|
||
markers = | ||
unit: marks tests as unit tests. | ||
integration: marks tests as integration tests. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pytest | ||
pytest-django | ||
flake8 | ||
pyproject-flake8 | ||
black | ||
isort | ||
mypy |