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

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

Merged
merged 5 commits into from Nov 20, 2023

Conversation

chrismllr
Copy link
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

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

@chrismllr
Copy link
Contributor Author

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

@chrismllr
Copy link
Contributor Author

chrismllr commented Aug 16, 2023

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
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
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

Copy link
Contributor Author

@chrismllr chrismllr Nov 18, 2023

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
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
Copy link

nickschot commented Sep 13, 2023

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

@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

cc: @ef4

@RobbieTheWagner
Copy link
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
Contributor

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

@RobbieTheWagner
Copy link
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
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
Collaborator

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

@chrismllr
Copy link
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
Copy link
Contributor

AmauryD commented Nov 14, 2023

@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

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
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
Copy link
Contributor Author

chrismllr commented Nov 18, 2023

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
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
1 check passed
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.

None yet

8 participants