Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Adicionado arquivos da aplicação para o reporitório do fork #103

Open
wants to merge 1 commit into
base: master
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
21 changes: 21 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/python-3/.devcontainer/base.Dockerfile

# [Choice] Python version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.10, 3.9, 3.8, 3.7, 3.6, 3-bullseye, 3.10-bullseye, 3.9-bullseye, 3.8-bullseye, 3.7-bullseye, 3.6-bullseye, 3-buster, 3.10-buster, 3.9-buster, 3.8-buster, 3.7-buster, 3.6-buster
ARG VARIANT="3.10-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
# && rm -rf /tmp/pip-tmp

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
51 changes: 51 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/python-3
{
"name": "Python 3",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"args": {
// Update 'VARIANT' to pick a Python version: 3, 3.10, 3.9, 3.8, 3.7, 3.6
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local on arm64/Apple Silicon.
"VARIANT": "3.10-bullseye",
// Options
"NODE_VERSION": "lts/*"
}
},

// Set *default* container specific settings.json values on container create.
"settings": {
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.autopep8Path": "/usr/local/py-utils/bin/autopep8",
"python.formatting.blackPath": "/usr/local/py-utils/bin/black",
"python.formatting.yapfPath": "/usr/local/py-utils/bin/yapf",
"python.linting.banditPath": "/usr/local/py-utils/bin/bandit",
"python.linting.flake8Path": "/usr/local/py-utils/bin/flake8",
"python.linting.mypyPath": "/usr/local/py-utils/bin/mypy",
"python.linting.pycodestylePath": "/usr/local/py-utils/bin/pycodestyle",
"python.linting.pydocstylePath": "/usr/local/py-utils/bin/pydocstyle",
"python.linting.pylintPath": "/usr/local/py-utils/bin/pylint"
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pip3 install --user -r requirements.txt",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"features": {
"git": "latest"
}
}
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.devcontainer
.git


*.pyc

.gitignore
.env.example

static
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
URL_API_GITHUB=
SECRET_KEY=
DEBUG=
DATABASE_URL=
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.env

*.pyc

db.sqlite3

staticfiles/
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"python.linting.pylintEnabled": true,
"python.linting.enabled": true
}
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.10

WORKDIR /app

COPY requirements.txt /app/

RUN apt update -y

RUN pip install -r requirements.txt

COPY . .

RUN python manage.py collectstatic

CMD ["gunicorn", "--bind", ":8000", "core.wsgi"]
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn core.wsgi
43 changes: 27 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
# Desafio técnico para desenvolvedores
# DEV HIRING CHALLENGE - ATELIWARE

Construa uma nova aplicação, utilizando o framework de sua preferência (Ruby on Rails, Elixir Phoenix, Python Django ou Flask, NodeJS Sails, Java Spring, ASP.NET ou outro), a qual deverá conectar na API do GitHub e disponibilizar as seguintes funcionalidades:
Uma aplicação desenvolvida para consumo da api do github, listando os principais repositórios das seguintes linguagens: Python, Javascript, Rust, Elixir e Ruby.

- Botão para buscar e armazenar os repositórios destaques de 5 linguagens à sua escolha;
- Listar os repositórios encontrados;
- Visualizar os detalhes de cada repositório.
## Instruções

Alguns requisitos:
### Dependências
- docker

- Deve ser uma aplicação totalmente nova;
- A solução deve estar em um repositório público do GitHub;
- A aplicação deve armazenar as informações encontradas;
- Utilizar PostgreSQL, MySQL ou SQL Server;
- O deploy deve ser realizado, preferencialmente, no Heroku, AWS ou no Azure;
- A aplicação precisa ter testes automatizados;
- Preferenciamente dockerizar a aplicação;
- Por favor atualizar o readme da aplicação com passo a passo com instrução para subir o ambiente.
### Arquivos de configuração
Crie um arquivo .env baseado em .env.example com a url de acesso ao banco de dados, chave secreta, a url da api do github e se será debugado o código.

Quando terminar, faça um Pull Request neste repo e avise-nos por email.
### Container do banco de dados
docker network create postgres
docker run -d --name postgres --network=postgres -e "POSTGRES_PASSWORD=teste" -p 5432:5432 -v data:/var/lib/postgresql/data postgres

**IMPORTANTE:** se você não conseguir finalizar o teste, por favor nos diga o motivo e descreva quais foram as suas dificuldades. Você pode também sugerir uma outra abordagem para avaliarmos seus skills técnicos, vender seu peixe, mostrar-nos do que é capaz.
### Criando banco de dados
docker exec -t postgres psql -U postgres -c "CREATE DATABASE dev_hiring_challenge"

