Conversation
|
nice work! 👏
we usually use https://github.com/ember-cli/ember-cli/blob/master/lib/experiments/index.js for these things, though that does not use env vars (yet). I would recommend migrating the feature flag to that file but instead of using the |
|
@Turbo87 Done. What's the best way to CI test this? Is it possible to re-run all tests with and without the env var set? |
What we currently do is: on What I'm meaning to say: what we currently do is not great and I think running the test suite with experiments turned off by default would be better and then adding another CI job per experiment. @ember-cli/core thoughts? |
|
@Turbo87 I don't know how crazy you want to get with the CI setup but I think that we should be considering running a full on/off matrix of experiments on each CI build, that way we would catch any potential interactions between experiments. I don't think it needs to go so far as to test each node version with the full matrix of experiments but maybe we could pick one node version and then run the experiment matrix off it as a smoke test? The current issue with the Beta branch was introduced on 1st March and would have shown on any test that disabled the MU experiment. I'm happy to help set this up 😄 |
|
My approach would be:
Certainly can't catch all issues, but seems like a reasonable compromise. PR welcome, but we should discuss the details in the CLI call on Thursday. |
|
@Turbo87 - I completely agree with the suggested path forward in your last comment (#7798 (comment)). |
|
This approach seems to make sense and provides a decent balance between every permutation of experiments thus taking longer to the suite to pass and coverage of conditions. In my case, there’s a bug somewhere as the test suite doesn’t pass with the experiment enabled. |
|
I submitted #7803 for refactoring the CI runs... |
rwjblue
left a comment
There was a problem hiding this comment.
Very excited for this progress!
lib/experiments/index.js
Outdated
| let experiments = { | ||
| MODULE_UNIFICATION: symbol('module-unification'), | ||
| DELAYED_TRANSPILATION: symbol('delayed-transpilation'), | ||
| BROCCOLI_MASTER: process.env.BROCCOLI_MASTER === '1', // Note: EXPERIMENTAL, DO NOT USE! |
There was a problem hiding this comment.
Hehe, these are all experimental 😉
There was a problem hiding this comment.
Lets make the flag: process.env.EMBER_CLI_BROCCOLI_1 (I don't like using _MASTER conceptually here)...
lib/models/builder.js
Outdated
|
|
||
| const broccoli = require('broccoli-builder'); | ||
| let broccoli; | ||
| if (this.broccoliMaster) { |
There was a problem hiding this comment.
I'd rather do the experiments check here, instead of in the build task
if (experiments.BROCCOLI_MASTER) {
} else {
}
lib/models/builder.js
Outdated
| .then(() => this.builder.build(willReadStringDir)) | ||
| .then(node => { | ||
| // broccoli-builder reformats the response into {directory, graph} | ||
| if (this.broccoliMaster) { |
There was a problem hiding this comment.
Lets do the experiments guard here directly also
lib/tasks/build.js
Outdated
| outputPath: options.outputPath, | ||
| environment: options.environment, | ||
| project: this.project, | ||
| broccoliMaster: experiments.BROCCOLI_MASTER, |
There was a problem hiding this comment.
Should be able to revert changes to this file once the builder itself does its own experiments check...
lib/tasks/serve.js
Outdated
| outputPath: options.outputPath, | ||
| project: this.project, | ||
| environment: options.environment, | ||
| broccoliMaster: experiments.BROCCOLI_MASTER, |
There was a problem hiding this comment.
Should be able to revert changes to this file once the builder itself does its own experiments check...
2832349 to
11e4a70
Compare
lib/models/builder.js
Outdated
| }); | ||
| } else { | ||
| this._cleanupPromise = this.builder.cleanup(); | ||
| } |
There was a problem hiding this comment.
you can simplify this using:
this._cleanupPromise = Promise.resolve().then(() => this.builder.cleanup());which should work for both Broccoli 0.x and 1.x
tests/unit/models/builder-test.js
Outdated
|
|
||
| it('calls instrumentation.stop(build, result, resultAnnotation)', function() { | ||
| let mockAnnotation = 'MockAnnotation'; | ||
| if (!experiments.BROCCOLI_MASTER) { |
There was a problem hiding this comment.
this should be BROCCOLI_1, right?
tests/unit/models/builder-test.js
Outdated
| it('allows addons to add promises preBuild', function() { | ||
| let preBuild = td.replace(addon, 'preBuild', td.function()); | ||
| td.when(preBuild(), { ignoreExtraArgs: true, times: 1 }).thenReturn(Promise.resolve()); | ||
| if (!experiments.BROCCOLI_MASTER) { |
c0839d4 to
5e2c13a
Compare
5e2c13a to
b13e0bf
Compare
|
FYI - I just released broccoli@2.0.0-beta.2 (updates deps, drops RSVP, drops Node 4). |
|
👌 |
|
@oligriffiths - I just rebased, added the bump commit to broccoli@2.0.0-beta.2, and force pushed to kick off a new CI run. I think this is very close to being landable... |
|
Restarted some of the CI builds (they were failing on the |
|
@rwjblue thanks, I saw that, good to know you can manually restart them, was gonna do a noop commit |
bin/ember
Outdated
| }).catch((err) => { | ||
| // should not normally reach here | ||
| // this handles the case where console-ui is broken | ||
| console.error(err); |
There was a problem hiding this comment.
In general we would prefer to not mutate this file. But this may be an exception, @rwjblue c/d?
There was a problem hiding this comment.
Chatted with @krisselden in slack about this, I think we can probably move this to lib/cli.js and still handle the broken scenario.
lib/models/builder.js
Outdated
| constructor(options) { | ||
| super(options); | ||
|
|
||
| this.broccoli2 = Boolean(options.broccoli2 === undefined ? experiments.BROCCOLI_2 : options.broccoli2); |
There was a problem hiding this comment.
I think it would be better to remove this.broccoli2 completely, and replace it with direct experiments.BROCCOLI_2 checks...
There was a problem hiding this comment.
I couldn’t see how to mock that property in tests. I want to compare with the property on and off in the same test.
There was a problem hiding this comment.
Why? I think having tests around the expected behaviors should be enough. In general, from the outside, I don't think which builder we use should actually matter much, right?
There was a problem hiding this comment.
Well, we want to ensure that the files are exactly the same between both versions.
I guess if we have a fixture directory and compare against that, that'd also work.
There was a problem hiding this comment.
Totally agreed. I think the goal here should be that the migration is seemless and the output is identical. And we should be able to do that via fixtures (either inside the file system, or just via fixturify in the test itself)..
There was a problem hiding this comment.
Cool. Are we doing this anywhere already?
lib/models/builder.js
Outdated
| super(options); | ||
|
|
||
| this.broccoli2 = Boolean(options.broccoli2 === undefined ? experiments.BROCCOLI_2 : options.broccoli2); | ||
| this.systemTemp = Boolean(options.systemTemp === undefined ? experiments.SYSTEM_TEMP : options.systemTemp); |
There was a problem hiding this comment.
Same RE: experiment checks. In general it should not be possible to force these experiments to true without process.env.EMBER_CLI_* is set...
| * @param node The node returned from Broccoli builder | ||
| */ | ||
| compatNode(node) { | ||
| if (this.broccoli2) { |
There was a problem hiding this comment.
I was hoping that we could structure the code such that the broccoli@2 case is the "normal" case, and we do any shimming/polyfilling for the older broccoli-builder APIs...
There was a problem hiding this comment.
I think we should do that once we move out of experimental mode
package.json
Outdated
| "chai-as-promised": "^7.0.0", | ||
| "chai-files": "^1.2.0", | ||
| "co": "^4.6.0", | ||
| "dir-compare": "^1.4.0", |
There was a problem hiding this comment.
Comparing the directory structure and files for a Broccoli-builder vs broccoli 2.0 build to ensure they’re identical.
There was a problem hiding this comment.
Hmm, I think in general I'd prefer to use something like:
expect(fixturify.readSync(oneDir)).to.deep.equal(fixturify.readSync(twoDir))
There was a problem hiding this comment.
the more you know. Will test that.
There was a problem hiding this comment.
Will that compare file contents/hash?
There was a problem hiding this comment.
fixturify.readSync loads an entire directory (recursively) into a POJO (where the values are the string contents of the individual files).
Snippet from the readme:
var fixturify = require('fixturify')
var obj = {
'foo.txt': 'foo.txt contents',
'subdir': {
'bar.txt': 'bar.txt contents'
}
}
fixturify.writeSync('testdir', obj) // write it to disk
fixturify.readSync('testdir') // => deep-equals objThere was a problem hiding this comment.
@rwjblue are there already tests that already assert the output of the build is correct?
| } else { | ||
| broccoli = require('broccoli-builder'); | ||
| if (this.systemTemp) { | ||
| console.warn('EMBER_CLI_SYSTEM_TEMP only works in combination with EMBER_CLI_BROCCOLI_2'); |
There was a problem hiding this comment.
we should simply error here
There was a problem hiding this comment.
Will need to isolate tests in that case, because we can't do only combo environment variables (e.g. BROCCOLI_2 and SYSTEM_TEMP). Right now, the SYSTEM_TEMP flag will cause this error when being run without setting BROCCOLI_2.
Will do a little refactor.
| if (experiments.BROCCOLI_2) { | ||
| expect(result.graph.__heimdall__).to.not.be.undefined; | ||
| } else { | ||
| expect(result.graph.constructor.name).to.equal('Node'); |
There was a problem hiding this comment.
Not sure I understand the question...
|
Updated to ensure |
|
Just rebased against master to get some of the CI fixes that have landed... |
7cd2082 to
8607dda
Compare
|
@rwjblue tests all passing 🎉 |
|
@krisselden I had to remove your changes to get tests passing. Things have changed a bit since you implemented them, and im not 100% sure what they were changing. So if you wouldn't mind testing this branch now, and see if you get the same errors, I'd appreciate it. |
Ok, lots of changes since this review, gonna dismiss and re-tag
|
Rebased and updated broccoli to 2.0.0-beta.3... |
|
Whoop 🎉 |
What
Once broccolijs/broccoli#363 merges, this PR adds support for broccoli 2.0 in ember-cli via
BROCCOLI_2environment flag. If there is a better way to do this, please LMK and I will change.The requisite change is to require the
broccolipackage, and to reformat the response from the broccolibuild()method, into:Test
In my testing, the output of both the 0-18x series and master is the same, I verified this with:
It should output nothing.
To test using the system temp directory, do:
Updated tests to validate the build results are the same, and support for system tmp dir.