Skip to content

Commit

Permalink
Merge pull request #566 from memeLab/develop
Browse files Browse the repository at this point in the history
Blog Release & Clean up project
  • Loading branch information
pablodiegoss authored Jul 7, 2024
2 parents d2b4431 + 2632e20 commit b04432e
Show file tree
Hide file tree
Showing 308 changed files with 8,553 additions and 4,384 deletions.
40 changes: 40 additions & 0 deletions .envs/.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Use this file to create a .env with filled variables
# Django Variables
DJANGO_DEBUG=True
DEBUG_TOOLBAR=True
DJANGO_SECRET_KEY=change_me
USE_MINIO=True

# Sentry Variables
DJANGO_ADMIN_URL=jandig-admin/
ENABLE_SENTRY=False
SENTRY_DSN=
HEALTH_CHECK_URL=api/v1/status/
SENTRY_TRACES_SAMPLE_RATE=0.1

## Amazon AWS Variables
AWS_ACCESS_KEY_ID=minio
AWS_SECRET_ACCESS_KEY=minio123
MINIO_ROOT_USER=minio
MINIO_ROOT_PASSWORD=minio123
AWS_STORAGE_BUCKET_NAME=jandig-cdn
AWS_PRIVATE_STORAGE_BUCKET_NAME=jandig-private-cdn
AWS_S3_REGION_NAME=us-east-2
AWS_STATIC_LOCATION=static
MINIO_S3_ENDPOINT_URL=http://storage:9000
MINIO_SITE_REGION=us-east-2
MINIO_USER_ACCESS_KEY=minio-access-key
MINIO_USER_SECRET_KEY=minio-secret-key

## Postgres variables
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_DB=jandig
POSTGRES_USER=jandig
POSTGRES_PASSWORD=secret

# Email server variables
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
[email protected]
JANDIG_EMAIL_PASSWORD=local_password
63 changes: 42 additions & 21 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,66 @@

## Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.

## Our Standards

Examples of behavior that contributes to creating a positive environment include:
Examples of behavior that contributes to a positive environment for our community include:

* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
- Focusing on what is best not just for us as individuals, but for the overall community

Examples of unacceptable behavior by participants include:
Examples of unacceptable behavior include:

* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
- The use of sexualized language or imagery, and sexual attention or advances of any kind
- Trolling, insulting or derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others private information, such as a physical or email address, without their explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting

## Our Responsibilities
## Enforcement Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.

## Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [email protected]. All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the reporter of any incident.

## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:

1. Correction <br><br>
**Community Impact:** Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. <br><br>
**Consequence:** A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.

2. Warning <br><br>
**Community Impact:** A violation through a single incident or series of actions. <br><br>
**Consequence:** A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.

3. Temporary Ban <br><br>
**Community Impact:** A serious violation of community standards, including sustained inappropriate behavior. <br><br>
**Consequence:** A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
4. Permanent Ban <br><br>
**Community Impact:** Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. <br><br>
**Consequence:** A permanent ban from any sort of public interaction within the community.

## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
This Code of Conduct is adapted from the [Contributor Covenant][homepage] version 2.0, available at [https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][version].

