Skip to content

Commit

Permalink
chore: Adiciona Docker e comandos via Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarofpp committed Feb 24, 2024
1 parent 204698b commit 922c535
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.12.1-slim

# Virtual environment
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

# Install requirements
# hadolint ignore=DL3013
RUN pip3 install --no-cache-dir --upgrade pip
COPY requirements.txt /tmp/requirements.txt
RUN pip3 install --no-cache-dir --requirement /tmp/requirements.txt

# Set environment variables
ENV WORKDIR=/app
WORKDIR ${WORKDIR}
50 changes: 50 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Variables
APP_NAME=app
ROOT=$(shell pwd)

## Lint
DOCKER_IMAGE_LINTER=alvarofpp/linter:latest
LINT_COMMIT_TARGET_BRANCH=origin/main

## Test
TEST_CONTAINER_NAME=${APP_NAME}_test

# Commands
.PHONY: install-hooks
install-hooks:
git config core.hooksPath .githooks

.PHONY: build
build: install-hooks
@docker compose build --pull

.PHONY: build-no-cache
build-no-cache: install-hooks
@docker compose build --no-cache --pull

.PHONY: lint
lint:
@docker pull ${DOCKER_IMAGE_LINTER}
@docker run --rm -v ${ROOT}:/app ${DOCKER_IMAGE_LINTER} " \
lint-commit ${LINT_COMMIT_TARGET_BRANCH} \
&& lint-markdown \
&& lint-dockerfile \
&& lint-yaml \
&& lint-shell-script \
&& lint-python"

.PHONY: test
test:
@docker compose run --rm -v ${ROOT}:/app \
--name ${TEST_CONTAINER_NAME} ${APP_NAME} \
pytest

.PHONY: test-coverage
test-coverage:
@docker compose run --rm -v ${ROOT}:/app \
--name ${TEST_CONTAINER_NAME} ${APP_NAME} \
/bin/bash -c "coverage run -m unittest discover tests && coverage report -m"

.PHONY: shell
shell:
@docker compose run --rm ${APP_NAME} bash
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
version: '3.8'

services:
app:
build:
context: .
image: alvarofpp/validate-docbr
container_name: validate-docbr
volumes:
- .:/app
File renamed without changes.
1 change: 1 addition & 0 deletions tests/test_cnh.py → tests/test_CNH.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

import validate_docbr as docbr


Expand Down
1 change: 1 addition & 0 deletions tests/test_cnpj.py → tests/test_CNPJ.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

import validate_docbr as docbr


Expand Down
1 change: 1 addition & 0 deletions tests/test_cns.py → tests/test_CNS.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

import validate_docbr as docbr


Expand Down
1 change: 1 addition & 0 deletions tests/test_cpf.py → tests/test_CPF.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

import validate_docbr as docbr


Expand Down
1 change: 1 addition & 0 deletions tests/test_certidao.py → tests/test_Certidao.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

import validate_docbr as docbr


Expand Down
1 change: 1 addition & 0 deletions tests/test_pis.py → tests/test_PIS.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

import validate_docbr as docbr


Expand Down
1 change: 1 addition & 0 deletions tests/test_renavam.py → tests/test_RENAVAM.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

import validate_docbr as docbr


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest

import validate_docbr as docbr


Expand Down

0 comments on commit 922c535

Please sign in to comment.