-
Notifications
You must be signed in to change notification settings - Fork 71
Fix #1180 Add the ability to build filters completely locally #1181
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
Open
Alex-302
wants to merge
18
commits into
master
Choose a base branch
from
fix/1180_local_build_from_cache
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
a8ac982
Fix #1180 Add the ability to build filters completely locally
Alex-302 dce899d
fix/lint errors in build.js
Alex-302 395bd2f
fix/Add --strip-generated-meta build flag for debug purposes
Alex-302 b656361
fix/lint
Alex-302 a1af0ab
merge parent branch into current one, resolve conflicts
slvvko 53c6a5c
- strip_generated_meta.js renamed to kebab-case
Alex-302 7af7209
Reused find_files.js in strip-generated-meta.js and build.js
Alex-302 576f7ef
use fs/promises in strip-generated-meta
Alex-302 a12947d
convert strip-generated-meta.js to TS
Alex-302 54a6df8
Upd docs
Alex-302 7a10cdb
Fixed invoking strip-generated-meta
Alex-302 337d24a
Fix lint error
Alex-302 9c694a6
strip meta in both platforms/ and temp/platforms/, add tests
Alex-302 6875b74
lint errors
Alex-302 a6919b5
Fix recursive walk inside platforms dirs
Alex-302 aea8ac6
feat(build): add CLI argument validation, added tests
Alex-302 a927ae8
Added eol-last in build-config.ts
Alex-302 3c74498
fix md
Alex-302 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| import { | ||
| describe, it, expect, | ||
| } from 'vitest'; | ||
| // eslint-disable-next-line import/no-unresolved | ||
| import { parseFlags, validateFlags, validateArgs } from '../build-config.js'; | ||
|
|
||
| describe('parseFlags', () => { | ||
| it('parses --include and --skip', () => { | ||
| const flags = parseFlags(['--include=1,2,3', '--skip=12,24']); | ||
| expect(flags.includedFilterIDs).toEqual([1, 2, 3]); | ||
| expect(flags.excludedFilterIDs).toEqual([12, 24]); | ||
| }); | ||
|
|
||
| it('parses short forms -i and -s', () => { | ||
| const flags = parseFlags(['-i=1,2', '-s=3']); | ||
| expect(flags.includedFilterIDs).toEqual([1, 2]); | ||
| expect(flags.excludedFilterIDs).toEqual([3]); | ||
| }); | ||
|
|
||
| it('parses --report', () => { | ||
| const flags = parseFlags(['--report=report.txt']); | ||
| expect(flags.rawReportPath).toBe('report.txt'); | ||
| }); | ||
|
|
||
| it('parses all boolean flags', () => { | ||
| const flags = parseFlags([ | ||
| '--use-cache', | ||
| '--no-patches-prepare', | ||
| '--strip-generated-meta', | ||
| ]); | ||
|
|
||
| expect(flags.useCache).toBe(true); | ||
| expect(flags.noPatchesPrepare).toBe(true); | ||
| expect(flags.stripGeneratedMeta).toBe(true); | ||
| }); | ||
|
|
||
| it('ignores unknown arguments', () => { | ||
| const flags = parseFlags(['--mode=unknown', '--foo']); | ||
| expect(flags.useCache).toBe(false); | ||
| }); | ||
|
|
||
| it('filters out NaN from invalid IDs', () => { | ||
| const flags = parseFlags(['--include=1,abc,3']); | ||
| expect(flags.includedFilterIDs).toEqual([1, 3]); | ||
| }); | ||
| }); | ||
|
|
||
| describe('validateFlags', () => { | ||
| it('allows valid single flags', () => { | ||
| const flags = parseFlags(['--use-cache']); | ||
| expect(validateFlags(flags)).toBeNull(); | ||
| }); | ||
|
|
||
| it('allows --generate-cache with --include', () => { | ||
| const flags = parseFlags(['--generate-cache', '--include=1,2,3']); | ||
| expect(validateFlags(flags)).toBeNull(); | ||
| }); | ||
|
|
||
| it('rejects --use-cache combined with --generate-cache', () => { | ||
| const flags = parseFlags(['--use-cache', '--generate-cache']); | ||
| const result = validateFlags(flags); | ||
| expect(result?.type).toBe('error'); | ||
| expect(result?.message).toContain('mutually exclusive'); | ||
| expect(result?.message).toContain('DEVELOPMENT.md'); | ||
| }); | ||
|
|
||
| it('errors on --generate-cache combined with --strip-generated-meta', () => { | ||
| const flags = parseFlags(['--generate-cache', '--strip-generated-meta']); | ||
| const result = validateFlags(flags); | ||
| expect(result?.type).toBe('error'); | ||
| expect(result?.message).toContain('--strip-generated-meta'); | ||
| expect(result?.message).toContain('incompatible'); | ||
| expect(result?.message).toContain('DEVELOPMENT.md'); | ||
| }); | ||
|
|
||
| it('errors on --generate-cache combined with --no-patches-prepare', () => { | ||
| const flags = parseFlags(['--generate-cache', '--no-patches-prepare']); | ||
| const result = validateFlags(flags); | ||
| expect(result?.type).toBe('error'); | ||
| expect(result?.message).toContain('--no-patches-prepare'); | ||
| expect(result?.message).toContain('DEVELOPMENT.md'); | ||
| }); | ||
|
|
||
| it('errors on multiple incompatible flags with --generate-cache', () => { | ||
| const flags = parseFlags([ | ||
| '--generate-cache', | ||
| '--strip-generated-meta', | ||
| '--no-patches-prepare', | ||
| ]); | ||
| const result = validateFlags(flags); | ||
| expect(result?.type).toBe('error'); | ||
| expect(result?.message).toContain('--strip-generated-meta and --no-patches-prepare'); | ||
| expect(result?.message).toContain('are incompatible'); | ||
| expect(result?.message).toContain('DEVELOPMENT.md'); | ||
| }); | ||
|
|
||
| it('allows multiple valid combinations', () => { | ||
| const flags = parseFlags([ | ||
| '--include=1,2', | ||
| '--no-patches-prepare', | ||
| '--strip-generated-meta', | ||
| ]); | ||
| expect(validateFlags(flags)).toBeNull(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('validateArgs', () => { | ||
| it('allows all valid arguments', () => { | ||
| expect(validateArgs(['--include=1,2'])).toBeNull(); | ||
| expect(validateArgs(['-i=1'])).toBeNull(); | ||
| expect(validateArgs(['--skip=12'])).toBeNull(); | ||
| expect(validateArgs(['-s=12'])).toBeNull(); | ||
| expect(validateArgs(['--report=file.txt'])).toBeNull(); | ||
| expect(validateArgs(['--use-cache'])).toBeNull(); | ||
| expect(validateArgs(['--generate-cache'])).toBeNull(); | ||
| expect(validateArgs(['--no-patches-prepare'])).toBeNull(); | ||
| expect(validateArgs(['--strip-generated-meta'])).toBeNull(); | ||
| }); | ||
|
|
||
| it('rejects random single-word arguments', () => { | ||
| expect(validateArgs(['unknown'])).toContain('Unknown argument: unknown'); | ||
| expect(validateArgs(['build'])).toContain('Unknown argument: build'); | ||
| expect(validateArgs(['123'])).toContain('Unknown argument: 123'); | ||
| }); | ||
|
|
||
| it('includes DEVELOPMENT.md hint in unknown argument error', () => { | ||
| const result = validateArgs(['saasdasd']); | ||
| expect(result).toContain('DEVELOPMENT.md'); | ||
| }); | ||
|
|
||
| it('rejects arbitrary flags', () => { | ||
| expect(validateArgs(['--foo'])).toContain('Unknown argument: --foo'); | ||
| expect(validateArgs(['--arg'])).toContain('Unknown argument: --arg'); | ||
| expect(validateArgs(['--unknown'])).toContain('Unknown argument: --unknown'); | ||
| expect(validateArgs(['-a'])).toContain('Unknown argument: -a'); | ||
| expect(validateArgs(['-x'])).toContain('Unknown argument: -x'); | ||
| expect(validateArgs(['-1'])).toContain('Unknown argument: -1'); | ||
| expect(validateArgs(['-Z'])).toContain('Unknown argument: -Z'); | ||
| }); | ||
|
|
||
| it('rejects common typos of valid flags', () => { | ||
| // Extra letter at end | ||
| expect(validateArgs(['--use-cachee'])).toContain('Unknown argument: --use-cachee'); | ||
| expect(validateArgs(['--generate-cach'])).toContain('Unknown argument: --generate-cach'); | ||
| expect(validateArgs(['--strip-generate-meta'])).toContain('Unknown argument: --strip-generate-meta'); | ||
| // Swapped / missing letter | ||
| expect(validateArgs(['--usecache'])).toContain('Unknown argument: --usecache'); | ||
| }); | ||
|
|
||
| it('rejects near-miss prefixes for value flags', () => { | ||
| expect(validateArgs(['--includes=1'])).toContain('Unknown argument: --includes=1'); | ||
| expect(validateArgs(['--skips=12'])).toContain('Unknown argument: --skips=12'); | ||
| }); | ||
|
|
||
| it('rejects --report without =value (bare flag)', () => { | ||
| expect(validateArgs(['--report'])).toContain('Unknown argument: --report'); | ||
| }); | ||
|
|
||
| it('rejects unknown arguments regardless of position among valid args', () => { | ||
| expect(validateArgs(['--include=1', 'junk'])).toContain('Unknown argument: junk'); | ||
| expect(validateArgs(['junk', '--include=1'])).toContain('Unknown argument: junk'); | ||
| expect(validateArgs(['--use-cache', '-a', '--skip=2'])).toContain('Unknown argument: -a'); | ||
| expect(validateArgs(['--genarate-cache'])) | ||
| .toContain('Unknown argument: --genarate-cache'); | ||
| }); | ||
|
|
||
| it('handles empty array (no args)', () => { | ||
| expect(validateArgs([])).toBeNull(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yarn strip-generated-metapoints toscripts/build/strip-generated-meta.ts, but this file only exportsstripGeneratedMetaFromDir()and never invokes it.I verified locally that the command exits successfully without touching the generated files. Please add a CLI entrypoint here, or point the npm script to a small wrapper that actually calls the function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 7a10cdb