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

[4.0][RFC] Drop minified static files from the repo #19637

Closed
wants to merge 3 commits into from
Closed

[4.0][RFC] Drop minified static files from the repo #19637

wants to merge 3 commits into from

Conversation

dgrammatiko
Copy link
Contributor

@dgrammatiko dgrammatiko commented Feb 10, 2018

Pull Request for Issue # .

Summary of Changes

  • All minified css and js files were removed from the repo
  • JHTML (or better HTMLHelper) was adjusted to pick the right files depending on debug state and irrelative to the given extension (eg .min.js or .js)

Why

  • This will make contributors life easier as they won't have to mess with node and try to figure out how to minify js.
  • It's kinda unsafe to accept minified code...

Possible problems

  • The repo remains installable but doesn't contain the production preferred minified files, so someone downloading it from GitHub will have to run build in order to get to production mode.
  • Although the idea here is to help contributors by offering an easer path for involvement and there is some security issue by accepting minified code, we do increase our dependency on tools and maybe this requires some more testing. Probably the release team can shed some light here.

WIP

As I opened the PR for comments there are parts that are missing here:

  • For SASS we need to see if we can trigger the minifier per request, so things could be tested.
  • The build script needs to run the node uglifier then pack the packages and then remove the minified files again. This code is not included in the PR (it makes no sense to spent time if this won't be approved)

Testing Instructions

Apply patch, or better download the branch from issue tracker and install. Check debug options and that all css and js files are still loaded correctly

Expected result

Actual result

Documentation Changes Required

Yes but mainly this will affect the maintainers (for the rest contributors is just removing the requirement for compressing js)

Calling @mbabker @wilsonge @rdeutz @dneukirchen @yvesh

@joomla-cms-bot joomla-cms-bot added PR-4.0-dev RFC Request for Comment labels Feb 10, 2018
@dneukirchen
Copy link
Contributor

dneukirchen commented Feb 10, 2018

I like it.
👍 Makes dev life a lot easier.
👍 Nobody really reviews whats committed in minified code.
👍 Those who want to install or deploy from github to production should be able to run the build by themselves.
😿 Will brake some tools...

@mbabker
Copy link
Contributor

mbabker commented Feb 10, 2018

The repo is not installable as is anymore, so someone downloading it from GitHub will have to run build before actually installing it.

That's the problem. The repo has always been in an installable state and if this is going to be accepted then we need to remove libraries/vendor from VCS too.

Likewise, before this can be merged whatever updates are needed so that distributable packages can be built (i.e. nightly builds, and eventually the production packages) must be included.

Documentation Changes Required

More than just affecting maintainer workflow. You are in effect changing workflow for all contributors because the acceptance of this PR means one can no longer simply git clone the repo and go to work, they must be willing to go through additional steps to get to a usable state.

This also puts a lot of trust in the build process because this means there are going to be a lot of files included in packages that will have zero opportunity for test/review until someone creates a package. For in house framework built apps not checking compiled assets into the repo is fine because of the workflows we use, and it not being mass distributed code, but I worry a bit about opening the door to us distributing possibly hundreds of files that have no chance for test/review to hundreds of thousands of sites.

@dgrammatiko
Copy link
Contributor Author

The repo has always been in an installable

Actually the repo remains installable and works fine as is, but for production use will not be a good fit as all the js is not minified. Sorry didn't phrase that correctly! :(

distributing possibly hundreds of files that have no chance for test/review

Pretty sure we can set some safety net, so this whole procedure is not going down to trusting blindly someone else's uglifier code.

@brianteeman
Copy link
Contributor

I am not in favour of any PR that means there are files in the release which have not been extensively tested

@dgrammatiko
Copy link
Contributor Author

@brianteeman that will not be the case, since we have https://github.com/joomla-projects/gsoc17_pr_testing_platform where we can add the minified scripts (eg run node uglify)

@dneukirchen
Copy link
Contributor

dneukirchen commented Feb 10, 2018

I am not in favour of any PR that means there are files in the release which have not been extensively tested

Got the point, but the problem is that at the moment, nobody (no person or tool) tests/reviews those files (expecially the minified scripts). Thats a possible security risk. Someone could commit malicious code (i.e. a credit-card or password scraper) in the minified version of the script without getting noticed.

We need to improve CI, automated testing and workflows, but im still in favor of this and think it is the right step.

@brianteeman
Copy link
Contributor

Not saying the custom system is perfect but i dont agree with this method of improvement

@dgt41 if that ever gets implemented I would be happy to reconsider my opinion

@mbabker
Copy link
Contributor

mbabker commented Feb 10, 2018

Someone could commit malicious code (i.e. a credit-card or password scraper) in the minified version of the script without getting noticed.

Then we need to improve our tooling to validate these files, not trust that myself, George, and Robert's personal systems as well as the CI infrastructure we use to build nightly packages are able to build release packages and never be compromised. I'm comfortable shipping non-version controlled files in projects where I have full control over the source and deploy workflow, but personally I'm less willing to push my luck right now on a mass distributed project like Joomla, it just seems far too risky at the moment.

@dgrammatiko
Copy link
Contributor Author

@mbabker @brianteeman but we still have the release team that tests things before the hit the public, or not?
The only difference here is who initiates the node uglifyjs and so far (all these months we're using this) we never had a glitch in this procedure (I mean getting an uglified file messed up). I'm not saying that this might not happen but there are multiple level of protection here:

  • Lock the uglify code to specific version,
  • Update it only after chorally tested that the results of all files are the same as the previous version
    ...

It's not black or white, but this is a step forward

@laoneo
Copy link
Member

laoneo commented Feb 10, 2018

I think it would be a step into the right direction. The advantages do overweight the concerns. Going that path would also simplify the dev workflow of the media manager.

then we need to remove libraries/vendor from VCS too

Agree here.

An issue I see is with our human patch testing. When they install a nightly and do not turn on the debug mode, then they are not testing the js changes in a patch. Probably we need to add an alert in the patch tester too if debug mode is disabled.

@mbabker
Copy link
Contributor

mbabker commented Feb 10, 2018

Patch tester becomes unusable once we remove assets from the repository without requiring Node and Composer.

@dgrammatiko
Copy link
Contributor Author

then they are not testing the js changes in a patch

But we can adjust the nightly to run node uglify before packing (or not, haven’t checked that code)

@mbabker
Copy link
Contributor

mbabker commented Feb 10, 2018

But we can adjust the nightly to run node uglify before packing (or not, haven’t checked that code)

It would have to be adjusted. Nightly builds are basically the same as the full release builds, just a hacked script to be able to build from branch versus tag and only build ZIP packages.

@brianteeman
Copy link
Contributor

@mbabker @brianteeman but we still have the release team that tests things before the hit the public, or not?

Your guess is as good as mine https://volunteers.joomla.org/teams/cms-release-team

@brianteeman
Copy link
Contributor

An issue I see is with our human patch testing. When they install a nightly and do not turn on the debug mode, then they are not testing the js changes in a patch.

Not true

@C-Lodder
Copy link
Member

Agree with removing minified files from the repo for both CSS and JS.

Should be up to the CMS maintainer to run the build scripts before publishing a release on Github.

This does indeed make life mich easier for those who contribute code, more so those who have never heard of Node.

Will also mean less conflicts.

@brianteeman
Copy link
Contributor

TBH there are a lot more important issues to address with j4 than this PR - there really has been almost no significant movement since the alpha release

@dgrammatiko
Copy link
Contributor Author

@brianteeman that’s why we try to address what seems to be unimportant issues since there are no major tasks on the table :(

@brianteeman
Copy link
Contributor

There are lots of major tasks but they all seem to have stalled :(
By the time 4 is released web components will be last years trend

@C-Lodder
Copy link
Member

Being part of a small group who manages CSS ans JS, can I also say I'm verging on sick to death of dealing with conflicts, most of which come from minified files

@mbabker
Copy link
Contributor

mbabker commented Feb 10, 2018

There are lots of major tasks but they all seem to have stalled :(

I can keep doing code stuff but when there are 3 people who do all the architecture stuff I don't have the desire to move very quickly on that (I'm doing PHPCS upgrades on 80 branches of our code, a more productive use of my time, believe it or not).

Anything UI related personally I'm not touching (including install from web) until the next template is produced.

So that leaves working on tool chains. Which is what this PR does. I get all the reasoning behind it, personally I have no issue with the approach, but fundamentally it's a major shift requiring a lot of buy in from a lot of sources.

@Fedik
Copy link
Member

Fedik commented Feb 10, 2018

The repo is not installable as is anymore, so someone downloading it from GitHub will have to run build before actually installing it.

no, it is not that big problem, if we do the thing right (see bottom) 😉

then we need to remove libraries/vendor from VCS too

no, it is different,
we still have all JS/CSS/SCSS sources under VCS, we just remove minified versions

What about compromise?

We remove all minified versions from repo as @dgt41 sugested.
But.
We keep pre-compiled SCSS.
We keep all sources in the place where they should be in the production.
And make HTMLHelper to always use source (files without .min.blabla) when $version->isInDevelopmentState() === true.

So the repo stays installable and usable and testable.
A testers will always test a source, that will avoid a problem when source and minified version are different, that happens time to time with different scripts.
We still safe from security point of view, because all minified versions will be compiled from sources which is in our repo.

in the theory all should work good 😄

@dgrammatiko
Copy link
Contributor Author

And make HTMLHelper to always use source (files without .min.blabla) when $version->isInDevelopmentState() === true.

@Fedik this is already implemented here in the HTMLHelper : https://github.com/joomla/joomla-cms/pull/19637/files#diff-8f6485b51d191985c4d1e9fbbf1a743aR1311

@dgrammatiko
Copy link
Contributor Author

This RFC served it's purpose so longer needs to be open, lets move the discussion to #19744

@dgrammatiko dgrammatiko deleted the §4.0-dev-drop-minified branch February 20, 2018 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFC Request for Comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants