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

fix(build): build/test on windows #6431

Merged
merged 6 commits into from Oct 27, 2022

Conversation

yamadayutaka
Copy link
Contributor

The basics

  • I branched from develop
  • My pull request is against develop
  • My code follows the style guide
  • I ran npm run format and npm run lint

The details

Resolves

Proposed Changes

  • chore(deps): bump @hyperjump/json-schema from 0.18.4 to 0.18.5
  • chore(deps): add gulp-gzip 1.4.2
  • build: migrate test scripts to gulp task (test_tasks.js)
  • build: not to use the grep command
  • build: normalize path

Behavior Before Change

The following commands are failing.

  • npm run build
  • npm run test

Behavior After Change

The following commands are successful.

  • npm run build
  • npm run test

Reason for Changes

For development on Windows environment.

Test Coverage

Confirmed in the following environments.

* chore(deps): bump @hyperjump/json-schema from 0.18.4 to 0.18.5
* chore(deps): add gulp-gzip 1.4.2
* build: migrate test scripts to gulp task (test_tasks.js)
* build: not to use the grep command
* build: normalize path
@NeilFraser NeilFraser requested review from cpcallen and removed request for NeilFraser September 28, 2022 17:09
@NeilFraser NeilFraser removed their assignment Sep 28, 2022
Copy link
Contributor

@cpcallen cpcallen left a comment

Choose a reason for hiding this comment

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

Hello Yutaka,

Thank you for sending us this substantial and very important PR. We definitely want to make it easier for Windows-using developers to be able to contribute to Blockly, and we know that their experience at the moment is not great. We really appreciate your efforts to help improve it.

Overall this PR looks very good, but there are some changes that will be needed before we can merge it. Most are minor (see below), but there are few slightly higher-level ones too:

  • Our current run_all-_tests script will plow ahead even when some of the tests fail. That's actually not great, because if build-debug fails we don't want to run metadata, mocha, generators, package, or node, but on the other hand your changes mean that an eslint failure will prevent any subsequent tests from running, which is too harsh. We want to run as many tests as we sensible can even if some of them fail—while making sure that GitHub CI still knows that there were failures.
  • It would be better to maintain the same nice formatting of test output as previously. See detailed comment below about this, but note also that it would be nice if we could suppress the "Starting" and "Finished" messages generated by Gulp.
  • There are quite a few functions in test_tasks.js that could probably be written more concisely as async functions.

Finally:

There is also the question of whether we want to be converting shell scripts to Gulp tasks. I put this question to the team, and the main observations were:

  • there is a general preference for node scripts over bash scripts, but
  • we're probably going to try to remove Gulp from our build system before too long.

To that end: your test_tasks.js is a good step on the road from bash to plain JS, and I'm happy to accept it with only minor fixes as noted—but please feel free also to modify it to NOT to use gulp features (and async features generally) where it doesn't need to: making it more like a plain, synchronous node script like tests/migration/validate-renamings.js could make it simpler and will probably be more helpful to us in the long run.

