Skip to content

Commit

Permalink
Merge pull request #128 from numerique-gouv/main
Browse files Browse the repository at this point in the history
Mise en production
  • Loading branch information
LucienMLD authored Dec 20, 2024
2 parents 9b3fb2e + 4715137 commit 5850f6e
Show file tree
Hide file tree
Showing 55 changed files with 38,435 additions and 730 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/cd-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 📦 Docker Image Build & Push

on:
push:
branches:
- "**"

jobs:
docker:
runs-on: ubuntu-latest
name: Build and push Docker image
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Inject enhanced GitHub environment variables
uses: rlespinasse/github-slug-action@v5
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: |
ghcr.io/${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}/sites-faciles:${{ env.GITHUB_REF_SLUG }}
${{ github.ref_name == 'main' && format('ghcr.io/{0}/sites-faciles:latest', env.GITHUB_REPOSITORY_OWNER_PART_SLUG) || '' }}
cache-from: type=registry,ref=ghcr.io/${{ env.GITHUB_REPOSITORY_OWNER_PART_SLUG }}/sites-faciles:${{ env.GITHUB_REF_SLUG }}
cache-to: type=inline
47 changes: 47 additions & 0 deletions .github/workflows/ci-check-migrations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 🔮 CI - Migrations Check

on:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review

jobs:
build:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
env:
DJANGO_SETTINGS_MODULE: config.settings_test
PYTHONPATH: .
strategy:
matrix:
python-version: ["3.12"]
services:
postgres:
image: postgres:14-alpine
env:
POSTGRES_USER: dju
POSTGRES_PASSWORD: djpwd
POSTGRES_DB: djdb
ports:
- 5432:5432
steps:
- uses: actions/checkout@v3
- name: 🐍 Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: 🌍 Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
pip install ruff
poetry install --no-root
- name: 📄 Copy empty .env.test to .env
run: |
cp .env.test .env
- name: 🚧 Check pending migrations
run: |
poetry run django-admin makemigrations --check --dry-run --noinput
7 changes: 2 additions & 5 deletions .github/workflows/ci.yml → .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 🔮 CI
name: 🔮 CI - Main checks

on: [push]

Expand All @@ -10,7 +10,7 @@ jobs:
PYTHONPATH: .
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
python-version: ["3.10", "3.11", "3.12", "3.13"]
services:
postgres:
image: postgres:14-alpine
Expand Down Expand Up @@ -38,9 +38,6 @@ jobs:
- name: ✨ Black & ruff
run: |
make quality
- name: 🚧 Check pending migrations # continue-on-error: true
run: |
poetry run django-admin makemigrations --check --dry-run --noinput
- name: 🤹‍ Run the unit tests
run: |
make test-unit
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.9
rev: v0.8.0
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- repo: https://github.com/psf/black
rev: 23.11.0
rev: 24.10.0
hooks:
- id: black
11 changes: 7 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM python:3.10

EXPOSE ${HOST_PORT}
EXPOSE ${CONTAINER_PORT}

ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
Expand All @@ -13,10 +13,13 @@ ENV POETRY_HOME=/opt/poetry
ENV POETRY_VENV=/opt/poetry-venv
ENV POETRY_CACHE_DIR=/opt/.cache

# Needed for docker build to succeed
ENV DATABASE_URL=postgres://user:password@localhost:5432/db

# Add new user to run the whole thing as non-root.
RUN set -ex \
&& addgroup app \
&& adduser --ingroup app --home ${APP_DIR} --disabled-password app;
&& addgroup --gid 1000 app \
&& adduser --uid 1000 --gid 1000 --home ${APP_DIR} --disabled-password app;

# Install poetry separated from system interpreter
RUN python3 -m venv ${POETRY_VENV} \
Expand All @@ -40,4 +43,4 @@ USER app
ENTRYPOINT ["./entrypoint.sh"]

# https://stackoverflow.com/a/40454758/21676629
CMD ["sh", "-c", "poetry run python manage.py runserver 0.0.0.0:$HOST_PORT"]
CMD ["sh", "-c", "poetry run python manage.py runserver 0.0.0.0:$CONTAINER_PORT"]
Binary file modified blog/locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
73 changes: 46 additions & 27 deletions blog/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-13 22:10+0200\n"
"PO-Revision-Date: 2024-09-17 12:04+0200\n"
"POT-Creation-Date: 2024-12-10 14:32+0100\n"
"PO-Revision-Date: 2024-12-10 14:33+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fr\n"
Expand Down Expand Up @@ -78,98 +78,117 @@ msgstr "Il est impossible d’avoir des parents circulaires."
msgid "Category"
msgstr "Catégorie"

#: blog/models.py:167 blog/models.py:275 blog/models.py:392
#: blog/templates/blog/categories_list_page.html:20 blog/views.py:117
#: blog/models.py:167 blog/models.py:279 blog/models.py:461 blog/models.py:468
#: blog/models.py:519
msgid "Categories"
msgstr "Catégories"

#: blog/models.py:201
msgid "Posts per page"
msgstr "Articles par page"

