Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
327b81b
Definindo os models
matheus-dev-fullstack Mar 10, 2024
aba52e5
Condigurando serializers
matheus-dev-fullstack Mar 11, 2024
3c47e1f
Construindo factory.py em Order e Product
matheus-dev-fullstack Mar 11, 2024
bdb6eef
Iniciando configuração do viewset de order
matheus-dev-fullstack Mar 13, 2024
0d2919a
/home/codespace
matheus-dev-fullstack Mar 14, 2024
9f7c44f
Ajustando serialyzers
matheus-dev-fullstack Mar 17, 2024
8566256
Criando Products pelo ProductFactory
matheus-dev-fullstack Mar 31, 2024
5e49194
Ajustando paginação do django rest framework
matheus-dev-fullstack Apr 4, 2024
9d6d473
Implementando django-debug-toolbar
matheus-dev-fullstack Apr 10, 2024
12f7a85
Implementando autenticação
matheus-dev-fullstack Apr 14, 2024
af48421
Implementando token de autenticação e retomando testes
matheus-dev-fullstack Apr 18, 2024
63ef177
Criando Dockerfile e configurando e rodando imagem docker
matheus-dev-fullstack Apr 30, 2024
5f6ae81
Configurando credenciais e tipo de banco de dados no settings.py
matheus-dev-fullstack May 7, 2024
205fdac
Adicionando as dependencias essenciais para o Postgres no Dockerfile …
matheus-dev-fullstack May 7, 2024
9a7bad7
Criação e configuração do docker-compose
matheus-dev-fullstack May 7, 2024
309a1c8
Criando env.dev para sincronizar com docker-compose
matheus-dev-fullstack May 7, 2024
f231361
Corrigindo importação do Poetry
matheus-dev-fullstack May 8, 2024
302d09e
Atualizando dependências no requirements.txt e adicionando README.me
matheus-dev-fullstack May 8, 2024
6802699
Corrigindo caminho do volumes em docker-compose.yml
matheus-dev-fullstack May 8, 2024
c03e56a
Corrignido credenciais de conexão com o banco de dados
matheus-dev-fullstack May 9, 2024
1674b7e
Removendo env dos ingorados paragarantir o salvamento de env.dev
matheus-dev-fullstack May 9, 2024
63cb6c8
Ajustando a instalação de psycopg2 para corrigir os erros ao rodar o …
matheus-dev-fullstack May 9, 2024
c3898da
Atualizando depensências do requirements.txt
matheus-dev-fullstack May 9, 2024
af12138
Configurando arquivo Makefile
matheus-dev-fullstack May 9, 2024
9de85b0
Alterando nome no docker-compose para web
matheus-dev-fullstack May 11, 2024
0985be6
feat: add github-actions demo
matheus-dev-fullstack May 12, 2024
6ca601a
Removendo autenticações desnecessárias
matheus-dev-fullstack May 12, 2024
51f4f95
Atualizando credenciais e renomeando variáveis
matheus-dev-fullstack May 12, 2024
cdd98af
Revisando test_viewsets
matheus-dev-fullstack May 14, 2024
f840407
Configurando build para github actions
matheus-dev-fullstack May 19, 2024
d525c71
Ajustando build para github actions
matheus-dev-fullstack May 19, 2024
a3ec982
Github Actions - Atualizando poetry para corrigir importação\
matheus-dev-fullstack May 19, 2024
1a4c9f4
Github Actions - Teste de alteração de versão do poetry
matheus-dev-fullstack May 19, 2024
9266ee0
Github Actions - Teste de alteração de versão do poetry
matheus-dev-fullstack May 19, 2024
b0827da
Github Actions - Teste de alteração de versão do poetry
matheus-dev-fullstack May 19, 2024
8097022
Github Actions - Teste de alteração de versão do poetry
matheus-dev-fullstack May 19, 2024
2606d6d
Github Actions - Teste de alteração de versão do poetry
matheus-dev-fullstack May 19, 2024
e6858b8
Github Actions - Alterando versão das dependencias no pyproject.toml
matheus-dev-fullstack May 19, 2024
2e57690
Congiurando ALLOWED_HOSTS em settings.py
matheus-dev-fullstack May 19, 2024
976aed2
Corrigindo Viewsets, e testes
matheus-dev-fullstack May 20, 2024
d85e7a4
Sinalizando requirements.txt para exercício EBAC
matheus-dev-fullstack May 22, 2024
fcf3c2c
Sinalizando testes para exercício EBAC - modulo 14
matheus-dev-fullstack May 22, 2024
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
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Python application

