Skip to content

Commit

Permalink
Updates Lingo to latest Arches Application pattern in v7.6.x (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnatawnclementawn authored Jul 31, 2024
1 parent ff0abbe commit 4105a8f
Show file tree
Hide file tree
Showing 21 changed files with 5,214 additions and 17,295 deletions.
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
153 changes: 10 additions & 143 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,75 +33,12 @@ jobs:
python-version: ${{ matrix.python-version }}
check-latest: true

- 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
- name: Install Python packages
run: |
python -m pip install --upgrade pip
pip install .
pip install -r arches_lingo/install/requirements.txt
pip install -r arches_lingo/install/requirements_dev.txt
echo Python packages installed
- uses: ankane/setup-elasticsearch@v1
with:
elasticsearch-version: 8

- name: Webpack frontend files
run: |
echo "Checking for package.json..."
if [ -f package.json ]; then
echo "package.json found, building static bundle."
npm install && npm run build_test
else
echo "package.json not found, skipping npm commands."
fi
- name: Check formatting
run: |
npm run prettier:check
black . --check --exclude=node_modules
- name: Run frontend tests
run: |
npm run vitest
mv coverage/frontend/coverage.xml feature_branch_frontend_coverage.xml
- name: Check for missing migrations
run: |
python manage.py makemigrations --check
- name: Ensure previous Python coverage data is erased
run: |
coverage erase
- name: Run Python unit tests
run: |
python -W default::DeprecationWarning -m coverage run manage.py test tests --settings="tests.test_settings"
- name: Generate Python report coverage
run: |
coverage report
coverage json
mv coverage/python/coverage.json feature_branch_python_coverage.json
- name: Upload frontend coverage report as artifact
uses: actions/upload-artifact@v4
- name: Build and test branch
uses: ./.github/actions/build-and-test-branch
with:
name: feature-branch-frontend-coverage-report
path: feature_branch_frontend_coverage.xml
overwrite: true

- name: Upload Python coverage report as artifact
uses: actions/upload-artifact@v4
with:
name: feature-branch-python-coverage-report
path: feature_branch_python_coverage.json
overwrite: true
secrets: ${{ toJSON(secrets) }}
project-name: 'arches_lingo'
branch-type: 'feature'

build_target_branch:
runs-on: ubuntu-latest
Expand All @@ -123,89 +60,19 @@ jobs:

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.base.ref }}

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
check-latest: true

- 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
- name: Install Python packages
run: |
python -m pip install --upgrade pip
pip install .
pip install -r arches_lingo/install/requirements.txt
pip install -r arches_lingo/install/requirements_dev.txt
echo Python packages installed
- uses: ankane/setup-elasticsearch@v1
with:
elasticsearch-version: 8

- name: Webpack frontend files
run: |
echo "Checking for package.json..."
if [ -f package.json ]; then
echo "package.json found, building static bundle."
npm install && npm run build_test
else
echo "package.json not found, skipping npm commands."
fi
- name: Run frontend tests
run: |
if [ -f vitest.config.json ]; then
npm run vitest
mv coverage/frontend/coverage.xml target_branch_frontend_coverage.xml
else
echo "Unable to find vitest config. Skipping frontend tests."
fi
- name: Check for missing migrations
run: |
python manage.py makemigrations --check
- name: Ensure previous Python coverage data is erased
run: |
coverage erase
- name: Run Python unit tests
run: |
python -W default::DeprecationWarning -m coverage run manage.py test tests --settings="tests.test_settings"
- name: Generate Python report coverage
run: |
coverage report
coverage json
# handles older target branch
if [ -f coverage/python/coverage.json ]; then
mv coverage/python/coverage.json target_branch_python_coverage.json
else
mv coverage.json target_branch_python_coverage.json
fi
- name: Upload frontend coverage report as artifact
uses: actions/upload-artifact@v4
- name: Build and test branch
uses: ./.github/actions/build-and-test-branch
with:
name: target-branch-frontend-coverage-report
path: target_branch_frontend_coverage.xml
overwrite: true

- name: Upload Python coverage report as artifact
uses: actions/upload-artifact@v4
with:
name: target-branch-python-coverage-report
path: target_branch_python_coverage.json
overwrite: true
secrets: ${{ toJSON(secrets) }}
project-name: 'arches_lingo'
branch-type: 'target'

check_frontend_coverage:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
*.pyc
*.log
node_modules
*.coverage
coverage/
arches_lingo/logs
arches_lingo/export_deliverables
arches_lingo/cantaloupe/*
Expand Down
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"
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"),
)
Loading

0 comments on commit 4105a8f

Please sign in to comment.