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

feat(validate/webidl): add Web IDL validator #104

Merged
merged 9 commits into from
Sep 10, 2021

Conversation

tidoust
Copy link
Member

@tidoust tidoust commented Sep 9, 2021

This adds an IDL validation step, enabled by default. The IDL gets extracted from the spec through Reffy and validated with WebIDL2.js.

The step gets skipped if no IDL can be extracted from the spec.

Enabling the step by default should not have any noticeable impact on "well-known" specs, typically those that are in browser-specs. In particular, the IDL patches that we currently need to maintain in Webref are for specs that do not use spec-prod, except for the DeviceOrientation Event specification, whose IDL fix is being tracked in w3c/deviceorientation#88.

@sidvishnoi, FYI, I note that, in order to test locally, and on top of the changes you suggested in #93 (comment), I also needed to:

  1. Explicitly set the PUPPETEER_EXECUTABLE_PATH env variable to an empty string in src/build.ts line 182 through:
    process.env["PUPPETEER_EXECUTABLE_PATH"] = PUPPETEER_ENV.PUPPETEER_EXECUTABLE_PATH || '';
    
    ... as the code does not seem to like when the env variable is undefined.
  2. Set the GITHUB_ENV and GITHUB_PATH env varibles to an empty string in test/index.test.ts line 11 instead of /dev/null (perhaps simply because I'm on a Windows machine)

This would fix #87.

This adds an IDL validation step, enabled by default. The IDL gets extracted
from the spec through Reffy and validated with WebIDL2.js.

The step gets skipped if no IDL can be extracted from the spec.
@sidvishnoi
Copy link
Member

@tidoust This looks great! 😍 Thanks for working on this! I'll do testing and review in day tomorrow.


I've quickly pushed two small changes to main branch:

  • Run yarn lint to check for linting issues and yarn lint --write to autofix them (713c690).
  • Use a cross platform null device in tests (4b53b84). Would love if you can test it on Windows.

@sidvishnoi
Copy link
Member

Though, should we disable this check on ReSpec specs as ReSpec already does validation using webidl2?

@tidoust
Copy link
Member Author

tidoust commented Sep 10, 2021

Use a cross platform null device in tests (4b53b84). Would love if you can test it on Windows.

Unless I'm missing something, that update does not work on Windows. The call to fs.existsSync done in the code of the @action/core returns false on Windows. FWIW, I tried to switch to Node.js v16.x in case there is some magic in that version that handles the null device but that does not change anything.

@tidoust
Copy link
Member Author

tidoust commented Sep 10, 2021

Though, should we disable this check on ReSpec specs as ReSpec already does validation using webidl2?

When ReSpec detects invalid IDL, what happens in practice? If the build step fails, then we don't really need to add logic to the IDL validation step: it won't run since build fails. If the build still goes through with some reported errors, then I would actually prefer to keep the IDL validation in this step because it will actually block publication, which is what I think we want here: catch IDL errors early (typically in pull requests) so that they cannot get published in the first place.

@sidvishnoi
Copy link
Member

By default, ReSpec build fails on IDL errors and action exits with error, so there's nothing to be done. But if BUILD_FAIL_ON: nothing is provided, build will pass regardless of errors - so we need IDL validation step only in this case. Though, that logic might require some work (as final toolchain isn't available to src/prepare-validate.ts yet), so lets leave it for now.

Unless I'm missing something, that update does not work on Windows.

Lets also skip it for now then 😄

docs/examples.md Outdated Show resolved Hide resolved
src/validate-idl.ts Outdated Show resolved Hide resolved
src/validate-idl.ts Outdated Show resolved Hide resolved
src/validate-idl.ts Outdated Show resolved Hide resolved
src/validate-idl.ts Outdated Show resolved Hide resolved
tidoust and others added 5 commits September 10, 2021 14:41
Co-authored-by: Sid Vishnoi <8426945+sidvishnoi@users.noreply.github.com>
Co-authored-by: Sid Vishnoi <8426945+sidvishnoi@users.noreply.github.com>
Co-authored-by: Sid Vishnoi <8426945+sidvishnoi@users.noreply.github.com>
Co-authored-by: Sid Vishnoi <8426945+sidvishnoi@users.noreply.github.com>
test/index.test.ts Outdated Show resolved Hide resolved
@sidvishnoi sidvishnoi changed the title feat(validate/idl): add IDL validator feat(validate/webidl): add Web IDL validator Sep 10, 2021
Copy link
Member

@sidvishnoi sidvishnoi left a comment

Choose a reason for hiding this comment

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

:shipit:

@sidvishnoi sidvishnoi merged commit e228dcc into w3c:main Sep 10, 2021
github-actions bot added a commit that referenced this pull request Sep 10, 2021
SHA: e228dcc
Reason: push, by @sidvishnoi

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@sidvishnoi
Copy link
Member

Released in v2 ≡ v2.6.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add WebIDL validation
2 participants