Skip to content

support new embroider working dir introduced in embroider/compat >3.1 - #387

Merged
RobbieTheWagner merged 5 commits into
ember-cli-code-coverage:masterfrom
chrismllr:master
Nov 20, 2023
Merged

RobbieTheWagner merged 5 commits into
ember-cli-code-coverage:masterfrom
chrismllr:master

Conversation

@chrismllr

Copy link
Copy Markdown
Contributor

Relates to #386

Allow Istanbul to observe the correct files when embroider builds into its new working directory location.

As of this commit: embroider-build/embroider@9e078f0, published in version 3.1.5 of @embroider/compat, Embroider uses a new locateEmbroiderWorkingDir method to obtain where the "rewritten" app is built to, which now resolves to node_modules/.embroider/rewritten-app.

@chrismllr chrismllr changed the title support new embroider working dir introduced in embroider/compat >3.1 Draft: support new embroider working dir introduced in embroider/compat >3.1 Aug 9, 2023
@chrismllr
chrismllr marked this pull request as draft August 9, 2023 18:31
@chrismllr chrismllr changed the title Draft: support new embroider working dir introduced in embroider/compat >3.1 support new embroider working dir introduced in embroider/compat >3.1 Aug 9, 2023
@NullVoxPopuli

Copy link
Copy Markdown

Do you have a sample app that proves that this works?

@chrismllr

Copy link
Copy Markdown
Contributor Author

@NullVoxPopuli Sure thing, I can see about duping the repro repo and applying these changes.

@chrismllr

chrismllr commented Aug 16, 2023 •

Copy link
Copy Markdown
Contributor Author

LEFT screenshot: Test run from reproduction repo (no coverage output): https://github.com/chrismllr/repro-code-coverage-embroider/actions/runs/5881955365/job/15951451547

RIGHT screenshot: Test run from fix repo (coverage output successfully): https://github.com/chrismllr/fix-code-coverage-embroider/actions/runs/5881976092/job/15951525068

Screenshot 2023-08-16 at 12 34 47 PM

Comment on lines +58 to +59
let version = pkgJSON['devDependencies']['@embroider/compat'];
let semver = require('semver');

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This admittedly feels flimsy, but this.project was not available in scope here (to pass on to something like ember-cli-version-checker)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a try/catch for importing/requiring the new locateEmbroiderWorkingDir method

@chrismllr chrismllr Nov 18, 2023 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to migrate to use the above, saw some issues in tests with fixturify-project usage (these values read were not the fixture libs output). This method also feels more stable. If the method exists, use it. Otherwise, use the original.

@kategengler

Copy link
Copy Markdown
Collaborator

cc @mansona for embroider support here (unless there is someone else I should ping?)

@chrismllr
chrismllr marked this pull request as ready for review August 17, 2023 14:32
@nickschot

nickschot commented Sep 13, 2023 •

Copy link
Copy Markdown

I think it may be necessary to bump the peerDep requirements on @embroider/core (?). Just tried this PR as a patch and ran into a case where it ended up using an older @embroider/shared-internals package on CI which didn't have the locateEmbroiderWorkingDir yet, breaking the build with a missing function error. Adding a resolution fixes it of course.

edit: other than that these changes appear to work fine for our ember-exam + coverage setup on both embroider v2 as well as latest v3.

@rogeraraujo90

Copy link
Copy Markdown

@chrismllr can you confirm if the current version is only working with embroider 1? I've tested with embroider 2 but no coverage was reported either. This is currently a blocker for me.

@rogeraraujo90

Copy link
Copy Markdown

cc: @ef4

@RobbieTheWagner

Copy link
Copy Markdown
Collaborator

@chrismllr I would love to get this in, but want to make sure it doesn't make things blow up. We probably at least need to guard locateEmbroiderWorkingDir right?

@SergeAstapov

Copy link
Copy Markdown
Contributor

@chrismllr @RobbieTheWagner would it worth adding a test Embroider app to ensure this addon works?

@RobbieTheWagner

Copy link
Copy Markdown
Collaborator

@SergeAstapov there is one https://github.com/ember-cli-code-coverage/ember-cli-code-coverage/tree/master/test-packages/my-embroider-app

I think we would need a couple with different embroider versions. Tests are currently failing for this embroider app, so if anyone has time to help with this, I would appreciate it!

@chrismllr

Copy link
Copy Markdown
Contributor Author

Hey all, apologies for the lack of updates here, I have been taking paternity leave 👶

I can attempt to get in to get some tests added as time permits, but if there's a way for someone to pick up and run with it, I can assist in any way I can!

As for some questions:

@chrismllr I would love to get this in, but want to make sure it doesn't make things blow up. We probably at least need to guard locateEmbroiderWorkingDir right?

Could you clarify? Currently, its behind a semver.satisfies , so hopefully it would only be accessed if the version of embroider/core was sufficient (that method was introduced within 3.1)

@chrismllr can you confirm if the current version is only working with embroider 1? I've tested with embroider 2 but no coverage was reported either. This is currently a blocker for me.

Nothing beyond my local testing; I've got a test repo mentioned in the original issue, but this may require some tests as others have mentioned.

@RobbieTheWagner

Copy link
Copy Markdown
Collaborator

I merged #398 so not sure if we still need this PR?

@chrismllr

Copy link
Copy Markdown
Contributor Author

I merged #398 so not sure if we still need this PR?

Ah, does that PR use some other method to tell istanbul where to look for app files?

@AmauryD

AmauryD commented Nov 14, 2023

Copy link
Copy Markdown
Contributor

@chrismllr I've only added a test for embroider/compat > 3.1. But i haven't changed anything related to this issue.

// '^3.1.0' remove when PR https://github.com/ember-cli-code-coverage/ember-cli-code-coverage/pull/387 is merged

@nickschot

Copy link
Copy Markdown

I merged #398 so not sure if we still need this PR?

Ah, does that PR use some other method to tell istanbul where to look for app files?

There don't appear to be any code changes to the core of code-coverage in the other PR, so I doubt it fixes it and it'd make this PR still required.

@chrismllr

Copy link
Copy Markdown
Contributor Author

@chrismllr I've only added a test for embroider/compat > 3.1. But i haven't changed anything related to this issue.

// '^3.1.0' remove when PR https://github.com/ember-cli-code-coverage/ember-cli-code-coverage/pull/387 is merged

I've added a commit to this fork to enable the above test to run on 3.1.0, and looks like its also pulled in some pnpm-lock updates per changes made in the last merged PR. Is there anything necessary to do to test the actions to run?

@chrismllr

chrismllr commented Nov 18, 2023 •

Copy link
Copy Markdown
Contributor Author

Currently working through the tests for 3.1, but all embroider tests for '^0.47.0', '^1.0.0', '^2.1.0' are passing 🎉

There look to be some discrepancies with how fixturify-project modifies the package.json vs how the code within the block I've edited in this PR reads pkgJSON. Not getting the same values.

- if `locateEmbroiderWorkingDir` exists, use it. otherwise use prior
- remove (seemingly) unnecessary update to ^3.0 peer dep
- remove semver. no longer used
@chrismllr

Copy link
Copy Markdown
Contributor Author

Altered the logic to use presence of the method instead of semver/ introspection of package.json. All tests passing for me locally!

@RobbieTheWagner
RobbieTheWagner merged commit 494396b into ember-cli-code-coverage:master Nov 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants