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

Calculate a partial fence difference based on git changes since a provided oid #101

Conversation

Adjective-Object
Copy link
Collaborator

Adds a CLI flag to only check fences changed since a given git OID / refname.
This diffs against the current git index to serve everything from git's object DB instead of going to disk.

The process is:

  • user specifies --sinceGitHash on the command line
  • we get the diff with the index
  • from the diff we read the changes to the fence.json files, and diff the current vs old versions of fences to create fenceDiffs
  • from the diff we parse the old and new versions of the changed typescript files to produce import sets, then diff those importSets to figure out the added/removeed import specifiers in each script.
  • We use those diffs to check which script files to re-evaluate
    • when a script file gains a new import, we re-check it against all fences that apply to it. If that import is to an internal file, each of its imports will also be checked
    • when a fence loses an "imports" rule, we re-check all files in the scope of that fence
    • when a fence loses an "dependencies" rule, we re-check all files in the scope of that fence
    • if a fence loses an "exports" rule, we abort, since you have to check all fences in that case (we can't know what is importing the fence)

Maxwell Huang-Hobbs and others added 10 commits August 11, 2021 16:52
Adds a faster file provider that discovers source and fence files with a
fast asyncronous file walk rather than by relying on typescript to
perform a syncronous walk + parse of the program.

We still use typescript to parse compilerOptions, but since we no longer
rely on the typescript program walk to identify files, we stub out file
discovery so only the initial config partse happens.

Also adds config options to support switching between the two providers,
since it will only work when all source files you intend to check fences
against fall under your rootDirs.
This is the case for OWA, but I don't know what other consumers look
like.

Depends on u/mahuangh/faster-source-providers-2
@Adjective-Object
Copy link
Collaborator Author

I realized while reviewing this change that the current way this is structured mishandles the adding of empty "dependencies" or "imports" sections. It treats that as a noop when in reality is a more constraining fence.

@Adjective-Object
Copy link
Collaborator Author

Added tests to the fence and import diffing logic, and covered the cases where sections are added / removed. Also updated the diffing logic to consider the removal of tags, so that when a tag is removed the whole fence is re-checked.

Together these cases should handle some false-negatives from the incremental fence check that we were missing in the full fence check.

Copy link
Collaborator Author

@Adjective-Object Adjective-Object left a comment

Choose a reason for hiding this comment

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

This change got pretty big after adding tests for the utility functions. Let me know if you want me to break it up into pieces again.

src/core/runner.ts Outdated Show resolved Hide resolved
src/core/runner.ts Outdated Show resolved Hide resolved
src/types/config/Config.ts Outdated Show resolved Hide resolved
src/utils/getFenceDiff.ts Outdated Show resolved Hide resolved
src/utils/getOptions.ts Outdated Show resolved Hide resolved
Copy link
Owner

@smikula smikula left a comment

Choose a reason for hiding this comment

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

Lots of comments. This is a tricky change — nice work! It's frustrating that there are so many cases where we need to bail out on validation, but it should be a big win for the most common cases.

@Adjective-Object
Copy link
Collaborator Author

I think I updated to the latest feedback, let me know if I missed something

@smikula smikula self-requested a review September 16, 2021 18:53
@smikula smikula merged commit 7acff60 into smikula:master Sep 16, 2021
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.

2 participants