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

Updates Lingo to latest Arches Application pattern in v7.6.x #35

Merged
merged 9 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ omit =
*/settings*.py
*/urls.py
*/wsgi.py
*/hosts.py
*/celery.py
*/__init__.py

Expand Down
11 changes: 11 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Known binary formats
*.png binary
*.jpg binary
*.ico binary
*.gif binary
*.ttf binary
*.woff binary
*.woff2 binary
120 changes: 120 additions & 0 deletions .github/actions/build-and-test-branch/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: 'Build and test branch'
description: 'Builds and tests a branch'
inputs:
branch-type:
description: 'String denoting either `target` or `feature` branch'
required: true
project-name:
description: 'String denoting the name of the project'
required: true
secrets:
description: 'Secrets from main.yml as JSON'
runs:
using: 'composite'
steps:
- name: Install Java, GDAL, and other system dependencies
run: |
sudo apt update
sudo apt-get install libxml2-dev libpq-dev openjdk-8-jdk libgdal-dev libxslt-dev
echo Postgres and ES dependencies installed
shell: bash

- name: Set up Elasticsearch
uses: ankane/setup-elasticsearch@v1
with:
elasticsearch-version: 8

- name: Install Python packages
run: |
python -m pip install --upgrade pip
pip install '.[dev]'
echo Python packages installed
shell: bash

- name: Install Arches applications
uses: ./.github/actions/install-arches-applications
with:
secrets: ${{ inputs.secrets }}

- name: Checkout into feature branch
if: inputs.branch-type == 'feature'
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ github.ref }}
path: .

- name: Checkout into target branch
if: inputs.branch-type == 'target'
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
ref: ${{ github.event.pull_request.base.ref }}
path: .

- name: Install frontend dependencies
run: |
npm install
shell: bash

- name: Webpack frontend files
run: |
npm run build_test
shell: bash

- name: Check frontend formatting with prettier
run: |
npm run prettier:check
shell: bash

- name: Check backend formatting with black
run: |
black . --check --exclude=node_modules
shell: bash

- name: Check line endings
run: |
! git ls-files --eol | grep 'w/crlf\|w/mixed'
shell: bash

- name: Run frontend tests
run: |
npm run vitest
mv coverage/frontend/coverage.xml ${{ inputs.branch-type }}_branch_frontend_coverage.xml
shell: bash

- name: Check for missing migrations
run: |
python manage.py makemigrations --check
shell: bash

- name: Ensure previous Python coverage data is erased
run: |
coverage erase
shell: bash

- name: Run Python unit tests
run: |
python -W default::DeprecationWarning -m coverage run manage.py test tests --settings="tests.test_settings"
shell: bash

- name: Generate Python report coverage
run: |
coverage report
coverage json
mv coverage/python/coverage.json ${{ inputs.branch-type }}_branch_python_coverage.json
shell: bash

- name: Upload frontend coverage report as artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.branch-type }}-branch-frontend-coverage-report
path: ${{ inputs.branch-type }}_branch_frontend_coverage.xml
overwrite: true

- name: Upload Python coverage report as artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.branch-type }}-branch-python-coverage-report
path: ${{ inputs.branch-type }}_branch_python_coverage.json
overwrite: true
29 changes: 29 additions & 0 deletions .github/actions/install-arches-applications/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'Install Arches Applications'
description: 'Manually edit this file to install all Arches Applications declared in settings.py, but not declared in `pyproject.toml`'
inputs:
secrets:
description: 'Secrets from main.yml as JSON'
runs:
using: 'composite'
steps:

# Manually add any ARCHES_APPLICATIONS to this file if not already declared in `pyproject.toml`.
# Below is a template for adding an application in a private repository.
# Be sure to delete the `no-op step` if adding when updating this file.

- name: No-op step to maintain workflow structure
run: echo "No-op step"
shell: bash

# - name: Checkout ${my_arches_application_name}
# uses: actions/checkout@v4
# with:
# repository: ${my_arches_application_repository}/${my_arches_application_name}
# token: ${{ fromJSON(inputs.secrets).${my_github_personal_access_token} }}
# path: ${my_arches_application_name}

