Skip to content

#53 properly test next-on-netlify in onBuild #65

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

Merged
merged 7 commits into from
Dec 2, 2020
Merged

Conversation

lindsaylevine
Copy link

@lindsaylevine lindsaylevine commented Nov 25, 2020

Fixes #53

@lindsaylevine lindsaylevine added the type: chore work needed to keep the product and development running smoothly label Nov 25, 2020
@lindsaylevine
Copy link
Author

thought: we could maybe try to get a dist from /sample

@lindsaylevine lindsaylevine marked this pull request as draft November 25, 2020 11:10
test/index.js Outdated
@@ -32,12 +32,22 @@ const changeCwd = function (cwd) {
return process.chdir.bind(process, originalCwd)
}

// Move .next from sample project to current directory
const moveNextDist = function () {
// Use copySync because cpx doesn't copy hidden files
Copy link

Choose a reason for hiding this comment

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

Do you mean dotfiles by "hidden files"?
If so, I believe cpx does support it (see this issue). The problem might come from the globbing pattern instead. Most globbing libraries will ignore dotfiles with * and ** unless some dotfile option is passed. However, .* will work (see this comment).

Copy link
Author

Choose a reason for hiding this comment

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

oh huh i was going off this one but gotchu

Copy link

Choose a reason for hiding this comment

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

If that does not work, cpy could also be used.

Copy link
Author

Choose a reason for hiding this comment

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

ive tried several things to copy .next with cpx and none have worked for me, feel free to pull n try n prove me wrong !!!

Copy link

Choose a reason for hiding this comment

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

Did it work with cpy instead?

Copy link
Author

Choose a reason for hiding this comment

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

nope

Copy link

Choose a reason for hiding this comment

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

The following commit fixes it with cpy: b099569
I haven't pushed it so you can review it first.

Copy link
Author

Choose a reason for hiding this comment

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

i was def using cpy wrong, the word dot literally isnt even included in the readme

Screen Shot 2020-12-01 at 5 58 31 AM

thanks for fixing!!!!!

Copy link
Author

@lindsaylevine lindsaylevine Dec 1, 2020

Choose a reason for hiding this comment

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

ahhhh i cherry-picked and your commit fails the tests. im gonna rebase it out for now; could you update your branch and make sure the tests pass there and PR it into this branch?

Copy link

@ehmicky ehmicky Dec 1, 2020

Choose a reason for hiding this comment

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

dot is part of globby which is mentioned there :)

I fixed the bug and pushed to this PR in 7aa933c 👍

@lindsaylevine lindsaylevine force-pushed the ll/test-non branch 11 times, most recently from 8952673 to 37ec572 Compare November 27, 2020 09:23
@lindsaylevine lindsaylevine marked this pull request as ready for review November 27, 2020 09:26
@lindsaylevine
Copy link
Author

lindsaylevine commented Nov 27, 2020

re: the conversation around the sample project/fixture - i hear what youre saying but dont see nearly a big enough issue to justify why certain files need to be removed. next-on-netlify has a ton of sample projects embedded in its cypress and test directories, with respective package.json filees and .gitignore files. when /sample was on the root level of the project, it existed with these same files (package.json required to, well, run the project to test the plugin as a local plugin and .gitignore to avoid committing files relevant to that project). if you'd really like, we can combine the .gitignore with the top-level, but because the sample project requires different dependencies to run as a local plugin, i don't think it makes sense to combine package.json files. i hope this makes sense! the one thing i will say is that sample doesnt really belong with the other fixtures and so i will move it up a level to /test/sample

@ehmicky
Copy link

ehmicky commented Nov 30, 2020

What you say makes sense. However, when it comes to having multiple package.json, we do need to consider the following drawbacks:

  • This requires adding cd ... && npm install in the CI, which makes CI much slower. It also makes local development setup (since multiple directories node_modules would now need to be installed)
  • Dependencies upgrades would now need to be done in multiple package.json
  • At the moment, this is a single sample project. But new tests might add more of them, which would increase that maintenance cost.

Separating which dependencies are needed in specific samples/fixtures from the main dependencies is nice, but it feels to me that benefit would be outweighed by those drawbacks. Just adding samples/fixtures to the top-level package.json devDependencies would just work without any of those drawbacks. What do you think?

@lindsaylevine
Copy link
Author

removing the package.json from the sample dir seems to interfere with testing the local plugin within the /sample project, which is and has been its primary purpose (see TESTING.md from original commit of the sample dir). we cant test with netlify cli without a package.json and the standard Next.js essentials. this is essential to plugin development and so unless you have a way to run netlify build and netlify deploy from sample without a package.json and the files you claim to be unnecessary, i'm going to assert the need to keep things as is.

@lindsaylevine
Copy link
Author

separate issue: the plugin won't install as a local plugin with the tests, it seems. it complains about the jest keywords being undefined. unclear at this moment if this is just local plugin specific or an issue with installing the plugin in prod as well (that wouldn't make sense, though, since we have tests in main/published). what's the fix here for local plugin installation? not sure if it's obvious or a plugin issue, happy to open an issue as well.

@ehmicky
Copy link

ehmicky commented Dec 1, 2020

not sure if it's obvious or a plugin issue, happy to open an issue as well.

Yes, that might be good (including build logs and steps to reproduce), thanks!

@lindsaylevine
Copy link
Author

i think this should be good now!!!!!!!!! @ehmicky

@@ -0,0 +1,2 @@
const plugin = require('../../../..')
module.exports = plugin
Copy link

Choose a reason for hiding this comment

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

This file can be removed thanks to netlify.toml using ../.. directly.

Copy link

@ehmicky ehmicky left a comment

Choose a reason for hiding this comment

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

🎉 🎉 🎉

(Note: one small comment about a file which can be removed)

@lindsaylevine lindsaylevine merged commit 9da8be5 into main Dec 2, 2020
@lindsaylevine lindsaylevine deleted the ll/test-non branch December 2, 2020 17:51
serhalp pushed a commit that referenced this pull request Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: chore work needed to keep the product and development running smoothly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Properly test nextOnNetlify functionality in onBuild part of plugin
2 participants