scripts/build_helper.js Outdated Show resolved Hide resolved
scripts/gulpfiles/build_tasks.js Outdated Show resolved Hide resolved
scripts/build_helper.js Outdated Show resolved Hide resolved
scripts/gulpfiles/build_tasks.js Outdated Show resolved Hide resolved
scripts/gulpfiles/build_tasks.js Outdated Show resolved Hide resolved
scripts/gulpfiles/test_tasks.js Outdated Show resolved Hide resolved
Comment on lines 137 to 139
if (failed === 0) {
done();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The callback should always be (eventually) called, but it can be passed an Error if the task fails. Try something like:

Suggested change
if (failed === 0) {
done();
}
done(failed > 0 ? new Error(/* useful message */) : undefined);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the implementation to no callbacks.

function generators(done) {
fs.mkdirSync(TMP_DIR);

execSync('node tests/generators/run_generators_in_browser.js');
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this just be a require('../../tests/generators/run_generators_in_browser.js)`?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed as suggested.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the execution of run_mocha_tests_in_browser.js as well.

Comment on lines 207 to 212
if (failed === 0) {
console.log(`${BOLD_GREEN}All generator tests passed.${ANSI_RESET}`);
done();
} else {
console.log(`${BOLD_RED}Failures in ${failed} generator tests.${ANSI_RESET}`);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

As above: done should always be called.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the implementation to no callbacks.

scripts/build_helper.js Outdated Show resolved Hide resolved
@yamadayutaka
Copy link
Contributor Author

Thank you for reviewing my PR.
I will check and fix what you pointed out.

@yamadayutaka
Copy link
Contributor Author

yamadayutaka commented Oct 3, 2022

Hello @cpcallen ,

I changed it based on your comments, so please check it.
Also, I made the following changes:

  • Formatting test output as previously.
  • Always continue even if a test unit fails.
  • Suppress the gulp messages.
  • Fix test_tasks.js to pass eslint.

* Add JSDoc comment
* Line length <= 80 characters.
* Formatting test output as previously.
* Always continue even if a test unit fails.
* Suppress the gulp messages.
* Fix test_tasks.js to pass eslint.
@yamadayutaka
Copy link
Contributor Author

image
Sorry, I overlooked "hidden conversations".
I will check and fix what you pointed out.

@yamadayutaka
Copy link
Contributor Author

I also fixed the overlooked content, so please check it.

Copy link
Contributor

@cpcallen cpcallen left a comment

Choose a reason for hiding this comment

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

Sorry it's taken me so long to re-review this PR. With your updates everything is looking great. Thanks for taking the time to do this work, and then additionally to respond so positively to all of my nit-picking. A big thank-you from all of us.

Comment on lines +107 to +109
entry: posixPath((argv.compileTs) ?
path.join(TSC_OUTPUT_DIR, CORE_DIR, 'main.js') :
path.join(CORE_DIR, 'main.js')),
Copy link
Contributor

Choose a reason for hiding this comment

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

It appears that you are trying to helpfully merge in code from getChunkOptions that I should have deleted that code in PR #6220. Ooops! Since it obviously hasn't been causing any problems until now I'm not going to block this PR because of my own mistake.

I believe that if I had removed that code as I intended to then the you would have written this instead, and I will apply this fix in another PR I am preparing that touches all of this again anyway:

Suggested change
entry: posixPath((argv.compileTs) ?
path.join(TSC_OUTPUT_DIR, CORE_DIR, 'main.js') :
path.join(CORE_DIR, 'main.js')),
entry: posixPath(path.join(CORE_DIR, 'main.js')),

Comment on lines -523 to -525
if (argv.compileTs) {
chunks[0].entry = path.join(TSC_OUTPUT_DIR, chunks[0].entry);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I should have deleted this bit a long time ago.

@cpcallen cpcallen merged commit 52879dd into google:develop Oct 27, 2022
@cpcallen cpcallen changed the title build: build/test on windows fix(build): build/test on windows Oct 27, 2022
@github-actions github-actions bot added the PR: fix Fixes a bug label Oct 27, 2022
@cpcallen
Copy link
Contributor

Hi @yamadayutaka: @rachel-fenichel ran in to a small problem with npm run build:generators on Linux, which turned out to be caused by the trailing / in the call rimraf('build/generators/'). She's fixed this in PR #6588; can you check to make sure that that change does not break anything on Windows?

@yamadayutaka
Copy link
Contributor Author

Hi @cpcallen and @rachel-fenichel, Sorry for the lack of confirmation. Thank you for your fix.
I have confirmed that it works fine on Windows.

@cpcallen
Copy link
Contributor

cpcallen commented Nov 1, 2022

Hi @cpcallen and @rachel-fenichel, Sorry for the lack of confirmation. Thank you for your fix. I have confirmed that it works fine on Windows.

Thanks for the confirmation!

cpcallen added a commit to cpcallen/blockly that referenced this pull request Nov 17, 2022
The bash script tests/run_all_tests.js was deleted in PR google#6431, where
it was replaced by `scripts/gulpfiles/test_tasks.js`, but it was
inadvertently resurrected by PR google#6475, apparently due to an error when
manually resolving conflicts for merge commit 00676ed.

Begone, undead script!
cpcallen added a commit that referenced this pull request Nov 21, 2022
The bash script tests/run_all_tests.sh was deleted in PR #6431, where
it was replaced by scripts/gulpfiles/test_tasks.js, but it was
inadvertently resurrected by PR #6475, apparently due to an error when
manually resolving conflicts for merge commit 00676ed.

Begone, undead script!
@cpcallen cpcallen linked an issue Jan 11, 2023 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: fix Fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build failing on Windows
3 participants