# - name: Install ${my_arches_application_name}
# run: |
# pip install ./${my_arches_application_name}
# echo ${my_arches_application_name} installed
# shell: bash
7 changes: 7 additions & 0 deletions arches_lingo/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.apps import AppConfig


class Arches_LingoConfig(AppConfig):
name = "arches_lingo"
verbose_name = "Arches_Lingo"
jacobtylerwalls marked this conversation as resolved.
Show resolved Hide resolved
is_arches_application = True
7 changes: 7 additions & 0 deletions arches_lingo/hosts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import re
from django_hosts import patterns, host

host_patterns = patterns(
"",
host(re.sub(r"_", r"-", r"arches_lingo"), "arches_lingo.urls", name="arches_lingo"),
)
31 changes: 15 additions & 16 deletions arches_lingo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
ETL_MODULE_LOCATIONS.append("arches_lingo.etl_modules")
SEARCH_COMPONENT_LOCATIONS.append("arches_lingo.search_components")

LOCALE_PATHS.append(os.path.join(APP_ROOT, "locale"))
LOCALE_PATHS.insert(0, os.path.join(APP_ROOT, "locale"))

FILE_TYPE_CHECKING = False
FILE_TYPES = [
Expand Down Expand Up @@ -133,6 +133,7 @@
"django.contrib.messages",
"django.contrib.staticfiles",
"django.contrib.gis",
"django_hosts",
"arches",
"arches.app.models",
"arches.management",
Expand All @@ -146,7 +147,10 @@
"arches_lingo",
)

ARCHES_APPLICATIONS = ()
INSTALLED_APPS += ("arches.app",)

ROOT_HOSTCONF = "arches_lingo.hosts"
DEFAULT_HOST = "arches_lingo"

MIDDLEWARE = [
"corsheaders.middleware.CorsMiddleware",
Expand All @@ -165,17 +169,19 @@
# "silk.middleware.SilkyMiddleware",
]

STATICFILES_DIRS = build_staticfiles_dirs(
root_dir=ROOT_DIR,
app_root=APP_ROOT,
arches_applications=ARCHES_APPLICATIONS,
MIDDLEWARE.insert( # this must resolve to first MIDDLEWARE entry
0, "django_hosts.middleware.HostsRequestMiddleware"
)

MIDDLEWARE.append( # this must resolve last MIDDLEWARE entry
"django_hosts.middleware.HostsResponseMiddleware"
)

STATICFILES_DIRS = build_staticfiles_dirs(app_root=APP_ROOT)

TEMPLATES = build_templates_config(
root_dir=ROOT_DIR,
debug=DEBUG,
app_root=APP_ROOT,
arches_applications=ARCHES_APPLICATIONS,
)

ALLOWED_HOSTS = []
Expand Down Expand Up @@ -436,11 +442,4 @@

# returns an output that can be read by NODEJS
if __name__ == "__main__":
transmit_webpack_django_config(
root_dir=ROOT_DIR,
app_root=APP_ROOT,
arches_applications=ARCHES_APPLICATIONS,
public_server_address=PUBLIC_SERVER_ADDRESS,
static_url=STATIC_URL,
webpack_development_server_port=WEBPACK_DEVELOPMENT_SERVER_PORT,
)
transmit_webpack_django_config(**locals())
14 changes: 8 additions & 6 deletions arches_lingo/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@
from arches_lingo.views import ConceptTreeView

urlpatterns = [
path("", include("arches.urls")),
path("concept_trees/", ConceptTreeView.as_view(), name="concept_trees"),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
]

# Ensure Arches core urls are superseded by project-level urls
urlpatterns.append(path("", include("arches.urls")))

# Adds URL pattern to serve media files during development
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

# Only handle i18n routing in active project. This will still handle the routes provided by Arches core and Arches applications,
# but handling i18n routes in multiple places causes application errors.
if (
settings.APP_NAME != "Arches"
and settings.APP_NAME not in settings.ARCHES_APPLICATIONS
):
if settings.ROOT_URLCONF == __name__:
if settings.SHOW_LANGUAGE_SWITCH is True:
urlpatterns = i18n_patterns(*urlpatterns)

Expand Down
Loading
Loading