#: blog/models.py:205 blog/templates/blog/blog_index_page.html:77
#: blog/models.py:207
msgid "Post limit in the RSS/Atom feeds"
msgstr "Nombre d’articles dans les flux RSS/Atom"

#: blog/models.py:211 blog/templates/blog/blog_index_page.html:85
msgid "Filter by category"
msgstr "Filtrer par catégorie"

#: blog/models.py:206 blog/templates/blog/blog_index_page.html:94
#: blog/models.py:212 blog/templates/blog/blog_index_page.html:102
msgid "Filter by tag"
msgstr "Filtrer par étiquette"

#: blog/models.py:207 blog/templates/blog/blog_index_page.html:111
#: blog/models.py:213 blog/templates/blog/blog_index_page.html:119
msgid "Filter by author"
msgstr "Filtrer par auteur"

#: blog/models.py:209 blog/templates/blog/blog_index_page.html:126
#: blog/models.py:215 blog/templates/blog/blog_index_page.html:134
msgid "Filter by source"
msgstr "Filtrer par source"

#: blog/models.py:209
#: blog/models.py:215
msgid "The source is the organization of the post author"
msgstr ""
"La source est l’organisation à laquelle appartient l’auteur de l’article"
msgstr "La source est l’organisation à laquelle appartient l’auteur de l’article"

#: blog/models.py:221
#: blog/models.py:228
msgid "Show filters"
msgstr "Afficher les filtres"

#: blog/models.py:228
#: blog/models.py:235
msgid "Blog index"
msgstr "Index de blog"

#: blog/models.py:257 blog/templates/blog/tags_list_page.html:20
#: blog/views.py:149
#: blog/models.py:262 blog/models.py:484 blog/models.py:498
#: blog/templates/blog/tags_list_page.html:20
msgid "Tags"
msgstr "Étiquettes"

#: blog/models.py:262
#: blog/models.py:267
#, python-format
msgid "Posts tagged with %(tag)s"
msgstr "Articles avec l’étiquette %(tag)s"

#: blog/models.py:280
#: blog/models.py:284
#, python-format
msgid "Posts in category %(category)s"
msgstr "Articles dans la catégorie %(category)s"

#: blog/models.py:291 blog/models.py:293 blog/models.py:304 blog/models.py:307
#: blog/models.py:294 blog/models.py:296 blog/models.py:306 blog/models.py:309
msgid "Posts written by"
msgstr "Articles écrits par"

#: blog/models.py:311
#: blog/models.py:314
#, python-format
msgid "Posts published in %(year)s"
msgstr "Articles publiés en %(year)s"

#: blog/models.py:394
#: blog/models.py:521
msgid "Post date"
msgstr "Date de publication"

#: blog/models.py:396
#: blog/models.py:523
msgid "Author entries can be created in Snippets > Persons"
msgstr "Les auteurs peuvent être créés via Fragments > Personnes"

#: blog/models.py:415
#: blog/models.py:542
msgid "Scheduled publishing"
msgstr "Publication planifiée"

#: blog/models.py:423
#: blog/models.py:550
msgid "Tags and Categories"
msgstr "Étiquettes et Catégories"

#: blog/models.py:450
#: blog/models.py:566
msgid "Blog page"
msgstr "Page de blog"

#: blog/templates/blog/blocks/blog_index_posts_list.html:37
msgid "No article found."
msgstr "Aucun article trouvé."

#: blog/templates/blog/blog_entry_page.html:75
#: blog/templates/blog/blocks/feeds.html:10
msgid "Atom feed for the category"
msgstr "Flux Atom pour la catégorie"

#: blog/templates/blog/blocks/feeds.html:12
msgid "Atom feed"
msgstr "Flux Atom"

#: blog/templates/blog/blocks/feeds.html:20
msgid "RSS feed for the category"
msgstr "Flux RSS pour la catégorie"

#: blog/templates/blog/blocks/feeds.html:22
msgid "RSS feed"
msgstr "Flux RSS"

#: blog/templates/blog/blog_entry_page.html:79
msgid "Posted by:"
msgstr "Écrit par :"

#: blog/templates/blog/blog_index_page.html:72
#: blog/templates/blog/blog_index_page.html:74
#: blog/templates/blog/blog_index_page.html:80
#: blog/templates/blog/blog_index_page.html:82
msgid "Filters"
msgstr "Filtres"

Expand Down
25 changes: 25 additions & 0 deletions blog/migrations/0038_blogindexpage_feed_posts_limit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 5.1.3 on 2024-11-27 10:47

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("blog", "0037_alter_blogentrypage_body_and_more"),
]

operations = [
migrations.AddField(
model_name="blogindexpage",
name="feed_posts_limit",
field=models.PositiveSmallIntegerField(
default=20,
validators=[
django.core.validators.MaxValueValidator(100),
django.core.validators.MinValueValidator(1),
],
verbose_name="Post limit in the RSS/Atom feeds",
),
),
]
Loading

0 comments on commit 5850f6e

Please sign in to comment.