[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
[version]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
88 changes: 88 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: CI pipeline

on: push

jobs:
linter:
name: run / linter
runs-on: ubuntu-latest
steps:
- name: Check out code from Github
uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Installing flake8
run: |
python -m pip install --upgrade pip
pip install flake8
- name: Run flake8 linter
run: |
flake8 --max-line-length=200 --exclude=*/migrations src/
build:
name: run / build
runs-on: ubuntu-latest
needs: linter
steps:
- name: Check out code from Github
uses: actions/checkout@v3
- name: Build image
run: |
# docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASS
docker build . -t jandigarte/django:$GITHUB_SHA
docker save -o docker_image_$GITHUB_SHA jandigarte/django:$GITHUB_SHA
- name: Caching image
uses: actions/cache@v3
with:
key: jandigarte
path: docker_image_${{ github.sha }}

migrations:
name: test / migrations
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out code from Github
uses: actions/checkout@v3
- name: Restoring cached image
uses: actions/cache@v3
with:
key: jandigarte
path: docker_image_${{ github.sha }}
- name: Running container
env:
IMAGE_NAME: jandigarte/django:${{ github.sha }}
run: |
cp .envs/.example .envs/.env
docker load -i docker_image_$GITHUB_SHA
docker-compose -f docker-compose.ci.yml -p jandigarte_$GITHUB_SHA up --no-build -d
- name: Test migrations
run: |
docker exec jandigarte_${{ github.sha }}_django_1 sh -c "\
poetry run src/manage.py makemigrations --check --dry-run"
test:
name: test / unity
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out code from Github
uses: actions/checkout@v3
- name: Restoring cached image
uses: actions/cache@v3
with:
key: jandigarte
path: docker_image_${{ github.sha }}
- name: Running container
env:
IMAGE_NAME: jandigarte/django:${{ github.sha }}
run: |
cp .envs/.example .envs/.env
docker load -i docker_image_$GITHUB_SHA
docker-compose -f docker-compose.ci.yml -p jandigarte_$GITHUB_SHA up --no-build -d
- name: Running users tests
run: |
docker exec jandigarte_${{ github.sha }}_django_1 sh -c "\
poetry run src/manage.py test"
21 changes: 21 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Dependencies pipeline

on:
push:
paths:
- 'pyproject.toml'

jobs:
dependencies:
name: test / dependencies
runs-on: ubuntu-latest
steps:
- name: Check out code from Github
uses: actions/checkout@v3
- name: Check diff
id: diff_lock
run: |
echo "::set-output name=dependencies::$(git diff --name-only | grep poetry.lock -c)"
- name: Check poetry lock
if: ${{ steps.diff_lock.outputs.dependencies == 0 }}
run: exit 1
24 changes: 24 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Docker pipeline

on:
push:
branches:
- develop

# TODO: Change environment and login envs
jobs:
django:
name: push / django
environment: testes
runs-on: ubuntu-latest
needs: dependencies
steps:
- name: Check out code from Github
uses: actions/checkout@v3
- name: Build django image
run: |
docker build . -t jandigarte/django:latest
- name: Push django image
run: |
docker login -u ${{ secrets.DOCKER_HUB_USER }} -p ${{ secrets.DOCKER_HUB_PASS }}
docker push jandigarte/django:latest
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
src/ARte/config/__pycache__/
*.pyc

##vscode
\.vscode/

##sqlite
*.sqlite3

Expand All @@ -25,4 +22,4 @@ docker/media/
*.mo
*.po~

src/.envs/.env
*/**/.env
6 changes: 3 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ stages:
- docker:dind
script:
- docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASS
- docker build . -f docker/Dockerfile -t jandigarte/django:$DOCKER_TAG --cache-from jandigarte/django:$DOCKER_TAG
- docker build . -t jandigarte/django:$DOCKER_TAG --cache-from jandigarte/django:$DOCKER_TAG
- docker push jandigarte/django:$DOCKER_TAG
tags:
- docker
- gitlab-org-docker

build develop:
extends: .build
Expand All @@ -32,7 +32,7 @@ build tag:
environment: production
script:
- docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_PASS
- "docker build . -f docker/Dockerfile
- "docker build .
-t jandigarte/django:$CI_COMMIT_TAG
-t jandigarte/django:$DOCKER_TAG
-t jandigarte/django:latest"
Expand Down
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"python.testing.pytestArgs": [
"src",
"--ds=config.test_settings",
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
49 changes: 49 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
FROM python:3.10-slim-bullseye

RUN apt-get update && \
apt-get install -y --no-install-recommends \
gettext \
docutils-common \
curl \
wget

COPY ./pyproject.toml /pyproject.toml
COPY ./poetry.lock /poetry.lock

ENV PATH="$PATH:/root/.local/bin" \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \
POETRY_CACHE_DIR='/var/cache/pypoetry' \
TINI_VERSION=v0.19.0 \
# poetry:
POETRY_VERSION=1.3.1

# Installing `poetry` package manager:
# https://github.com/python-poetry/poetry
RUN curl -sSL https://install.python-poetry.org | python3 - \
&& poetry --version

RUN pip install --upgrade pip
RUN poetry install

RUN dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
&& wget "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${dpkgArch}" -O /usr/local/bin/tini \
&& chmod +x /usr/local/bin/tini && tini --version


RUN mkdir -p /jandig/src /jandig/locale /jandig/docs /jandig/static /jandig/build

WORKDIR /jandig

COPY ./src/ /jandig/src/
COPY ./docs/ /jandig/docs/
COPY ./locale/ /jandig/locale/
COPY ./tasks.py /jandig/tasks.py
COPY ./run.sh /jandig/run.sh
COPY ./etc/ /jandig/etc/


RUN find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf


ENTRYPOINT ["tini", "--"]
Loading

0 comments on commit b04432e

Please sign in to comment.