Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Move backend/ to the root of the project, open-contracting/software-development-handbook#115 #186

Merged
merged 1 commit into from
Oct 16, 2024
Merged
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
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: CI
on: [push, pull_request]
jobs:
build_backend:
backend:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-20.04
steps:
Expand All @@ -13,8 +13,7 @@ jobs:
cache-dependency-path: "**/requirements*.txt"
- run: pip install -r requirements.txt
# Check requirements.txt contains production requirements.
- working-directory: backend
run: ./manage.py --help
- run: ./manage.py --help
- run: pip install -r requirements_dev.txt
- name: Run Pelican backend migrations
run: |
Expand All @@ -28,7 +27,6 @@ jobs:
DATABASE_URL: postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres
PELICAN_BACKEND_DATABASE_URL: postgresql://postgres:postgres@localhost:${{ job.services.postgres.ports[5432] }}/postgres
shell: bash
working-directory: backend
run: |
./manage.py migrate
./manage.py makemigrations --check --dry-run
Expand All @@ -48,7 +46,7 @@ jobs:
ports:
- 5432/tcp

build_frontend:
frontend:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
runs-on: ubuntu-20.04
defaults:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/i18n.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ jobs:
sudo apt update
sudo apt install gettext translate-toolkit
- run: pip install -r requirements.txt
- working-directory: backend
run: python manage.py makemessages -a
- run: python manage.py makemessages -a
- name: Count incomplete translations
shell: bash
run: |
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ jobs:
- shell: bash
run: curl -s -S --retry 3 $BASEDIR/tests/script.sh | bash -
- run: pip install -r requirements_dev.txt
- working-directory: backend
run: pytest /tmp/test_requirements.py
- run: pytest /tmp/test_requirements.py
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ node_modules
*.mo
dist
.coverage
htmlcov
credentials.json
google_drive_cache
/backend/static
/htmlcov
/credentials.json
/google_drive_cache
/static
/docs/_build
2 changes: 1 addition & 1 deletion Dockerfile_django
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN pip install --no-cache-dir -r /tmp/requirements.txt

WORKDIR /workdir
USER runner:runner
COPY --chown=runner:runner backend .
COPY --chown=runner:runner . .

ENV DJANGO_ENV=production
ENV WEB_CONCURRENCY=2
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile_static
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ ENV DJANGO_ENV=production

WORKDIR /workdir/frontend
RUN npx vue-cli-service build
WORKDIR /workdir/backend
WORKDIR /workdir
RUN python manage.py collectstatic --noinput -v2

