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

Remove django-compressor now it's replaced by webpack #94

Merged
merged 7 commits into from
Jun 18, 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
27 changes: 0 additions & 27 deletions .github/workflows/unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,30 +33,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

# We need node to install the JS dependencies used to build static assets.
# Because some unit tests use Django's test client to visit pages, we need
# to have JS and styles ready to be loaded on those pages or there will be
# errors.
# Uses the node version specified in package.json
- name: Setup node
uses: actions/setup-node@v4

# Basing the cache on the hash of the lockfile means that the cache should
# only ever be invalidated when we update package-lock.json, which happens
# as part of a release. For more info, see:
# https://docs.github.com/en/free-pro-team@latest/actions/guides/caching-dependencies-to-speed-up-workflows
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ hashFiles('package-lock.json') }}
npm-

- name: Install JS dependencies
run: npm ci

# Python version to use is stored in the .python-version file, which is the
# convention for pyenv (https://github.com/pyenv/pyenv)
# setup-python automatically picks up version from .python-version
Expand All @@ -80,9 +56,6 @@ jobs:
- name: Setup local_settings.py
run: python -c "import uuid; print('SECRET_KEY = \'%s\'' % uuid.uuid4())" >> cdhweb/settings/local_settings.py

- name: Build static assets
run: python manage.py compress

- name: Run pytest
run: pytest --cov=./ --cov-config=.coveragerc --cov-report=xml

Expand Down
10 changes: 7 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
CHANGELOG
=========

4.0.0-dev1
-----
- Redesigned and rebuilt
- TODO

3.5.3
-----

Expand Down Expand Up @@ -30,7 +35,7 @@ Maintenance release: npm package updates
- updated to django 4.2 and wagtail 5.0
- updated to python 3.8+ (tested against 3.8-3.11)
- updated node version 18
- removed editoria11y v1 integration
- removed editoria11y v1 integration
- removed Percy visual testing workflow

3.4.4
Expand All @@ -41,7 +46,7 @@ Maintenance release: npm package updates
3.4.3
-----

* Update to include Humanities + Data Science Institute instructors and participants as
* Update to include Humanities + Data Science Institute instructors and participants as
affiliates and student affiliates
* bugfixes:
* correct Event ordering on semester archive pages
Expand Down Expand Up @@ -401,4 +406,3 @@ Other Content
Import
~~~~~~
* As an admin, I want an import of content from the previous version of the site so that all the information available on the old site is migrated to the new version.

2 changes: 1 addition & 1 deletion cdhweb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version_info__ = (3, 5, 3, None)
__version_info__ = (4, 0, 0, "dev1")


# Dot-connect all but the last. Last is dash-connected if not None.
Expand Down
4 changes: 2 additions & 2 deletions cdhweb/pages/templatetags/core_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ def _get_secondary_nav_cta_button():
secondary_nav = SecondaryNavigation.objects.prefetch_related("cta_button")

if secondary_nav.exists():
cta_button = secondary_nav.first().cta_button.all()
return cta_button
return secondary_nav.first().cta_button.all()
return []


@register.simple_tag()
Expand Down
10 changes: 5 additions & 5 deletions cdhweb/projects/tests/test_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from cdhweb.projects.models import (
Grant,
GrantType,
PeopleLandingPageArchivedArchived,
Project,
ProjectRelatedLink,
ProjectsLandingPageArchived,
)


Expand Down Expand Up @@ -94,18 +94,18 @@ def test_sitemap(self, rf, derrida):
class TestProjectPage(WagtailPageTestCase):
def test_parent_pages(self):
"""project can only be created under projects link page"""
self.assertAllowedParentPageTypes(Project, [PeopleLandingPageArchivedArchived])
self.assertAllowedParentPageTypes(Project, [ProjectsLandingPageArchived])

def test_subpages(self):
"""project page can't have children"""
self.assertAllowedSubpageTypes(Project, [])


class TestPeopleLandingPageArchived(WagtailPageTestCase):
class TestProjectsLandingPageArchived(WagtailPageTestCase):
def test_parentpage_types(self):
"""projects link page should not be creatable in admin"""
self.assertAllowedParentPageTypes(PeopleLandingPageArchived, [])
self.assertAllowedParentPageTypes(ProjectsLandingPageArchived, [])