on: [push]

jobs:
build:
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9]
poetry-version: [1.1.4]

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install poetry ${{ matrix.poetry-version }}
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH


- name: View poetry --help
run: poetry --help

- name: Install dependencies
run: poetry install

- name: Test
run: |
poetry run python manage.py test
17 changes: 17 additions & 0 deletions .github/workflows/github-actions-demo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: GitHub Actions Demo
on: [push]
jobs:
Explore-GitHub-Actions:
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@v2
- 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 }}."
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
env

.env
/env
72 changes: 72 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# `python-base` sets up all our shared environment variables
FROM python:3.12.0-slim as python-base
# FROM python:3.8.1-slim as python-base

# python
ENV PYTHONUNBUFFERED=1 \
# prevents python creating .pyc files
PYTHONDONTWRITEBYTECODE=1 \
\
# pip
PIP_NO_CACHE_DIR=off \
PIP_DISABLE_PIP_VERSION_CHECK=on \
PIP_DEFAULT_TIMEOUT=100 \
\
# poetry
# https://python-poetry.org/docs/configuration/#using-environment-variables
POETRY_VERSION=1.8.2 \
# make poetry install to this location
POETRY_HOME="/opt/poetry" \
# make poetry create the virtual environment in the project's root
# it gets named `.venv`
POETRY_VIRTUALENVS_IN_PROJECT=true \
# do not ask any interactive question
POETRY_NO_INTERACTION=1 \
\
# paths
# this is where our requirements + virtual environment will live
PYSETUP_PATH="/opt/pysetup" \
VENV_PATH="/opt/pysetup/.venv"


# prepend poetry and venv to path
ENV PATH="$POETRY_HOME/bin:$VENV_PATH/bin:$PATH"

RUN apt-get update \
&& apt-get install --no-install-recommends -y \
# deps for installing poetry
curl \
# deps for building python deps
build-essential

# install poetry - respects $POETRY_VERSION & $POETRY_HOME
# RUN curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
# RUN pip install poetry poetry init
# RUN curl -sSL https://install.python-poetry.org | python3 -
RUN curl -sSL https://raw.githubusercontent.com.sdispater/poetry/get-poetry.py | python

RUN curl -sSL https://install.python-poetry.org | python3 -


# install postgres dependencies inside of Docker
RUN apt-get update \
&& apt-get -y install libpq-dev gcc \
&& pip install psycopg2

# copy project requirement files here to ensure they will be cached.
WORKDIR $PYSETUP_PATH
COPY poetry.lock pyproject.toml ./

# install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally
RUN poetry install --no-dev

# quicker install as runtime deps are already installed
RUN poetry install

WORKDIR /app

COPY . /app/

EXPOSE 8000

CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
122 changes: 122 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Set this to ~use it everywhere in the project setup
PYTHON_VERSION ?= 3.8.10
# the directories containing the library modules this repo builds
LIBRARY_DIRS = mylibrary
# build artifacts organized in this Makefile
BUILD_DIR ?= build

# PyTest options
PYTEST_HTML_OPTIONS = --html=$(BUILD_DIR)/report.html --self-contained-html
PYTEST_TAP_OPTIONS = --tap-combined --tap-outdir $(BUILD_DIR)
PYTEST_COVERAGE_OPTIONS = --cov=$(LIBRARY_DIRS)
PYTEST_OPTIONS ?= $(PYTEST_HTML_OPTIONS) $(PYTEST_TAP_OPTIONS) $(PYTEST_COVERAGE_OPTIONS)

# MyPy typechecking options
MYPY_OPTS ?= --python-version $(basename $(PYTHON_VERSION)) --show-column-numbers --pretty --html-report $(BUILD_DIR)/mypy
# Python installation artifacts
PYTHON_VERSION_FILE=.python-version
ifeq ($(shell which pyenv),)
# pyenv isn't installed, guess the eventual path FWIW
PYENV_VERSION_DIR ?= $(HOME)/.pyenv/versions/$(PYTHON_VERSION)
else
# pyenv is installed
PYENV_VERSION_DIR ?= $(shell pyenv root)/versions/$(PYTHON_VERSION)
endif
PIP ?= pip3