FROM nginxinc/nginx-unprivileged:latest as production-stage
USER root
COPY --from=build-stage --chown=nginx:root /workdir/frontend/dist /usr/share/nginx/html
COPY --from=build-stage --chown=nginx:root /workdir/backend/static /usr/share/nginx/html/static
COPY --from=build-stage --chown=nginx:root /workdir/static /usr/share/nginx/html/static
COPY --chown=nginx:root frontend/default.conf /etc/nginx/conf.d/default.conf
USER nginx
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"indentStyle": "space",
"indentWidth": 4,
"lineWidth": 119,
"ignore": ["backend/release-schema.json"]
"ignore": ["release-schema.json"]
},
"json": {
"formatter": {
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 0 additions & 2 deletions backend/core/settings.py → core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,6 @@

# The path to a service account JSON file, for writing exports to Google Drive.
# https://developers.google.com/workspace/guides/create-credentials#service-account
# WARNING: If you change the directory for the production default, update `backend/Dockerfile` and
# `docker-compose.yaml` volumes.
SERVICE_ACCOUNT_JSON_FILE = os.getenv("SERVICE_ACCOUNT_JSON_FILE", "credentials.json")

# The Google Docs IDs for templates, when writing exports to Google Drive.
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

import django

sys.path.insert(0, os.path.join(os.path.abspath(".."), "backend"))
sys.path.insert(0, os.path.abspath(".."))
os.environ["DJANGO_SETTINGS_MODULE"] = "core.settings"

django.setup()
Expand Down
6 changes: 3 additions & 3 deletions docs/contributing/add-check.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Add a check

In all cases:

#. Add a line to ``backend/export/translations.py``
#. Add a line to ``exporter/translations.py``

Field-level
-----------
Expand All @@ -15,7 +15,7 @@ The UI otherwise automatically supports new field-level checks.
Compiled release-level
----------------------

#. Add an element to ``CHECKS`` in ``backend/exporter/template_tags/resource.py``
#. Add an element to ``CHECKS`` in ``exporter/template_tags/resource.py``
#. Add an element to ``order`` in ``frontend/src/components/ResourceLevelList.vue``
#. If a section other than ``coherent``, ``consistent`` or ``reference`` is used, add it to ``sections`` in ``frontend/src/views/Resource.vue``
#. Add new keys to ``resourceLevel.coherent``, ``resourceLevel.consistent`` and/or ``resourceLevel.reference`` in ``frontend/src/messages/en.js``
Expand All @@ -25,7 +25,7 @@ The UI otherwise automatically supports new compiled release-level checks.
Dataset-level
-------------

#. Add a key-value pair to ``CHECK_TYPES`` in ``backend/exporter/template_tags/dataset.py``
#. Add a key-value pair to ``CHECK_TYPES`` in ``exporter/template_tags/dataset.py``
#. Add a key-value pair to ``checkTypeData`` in ``frontend/src/plugins/datasetMixins.js``
#. Add an element to the appropriate array in ``frontend/src/components/DatasetLevelSection.vue``
#. Add new keys to ``datasetLevel`` in ``frontend/src/messages/en.js``
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/add-metadata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Add metadata

#. Update the template in ``frontend/src/views/Overview.vue``.
#. Add new keys to ``overview`` in ``frontend/src/messages/en.js``.
#. Update the ``tags`` tuple and return value in ``backend/exporter/template_tags/overview.py``.
#. Update the ``tags`` tuple and return value in ``exporter/template_tags/overview.py``.

13 changes: 3 additions & 10 deletions docs/contributing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ Set up the git pre-commit hook:
Backend
~~~~~~~

Change to the ``backend`` directory:

.. code-block:: bash

cd backend

Install development dependencies:

.. code-block:: bash
Expand All @@ -47,7 +41,7 @@ If you don't have an instance of `Pelican backend <https://pelican-backend.readt
.. code-block:: bash

createdb pelican_backend
gunzip -c backend/tests/fixtures/pelican-backend.sql | psql pelican_backend
gunzip -c tests/fixtures/pelican-backend.sql | psql pelican_backend

Frontend
~~~~~~~~
Expand All @@ -73,7 +67,6 @@ In one terminal, start the backend server:

.. code-block:: bash

cd backend
./manage.py runserver

In another terminal, start the frontend server:
Expand Down Expand Up @@ -109,9 +102,9 @@ Pelican backend integration

`Pelican backend <https://pelican-backend.readthedocs.io/en/latest/>`__'s database is treated as a read-only `legacy database <https://docs.djangoproject.com/en/4.2/howto/legacy-databases/>`__, with ``managed = False`` in all model's ``Meta`` class, and with a ``DATABASE_ROUTERS`` setting that routes queries to its database.

To update ``backend/api/models.py`` following changes to Pelican backend's database schema:
To update ``api/models.py`` following changes to Pelican backend's database schema:

- Run ``python backend/manage.py inspectdb > backend/api/models.py``
- Run ``python manage.py inspectdb > api/models.py``
- Replace comments at top of file
- Replace ``models.DO_NOTHING`` with ``on_delete=models.CASCADE``
- ``Dataset.meta``: Add ``blank=True, default=dict``
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing/update-check.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ Pelican frontend does not pre-emptively disallow new versions, since breaking ch

For example, changing the histogram bins (buckets) in Pelican backend would require supporting more bins in:

- ``backend/exporter/leaf_tags/dataset.py``
- ``exporter/leaf_tags/dataset.py``
- ``frontend/src/components/BarChartSingleValue.vue``
2 changes: 1 addition & 1 deletion docs/export.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Simple tags accept no arguments.
* - ``{% lifecycleImage %}``
- this image in a frame with the number of objects per contracting stage

.. image:: ../backend/exporter/assets/images/lifecycle.png
.. image:: ../exporter/assets/images/lifecycle.png

Date leaf tags
^^^^^^^^^^^^^^
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ version = "0.0.0"
[tool.ruff]
line-length = 119
target-version = "py311"
src = ["backend"]

[tool.ruff.lint]
select = ["ALL"]
Expand All @@ -29,13 +28,13 @@ ignore-variadic-names = true
"docs/*" = ["D100", "INP001"]
"{*/signals,*/views,*/migrations/*}.py" = ["ARG001"]
"{*/admin,*/routers,*/views,*/commands/*}.py" = ["ARG002"]
"{*/admin,*/forms,*/models,*/routers,*/migrations/*,*/tests/*}.py" = ["RUF012"]
"{*/admin,*/forms,*/models,*/routers,*/migrations/*,tests/*}.py" = ["RUF012"]
"*/{serializers,views}.py" = ["RUF012"]
"*/migrations/*" = ["E501"]
"*/tests/*" = [
"tests/*" = [
"D", "FBT003", "INP001", "PLR2004", "PT", "S", "TRY003",
]
"*/exporter/*" = [
"exporter/*" = [
"D205",
"ARG001", # tag
"ARG002", # data
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.