def test_subpage_types(self):
"""projects link page only allowed child is project page"""
self.assertAllowedSubpageTypes(PeopleLandingPageArchived, [Project, LinkPage])
self.assertAllowedSubpageTypes(ProjectsLandingPageArchived, [Project, LinkPage])
22 changes: 2 additions & 20 deletions cdhweb/settings/components/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Django settings for cdhweb.
"""

from pathlib import Path

#########
Expand Down Expand Up @@ -33,7 +34,7 @@
# Additional locations of static files
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
STATICFILES_DIRS = ()
STATICFILES_DIRS = [BASE_DIR / "static"]

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
Expand Down Expand Up @@ -115,27 +116,9 @@
# Increase file upload size to roughly 50 MB
FILEBROWSER_MAX_UPLOAD_SIZE = 50000000

# Use local node-sass installed via npm
COMPRESS_PRECOMPILERS = (("text/x-scss", "node_modules/.bin/sass {infile} {outfile}"),)

# Use local postcss-cli and autoprefixer installed via npm
COMPRESS_AUTOPREFIXER_BINARY = "node_modules/postcss-cli/bin/postcss"

COMPRESS_CSS_FILTERS = (
"compressor.filters.css_default.CssAbsoluteFilter",
# NOTE: requires COMPRESS_ENABLED = True when DEBUG is True
"django_compressor_autoprefixer.AutoprefixerFilter",
)

# use content hashing to ensure same url on both servers
COMPRESS_CSS_HASHING_METHOD = "content"


STATICFILES_FINDERS = (
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
# other finders..
"compressor.finders.CompressorFinder",
)

# Package/module name to import the root urlpatterns from for the project.
Expand Down Expand Up @@ -207,7 +190,6 @@
"modelcluster",
"taggit",
"adminsortable2",
"compressor",
"fullurl",
"django_cas_ng",
"wagtailcodeblock",
Expand Down
9 changes: 0 additions & 9 deletions cdhweb/settings/environments/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,5 @@
# required for tests when DEBUG = False
ALLOWED_HOSTS = ["*"]

# configure django-compressor to compress css & javascript
COMPRESS_ENABLED = True

# compress to the sitemedia folder
COMPRESS_ROOT = BASE_DIR / "sitemedia"

# run a full compress before e2e/a11y tests to serve statically
COMPRESS_OFFLINE = True

# override software version to avoid creating visual diffs in display
SW_VERSION = "CI Build"
8 changes: 1 addition & 7 deletions cdhweb/settings/local_settings.py.docker-sample
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,6 @@ PUCAS_LDAP.update(
}
)

# optional configuration for compress autoprefixer
# COMPRESS_AUTOPREFIXER_BINARY = '/usr/local/bin/postcss'
# COMPRESS_AUTOPREFIXER_ARGS = '--use autoprefixer' (default)

COMPRESS_ENABLED = False

# sample logging config
LOGGING = {
"version": 1,
Expand All @@ -70,4 +64,4 @@ LOGGING = {
CSRF_TRUSTED_ORIGINS = ["http://localhost", "https://cdh.dev.springload.nz"]

# disable feature detection in images
WAGTAILIMAGES_FEATURE_DETECTION_ENABLED = False
WAGTAILIMAGES_FEATURE_DETECTION_ENABLED = False
6 changes: 0 additions & 6 deletions cdhweb/settings/local_settings.py.sample
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ PUCAS_LDAP.update(
}
)

# optional configuration for compress autoprefixer
# COMPRESS_AUTOPREFIXER_BINARY = '/usr/local/bin/postcss'
# COMPRESS_AUTOPREFIXER_ARGS = '--use autoprefixer' (default)

COMPRESS_ENABLED = False

# sample logging config
LOGGING = {
"version": 1,
Expand Down
14 changes: 12 additions & 2 deletions cdhweb/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@
# wagtail paths
path("cms/", include(wagtailadmin_urls)),
path("documents/", include(wagtaildocs_urls)),
# let wagtail handle everything else
path("", include(wagtail_urls)),
]

if settings.DEBUG:
Expand All @@ -90,10 +88,22 @@
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
urlpatterns += staticfiles_urlpatterns()

# Serve 404 and 500 page templates(seeing as errors are masked with debug)
urlpatterns.extend(
[
path("404/", TemplateView.as_view(template_name="404.html")),
path("500/", TemplateView.as_view(template_name="500.html")),
]
)
try:
import debug_toolbar

# must come before wagtail catch-all route or else debug urls 404
urlpatterns.insert(0, path("__debug__/", include(debug_toolbar.urls)))
except ImportError:
pass

urlpatterns.append(
# let wagtail handle everything else
path("", include(wagtail_urls)),
)
28 changes: 2 additions & 26 deletions docker/application/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,8 @@
# syntax=docker/dockerfile:1.4

## Frontend TODO once Springload approach added
# # frontend assets
# FROM node:20-alpine as frontend

# RUN apk add --update git

# WORKDIR /app

# # Install packages
# COPY package.json package-lock.json /app/
# RUN --mount=type=cache,target=/root/.npm NPM_CACHE_FOLDER=/root/.npm \
# npm ci

# # Copy config/build files
# COPY webpack.config.js webpack.fix-django-paths.js tsconfig.json /app/
# COPY core/static_src /app/core/static_src
# COPY core/templates_src /app/core/templates_src

# RUN npm run build

# CMD ["npm", "run build"]


## -----
# Base backend
# On Debian, as their prod is Ubuntu
# On Debian, as prod is Ubuntu
FROM --platform=linux/x86_64 python:3.11-slim-bullseye as base

ENV PROJECT cdh-web
Expand Down Expand Up @@ -70,11 +47,10 @@ ENV DJANGO_SETTINGS_MODULE cdhweb.settings

ADD --chmod=755 https://github.com/mrako/wait-for/releases/download/v1.0.0/wait-for /usr/local/bin/

# TODO: Frontend: Remove npm install once deps are built without compressor
RUN --mount=type=cache,target=/var/lib/apt/lists \
--mount=type=cache,target=/var/cache/apt \
apt-get update -y && apt-get install --no-install-recommends -y \
netcat npm
netcat

RUN --mount=type=cache,target=/root/.cache/pip \
pip3 install -r /app/requirements/dev.txt \
Expand Down
2 changes: 0 additions & 2 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ django-appconf==1.0.4
django-apptemplates==1.5
django-cas-ng==4.1.1
django-cogwheels==0.3
django-compressor==2.4.1
django-compressor-autoprefixer==0.1.0
django-contrib-comments==2.0.0
django-dbml @ git+git://github.com/thatbudakguy/django-dbml@334ead74c8c4fa4ae997adeccaa5f3d5367f17b2
django-debug-toolbar==3.2
Expand Down
2 changes: 0 additions & 2 deletions requirements/prod.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
Django>=4.2,<5.1
pillow>=9.1.0
wagtail>=5.2,<6.0
django-compressor
django-compressor-autoprefixer
psycopg2-binary
django-admin-sortable2
# wagtail 4.2 requires taggit<5.0
Expand Down
Loading