### Buildando container da aplicação
docker build -t ateliware/dev-hiring-challenge .

### Executando container
docker run -p 8000:8000 --network postgres --name dev-hiring-challenge ateliware/dev-hiring-challenge

### Aplicando migrations
docker exec -t dev-hiring-challenge python manage.py migrate

### Testando aplicação
docker exec -t dev-hiring-challenge python manage.py test

### URL do ambiente de produção
https://blooming-shelf-11188.herokuapp.com/
22 changes: 22 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "Dev Hiring Challenge - Ateliware",
"description": "Aplicação web responsável pela a listagem de repositórios do github das principais linguagens.",
"image": "heroku/python",
"repository": "https://github.com/vitorgripa/dev-hiring-challenge",
"keywords": ["python", "django" ],
"addons": [ "heroku-postgresql" ],
"env": {
"SECRET_KEY": {
"description": "The secret key for the Django application.",
"generator": "secret"
}
},
"environments": {
"test": {
"scripts": {
"test-setup": "python manage.py collectstatic --noinput",
"test": "python manage.py test"
}
}
}
}
Empty file added core/__init__.py
Empty file.
7 changes: 7 additions & 0 deletions core/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'core.settings')

application = get_asgi_application()
Empty file added core/github/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions core/github/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class GithubConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'core.github'
7 changes: 7 additions & 0 deletions core/github/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
LINGUAGENS = (
"Python",
"Javascript",
"Rust",
"Elixir",
"Ruby"
)
46 changes: 46 additions & 0 deletions core/github/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by Django 4.0.1 on 2022-01-19 01:28

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Linguagem',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nome', models.TextField()),
],
options={
'verbose_name': 'Linguagem',
'verbose_name_plural': 'Linguagens',
'db_table': 'linguagens',
},
),
migrations.CreateModel(
name='Repositorio',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nome', models.TextField()),
('url', models.URLField()),
('estrelas', models.IntegerField()),
('pontos', models.FloatField()),
('acompanhadores', models.IntegerField()),
('lincenca', models.TextField()),
('descricao', models.TextField()),
('linguagem', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='github.linguagem')),
],
options={
'verbose_name': 'Repositório',
'verbose_name_plural': 'Repositórios',
'db_table': 'repositorios',
},
),
]
18 changes: 18 additions & 0 deletions core/github/migrations/0002_alter_repositorio_descricao.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.1 on 2022-01-19 03:21

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('github', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='repositorio',
name='descricao',
field=models.TextField(null=True),
),
]
20 changes: 20 additions & 0 deletions core/github/migrations/0003_initial_data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.db import migrations

from core.github.constants import LINGUAGENS


def inserir_linguagens(apps, schema_editor):
Linguagem = apps.get_model("github", "Linguagem")

for linguagem in LINGUAGENS:
Linguagem.objects.create(nome=linguagem)


class Migration(migrations.Migration):
dependencies = [
("github", "0002_alter_repositorio_descricao")
]

operations = [
migrations.RunPython(inserir_linguagens)
]
18 changes: 18 additions & 0 deletions core/github/migrations/0004_rename_lincenca_repositorio_licenca.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.0.1 on 2022-01-20 01:50

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('github', '0003_initial_data'),
]

operations = [
migrations.RenameField(
model_name='repositorio',
old_name='lincenca',
new_name='licenca',
),
]
Empty file.
42 changes: 42 additions & 0 deletions core/github/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from django.db.models import Model
from django.db.models import IntegerField
from django.db.models import TextField
from django.db.models import URLField
from django.db.models import ForeignKey
from django.db.models import FloatField
from django.db.models import CASCADE

from django.db.models import Manager


class Linguagem(Model):
nome = TextField()
objects = Manager()

def __str__(self):
return str(self.nome)

class Meta:
db_table = "linguagens"
verbose_name = "Linguagem"
verbose_name_plural = "Linguagens"


class Repositorio(Model):
nome = TextField()
url = URLField()
estrelas = IntegerField()
pontos = FloatField()
acompanhadores = IntegerField()
licenca = TextField()
descricao = TextField(null=True)
linguagem = ForeignKey(Linguagem, on_delete=CASCADE)
objects = Manager()

def __str__(self):
return str(self.nome)

class Meta:
db_table = "repositorios"
verbose_name = "Repositório"
verbose_name_plural = "Repositórios"
Loading