-
Notifications
You must be signed in to change notification settings - Fork 687
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 runtime javascript minification #6425
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #6425 +/- ##
===========================================
- Coverage 83.83% 83.81% -0.02%
===========================================
Files 62 62
Lines 4331 4326 -5
Branches 525 525
===========================================
- Hits 3631 3626 -5
Misses 575 575
Partials 125 125
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
8a4f055
to
9f08d39
Compare
(rebased on top of develop so the /tor2web-warning endpoint isn't throwing 500 errors, was fixed in cfae1e6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debs are still building, but I think we can remove the gen
and .webassets-cache
folders from the "Create static asset directories" step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the build failure I got:
=================================== FAILURES ===================================
_ test_deb_package_contains_no_generated_assets[docker://focal-sd-dpkg-verification] _
[gw1] linux -- Python 3.7.3 /home/user/securedrop/.venv/bin/python3
securedrop_app_code_contents = 'drwxr-xr-x root/root 0 2022-05-06 14:05 ./\ndrwxr-xr-x root/root 0 2022-05-06 14:05 ./etc/\ndrwxr-xr-...n3 -> /usr/bin/python3\nlrwxrwxrwx root/root 0 2022-05-06 14:05 ./opt/venvs/securedrop-app-code/lib64 -> lib\n'
def test_deb_package_contains_no_generated_assets(securedrop_app_code_contents: str):
"""
Ensures the `securedrop-app-code` package does not ship minified
static assets previously built at runtime via Flask-Assets under /gen, and
which may be present in the source directory used to build from.
"""
# static/gen/ directory not should exist
> assert not re.search(
r"^.*\./var/www/securedrop" "/static/gen/$", securedrop_app_code_contents, re.M
)
E AssertionError: assert not <re.Match object; span=(523650, 523730), match='drwxr-xr-x root/root 0 2022-05-06 14:05 .>
E + where <re.Match object; span=(523650, 523730), match='drwxr-xr-x root/root 0 2022-05-06 14:05 .> = <function search at 0x7080ed8d21e0>('^.*\\./var/www/securedrop/static/gen/$', 'drwxr-xr-x root/root 0 2022-05-06 14:05 ./\ndrwxr-xr-x root/root 0 2022-05-06 14:05 ./etc/\ndrwxr-xr-...n3 -> /usr/bin/python3\nlrwxrwxrwx root/root 0 2022-05-06 14:05 ./opt/venvs/securedrop-app-code/lib64 -> lib\n', <RegexFlag.MULTILINE: 8>)
E + where <function search at 0x7080ed8d21e0> = re.search
E + and <RegexFlag.MULTILINE: 8> = re.M
tests/test_securedrop_deb_package.py:273: AssertionError
=========================== short test summary info ============================
FAILED tests/test_securedrop_deb_package.py::test_deb_package_contains_no_generated_assets[docker:/focal-sd-dpkg-verification]
======= 1 failed, 143 passed, 1 skipped, 1 xfailed in 143.10s (0:02:23) ========
9f08d39
to
1984881
Compare
- serves static/js resources instead of gen/js resources - removes flask-assets, jsmin, and webassets dependencies and related code - updated apparmor profile to remove rw access to /gen/ - updates builder functionality/tests to ensure gen/ not present - updates postinst to remove gen/, .webassets-cache/ if present
1984881
to
72b8be1
Compare
D'oh! apologies on missing the CR @legoktm, PR is updated now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic, LGTM!
Status
Ready for review
Description of Changes
Fixes #6415
Testing
git clean -dfx
to ensure old generated files aren't left hanging aroundmake dev-tor
source.js
on the SI home page is served from/static/js/
, not/static/gen
/tor2web-warning
page on visiting the SI home pagejournalst.js
on the JI All Source page is served from/static/js/
, not/static/gen
make build-debs
, confirm that the package build completes without errormake staging
, and confirm that staging servers are provisioned without error and thatsource.js
andjournalist.js
are served from/static/js
on the SI and JI respectivelyUpgrade testing (optional)
source.js
andjournalist.js
are served from/static/js
on the SI and JI respectivelyDeployment
This PR modifies the
securedrop-app-code
postint
to remove the/static/gen
and/static/.webassets-cache
directories in the webroot, so upgrade testing should be performed prior to release.Checklist
If you made changes to the server application code:
make lint
) and tests (make test
) pass in the development containerIf you made changes to
securedrop-admin
:make -C admin test
) pass in the admin development containerIf you added or removed a file deployed with the application:
If you made non-trivial code changes:
Choose one of the following: