From b5a46eba33693b6b91d7b4083718581ec5af61d1 Mon Sep 17 00:00:00 2001 From: Samuel Paccoud - DINUM Date: Fri, 5 Jan 2024 09:11:57 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7(ci)=20fix=20CI=20running=20in=20gi?= =?UTF-8?q?thub=20actions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CI configuration file was translated from CircleCI to github actions a bit too fast and had not been tested yet. --- .github/workflows/people.yml | 127 ++++++------ Dockerfile | 2 +- Makefile | 6 +- docker-compose.yml | 2 +- src/backend/core/tests/swagger/__init__.py | 0 .../core/tests/swagger/test_openapi_schema.py | 22 +- .../locale/fr_FR/LC_MESSAGES/django.mo | Bin 0 -> 474 bytes .../locale/fr_FR/LC_MESSAGES/django.po | 191 ++++++++++++++++++ 8 files changed, 276 insertions(+), 74 deletions(-) create mode 100644 src/backend/core/tests/swagger/__init__.py create mode 100644 src/backend/locale/fr_FR/LC_MESSAGES/django.mo create mode 100644 src/backend/locale/fr_FR/LC_MESSAGES/django.po diff --git a/.github/workflows/people.yml b/.github/workflows/people.yml index b471b9d..06f319f 100644 --- a/.github/workflows/people.yml +++ b/.github/workflows/people.yml @@ -4,26 +4,33 @@ on: push: branches: - main + tags: + - 'v*' pull_request: branches: - - main + - '*' jobs: lint-git: runs-on: ubuntu-latest + if: github.event_name == 'pull_request' # Makes sense only for pull requests steps: - name: Checkout repository uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: show + run: git log - name: Enforce absence of print statements in code run: | - ! git diff origin/main..HEAD -- . ':(exclude).circleci' | grep "print(" + ! git diff origin/${{ github.event.pull_request.base.ref }}..HEAD -- . ':(exclude)**/people.yml' | grep "print(" - name: Check absence of fixup commits run: | ! git log | grep 'fixup!' - name: Install gitlint run: pip install --user requests gitlint - name: Lint commit messages added to main - run: ~/.local/bin/gitlint --commits origin/main..HEAD + run: ~/.local/bin/gitlint --commits origin/${{ github.event.pull_request.base.ref }}..HEAD check-changelog: runs-on: ubuntu-latest @@ -48,6 +55,9 @@ jobs: build-mails: runs-on: ubuntu-latest + defaults: + run: + working-directory: src/mail steps: - name: Checkout repository uses: actions/checkout@v2 @@ -77,8 +87,11 @@ jobs: - name: Check built image availability run: docker images "people:${{ github.sha }}*" - build-back: + lint-back: runs-on: ubuntu-latest + defaults: + run: + working-directory: src/backend steps: - name: Checkout repository uses: actions/checkout@v2 @@ -88,14 +101,6 @@ jobs: python-version: '3.10' - name: Install development dependencies run: pip install --user .[dev] - working-directory: src/backend - - name: Cache dependencies - uses: actions/cache@v2 - with: - path: ~/.local - key: v1-back-dependencies-${{ hashFiles('src/backend/requirements.txt') }} - restore-keys: | - v1-back-dependencies- - name: Check code formatting with ruff run: ~/.local/bin/ruff format people --diff - name: Lint code with ruff @@ -105,27 +110,46 @@ jobs: test-back: runs-on: ubuntu-latest + defaults: + run: + working-directory: src/backend + services: postgres: image: postgres:16 env: - POSTGRES_DB: test_people + POSTGRES_DB: people POSTGRES_USER: dinum POSTGRES_PASSWORD: pass + ports: + - 5432:5432 + # needed because the postgres container does not provide a healthcheck + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + env: + DJANGO_CONFIGURATION: Test + DJANGO_SETTINGS_MODULE: people.settings + DJANGO_SECRET_KEY: ThisIsAnExampleKeyForTestPurposeOnly + DJANGO_JWT_PRIVATE_SIGNING_KEY: ThisIsAnExampleKeyForDevPurposeOnly + DB_HOST: localhost + DB_NAME: people + DB_USER: dinum + DB_PASSWORD: pass + DB_PORT: 5432 + steps: - name: Checkout repository uses: actions/checkout@v2 + - name: Create writable /data + run: | + sudo mkdir -p /data/media && \ + sudo mkdir -p /data/static - name: Install Python uses: actions/setup-python@v3 with: python-version: '3.10' - - name: Install dependencies - run: pip install --user -r src/backend/requirements.txt - - name: Create writable /data - run: | - sudo mkdir -p /data/media && \ - sudo mkdir -p /data/static && \ - sudo chown -R $USER:$USER /data + - name: Install development dependencies + run: pip install --user .[dev] - name: Install gettext (required to compile messages) run: | sudo apt-get update @@ -135,67 +159,38 @@ jobs: - name: Run tests run: ~/.local/bin/pytest -n 2 - build-back-i18n: + i18n-back: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v2 - - name: Attach workspace - uses: actions/checkout@v2 - with: - path: ~/people - - name: Install Python - uses: actions/setup-python@v3 - with: - python-version: '3.10' - name: Install gettext (required to make messages) run: | sudo apt-get update sudo apt-get install -y gettext - - name: Generate and persist the translations base file - run: ~/.local/bin/django-admin makemessages --keep-pot --all - - name: Persist translations to workspace - uses: actions/upload-artifact@v2 - with: - name: translations - path: src/backend/locale - - upload-i18n-strings: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - name: Attach workspace - uses: actions/checkout@v2 - with: - path: ~/people - - name: Upload files to Crowdin - run: crowdin upload sources -c crowdin/config.yml - - package-back: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 - name: Install Python uses: actions/setup-python@v3 with: python-version: '3.10' - - name: Build python package - run: python setup.py sdist bdist_wheel - - name: Persist build packages to workspace - uses: actions/upload-artifact@v2 - with: - name: packages - path: src/backend/dist - - name: Store packages as artifacts - uses: actions/upload-artifact@v2 - with: - name: packages - path: src/backend/dist + - name: Install development dependencies + working-directory: src/backend + run: pip install --user .[dev] + - name: Generate the translation base file + run: ~/.local/bin/django-admin makemessages --keep-pot --all + - name: Upload files to Crowdin + run: | + docker run \ + --rm \ + -e CROWDIN_API_TOKEN=${{ secrets.CROWDIN_API_TOKEN }} \ + -e CROWDIN_PROJECT_ID=${{ vars.CROWDIN_PROJECT_ID }} \ + -e CROWDIN_BASE_PATH=${{ vars.CROWDIN_BASE_PATH }} \ + -v "${{ github.workspace }}:/app" \ + crowdin/cli:3.16.0 \ + crowdin upload sources -c /app/crowdin/config.yml hub: runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') steps: - name: Checkout repository uses: actions/checkout@v2 diff --git a/Dockerfile b/Dockerfile index da75b75..b7c9bbe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -144,7 +144,7 @@ USER ${DOCKER_USER} COPY --from=link-collector ${PEOPLE_STATIC_ROOT} ${PEOPLE_STATIC_ROOT} # Copy people mails -COPY --from=mail-builder /mail/backend/people/core/templates/mail /app/people/core/templates/mail +COPY --from=mail-builder /mail/backend/core/templates/mail /app/core/templates/mail # The default command runs gunicorn WSGI server in people's main module CMD gunicorn -c /usr/local/etc/gunicorn/people.py people.wsgi:application diff --git a/Makefile b/Makefile index b90f08e..5e24dd8 100644 --- a/Makefile +++ b/Makefile @@ -217,14 +217,12 @@ crowdin-upload: ## Upload source translations to crowdin i18n-compile: ## compile all translations i18n-compile: \ - back-i18n-compile \ - admin-i18n-compile + back-i18n-compile .PHONY: i18n-compile i18n-generate: ## create the .pot files and extract frontend messages i18n-generate: \ - back-i18n-generate \ - admin-i18n-extract + back-i18n-generate .PHONY: i18n-generate i18n-download-and-compile: ## download all translated messages and compile them to be used by all applications diff --git a/docker-compose.yml b/docker-compose.yml index 427a529..1751de4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -102,7 +102,7 @@ services: image: jwilder/dockerize crowdin: - image: crowdin/cli:3.5.2 + image: crowdin/cli:3.16.0 volumes: - ".:/app" env_file: diff --git a/src/backend/core/tests/swagger/__init__.py b/src/backend/core/tests/swagger/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/backend/core/tests/swagger/test_openapi_schema.py b/src/backend/core/tests/swagger/test_openapi_schema.py index 50611cd..5fa079e 100644 --- a/src/backend/core/tests/swagger/test_openapi_schema.py +++ b/src/backend/core/tests/swagger/test_openapi_schema.py @@ -14,10 +14,28 @@ pytestmark = pytest.mark.django_db def test_openapi_client_schema(): """ - Generated OpenAPI client schema should be correct. + Generated and served OpenAPI client schema should be correct. """ + # Start by generating the swagger.json file + output = StringIO() + call_command( + "spectacular", + "--api-version", + "v1.0", + "--urlconf", + "people.api_urls", + "--format", + "openapi-json", + "--file", + "core/tests/swagger/swagger.json", + stdout=output, + ) + assert output.getvalue() == "" + response = Client().get("/v1.0/swagger.json") assert response.status_code == 200 - with open("core/tests/swagger/swagger.json") as expected_schema: + with open( + "core/tests/swagger/swagger.json", "r", encoding="utf-8" + ) as expected_schema: assert response.json() == json.load(expected_schema) diff --git a/src/backend/locale/fr_FR/LC_MESSAGES/django.mo b/src/backend/locale/fr_FR/LC_MESSAGES/django.mo new file mode 100644 index 0000000000000000000000000000000000000000..9862a19497b7bdc9c6c97248c656eeb3140f6d25 GIT binary patch literal 474 zcmZWlO-}+b5XI=JN6#L5@Sur<`+*82co5iR6NrSY#+xa-!%|(^P22V3hj{mw`CIIw z0+C5x+RnT;(>Gs-2OkX=dk#kq#}4}rXAX6=9X?&LH^6*QlZji+{dtMe? z$SzG6TpP5#yCj14hF1@rqlTeORVHN4XnQ6snG}`g1w=|O4WqJLJxwp@(w}SZMAB>O zpLWRu^tF0*Qutlb&R%vH5Dyr=46iz2YfJuTxi+_zjzr;{%y{~YGHaH~{;RE;1*Gu} DAL@-~ literal 0 HcmV?d00001 diff --git a/src/backend/locale/fr_FR/LC_MESSAGES/django.po b/src/backend/locale/fr_FR/LC_MESSAGES/django.po new file mode 100644 index 0000000..57f2f0c --- /dev/null +++ b/src/backend/locale/fr_FR/LC_MESSAGES/django.po @@ -0,0 +1,191 @@ +msgid "" +msgstr "" +"Project-Id-Version: lasuite-people\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-01-03 23:15+0000\n" +"PO-Revision-Date: 2024-01-03 23:15\n" +"Last-Translator: \n" +"Language-Team: French\n" +"Language: fr_FR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Crowdin-Project: lasuite-people\n" +"X-Crowdin-Project-ID: 637934\n" +"X-Crowdin-Language: fr\n" +"X-Crowdin-File: backend.pot\n" +"X-Crowdin-File-ID: 2\n" + +#: core/models.py:30 +msgid "Member" +msgstr "" + +#: core/models.py:31 +msgid "Administrator" +msgstr "" + +#: core/models.py:32 +msgid "Owner" +msgstr "" + +#: core/models.py:44 +msgid "id" +msgstr "" + +#: core/models.py:45 +msgid "primary key for the record as UUID" +msgstr "" + +#: core/models.py:51 +msgid "created on" +msgstr "" + +#: core/models.py:52 +msgid "date and time at which a record was created" +msgstr "" + +#: core/models.py:57 +msgid "updated on" +msgstr "" + +#: core/models.py:58 +msgid "date and time at which a record was last updated" +msgstr "" + +#: core/models.py:89 +msgid "full name" +msgstr "" + +#: core/models.py:90 +msgid "short name" +msgstr "" + +#: core/models.py:95 +msgid "contact information" +msgstr "" + +#: core/models.py:96 +msgid "A JSON object containing the contact information" +msgstr "" + +#: core/models.py:110 +msgid "contact" +msgstr "" + +#: core/models.py:111 +msgid "contacts" +msgstr "" + +#: core/models.py:173 +msgid "language" +msgstr "" + +#: core/models.py:174 +msgid "The language in which the user wants to see the interface." +msgstr "" + +#: core/models.py:180 +msgid "The timezone in which the user wants to see times." +msgstr "" + +#: core/models.py:183 +msgid "device" +msgstr "" + +#: core/models.py:185 +msgid "Whether the user is a device or a real user." +msgstr "" + +#: core/models.py:188 +msgid "staff status" +msgstr "" + +#: core/models.py:190 +msgid "Whether the user can log into this admin site." +msgstr "" + +#: core/models.py:193 +msgid "active" +msgstr "" + +#: core/models.py:196 +msgid "Whether this user should be treated as active. Unselect this instead of deleting accounts." +msgstr "" + +#: core/models.py:208 +msgid "user" +msgstr "" + +#: core/models.py:209 +msgid "users" +msgstr "" + +#: core/models.py:245 +msgid "Enter a valid sub. This value may contain only letters, numbers, and @/./+/-/_ characters." +msgstr "" + +#: core/models.py:252 +msgid "sub" +msgstr "" + +#: core/models.py:254 +msgid "Required. 255 characters or fewer. Letters, numbers, and @/./+/-/_ characters only." +msgstr "" + +#: core/models.py:260 +msgid "email address" +msgstr "" + +#: core/models.py:262 +msgid "main" +msgstr "" + +#: core/models.py:264 +msgid "Designates whether the email is the main one." +msgstr "" + +#: core/models.py:270 +msgid "identity" +msgstr "" + +#: core/models.py:271 +msgid "identities" +msgstr "" + +#: core/models.py:278 +msgid "This email address is already declared for this user." +msgstr "" + +#: core/models.py:323 +msgid "Team" +msgstr "" + +#: core/models.py:324 +msgid "Teams" +msgstr "" + +#: core/models.py:375 +msgid "Team/user relation" +msgstr "" + +#: core/models.py:376 +msgid "Team/user relations" +msgstr "" + +#: core/models.py:381 +msgid "This user is already in this team." +msgstr "" + +#: core/models.py:451 +msgid "Token contained no recognizable user identification" +msgstr "" + +#: people/settings.py:132 +msgid "English" +msgstr "" + +#: people/settings.py:133 +msgid "French" +msgstr "" +