POETRY_OPTS ?=
POETRY ?= poetry $(POETRY_OPTS)
RUN_PYPKG_BIN = $(POETRY) run

COLOR_ORANGE = \033[33m
COLOR_RESET = \033[0m

##@ Utility

.PHONY: help
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

.PHONY: version-python
version-python: ## Echos the version of Python in use
@echo $(PYTHON_VERSION)

##@ Testing

.PHONY: test
test: ## Runs tests
$(RUN_PYPKG_BIN) pytest \
$(PYTEST_OPTIONS) \
tests/*.py

##@ Building and Publishing

.PHONY: build
build: ## Runs a build
$(POETRY) build

.PHONY: publish
publish: ## Publish a build to the configured repo
$(POETRY) publish $(POETRY_PUBLISH_OPTIONS_SET_BY_CI_ENV)

.PHONY: deps-py-update
deps-py-update: pyproject.toml ## Update Poetry deps, e.g. after adding a new one manually
$(POETRY) update

##@ Setup
# dynamic-ish detection of Python installation directory with pyenv
$(PYENV_VERSION_DIR):
pyenv install --skip-existing $(PYTHON_VERSION)
$(PYTHON_VERSION_FILE): $(PYENV_VERSION_DIR)
pyenv local $(PYTHON_VERSION)

.PHONY: deps
deps: deps-brew deps-py ## Installs all dependencies

.PHONY: deps-brew
deps-brew: Brewfile ## Installs development dependencies from Homebrew
brew bundle --file=Brewfile
@echo "$(COLOR_ORANGE)Ensure that pyenv is setup in your shell.$(COLOR_RESET)"
@echo "$(COLOR_ORANGE)It should have something like 'eval \$$(pyenv init -)'$(COLOR_RESET)"

.PHONY: deps-py
deps-py: $(PYTHON_VERSION_FILE) ## Installs Python development and runtime dependencies
$(PIP) install --upgrade \
--index-url $(PYPI_PROXY) \
pip
$(PIP) install --upgrade \
--index-url $(PYPI_PROXY) \
poetry
$(POETRY) install

##@ Code Quality

.PHONY: check
check: check-py ## Runs linters and other important tools

.PHONY: check-py
check-py: check-py-flake8 check-py-black check-py-mypy ## Checks only Python files

.PHONY: check-py-flake8
check-py-flake8: ## Runs flake8 linter
$(RUN_PYPKG_BIN) flake8 .

.PHONY: check-py-black
check-py-black: ## Runs black in check mode (no changes)
$(RUN_PYPKG_BIN) black --check --line-length 118 --fast .

.PHONY: check-py-mypy
check-py-mypy: ## Runs mypy
$(RUN_PYPKG_BIN) mypy $(MYPY_OPTS) $(LIBRARY_DIRS)

.PHONY: format-py
format-py: ## Runs black, makes changes where necessary
$(RUN_PYPKG_BIN) black .

.PHONY: format-autopep8
format-autopep8:
$(RUN_PYPKG_BIN) autopep8 --in-place --recursive .

.PHONY: format-isort
format-isort:
$(RUN_PYPKG_BIN) isort --recursive .
18 changes: 18 additions & 0 deletions README.me
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Scripts do Projeto:

Git clone ...

## Criando Ambiente Virtual:
python -m venv env
env/scripts/activate



## Instalação das dependências do Projeto:
pip install -r requirements.txt

## Build Docker:
* Abrir o Docker e digitar no terminal
docker run
docker-compose up --build

3 changes: 0 additions & 3 deletions api/admin.py

This file was deleted.

6 changes: 0 additions & 6 deletions api/apps.py

This file was deleted.

3 changes: 0 additions & 3 deletions api/models.py

This file was deleted.

3 changes: 0 additions & 3 deletions api/tests.py

This file was deleted.

3 changes: 0 additions & 3 deletions api/views.py

This file was deleted.

Binary file added bookstore/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file modified bookstore/__pycache__/__init__.cpython-312.pyc
Binary file not shown.
Binary file added bookstore/__pycache__/settings.cpython-310.pyc
Binary file not shown.
Binary file modified bookstore/__pycache__/settings.cpython-312.pyc
Binary file not shown.
Binary file modified bookstore/__pycache__/urls.cpython-312.pyc
Binary file not shown.
Binary file modified bookstore/__pycache__/wsgi.cpython-312.pyc
Binary file not shown.
Loading