Add the ability to use local optimization_config#1186
Add the ability to use local optimization_config#1186mu-hun wants to merge 3 commits intofix/1180_local_build_from_cachefrom
Conversation
6507dd5 to
3bcca2e
Compare
df6f136 to
424e89f
Compare
Please specify how to perform the test.I have just aligned with the flags you created (#1181). In the PR description,
|
e04f297 to
867ab88
Compare
Crash fixed7691c68. The cache dir is wiped with Verification guideline (Draft)I tested the steps below, but the result had no output. Maybe I wrote the steps incorrectly or missed something.
If step 6 returns output, the stats cache is wired correctly end-to-end: grep -rF "||banggood.com^$domain=topic.lt" platforms/
# → prints matching lines with file pathsAfter restoring the hit count and running # Rule is absent (before change hit count to 9999) — cache working correctly:
grep -rF "||banggood.com^$domain=topic.lt" platforms/
# → no output |
3e2d9bd to
4bf108a
Compare
Adds support for downloading and reusing optimization config locally, so the optimization result can be checked before changes are deployed to the server. - `percent.json` is saved under `temp/optimization_config_cache/` and read from there when `--use-cache` is active. Both `--generate-cache` and `--use-cache` flags now include optimization config handling alongside the existing filter source caching. `@adguard/filters-compiler` is set to `AdguardTeam/FiltersCompiler#local_optimization_config` in `package.json`. This requires `dist/` to be committed to the branch, as GitHub shorthand installation does not trigger a build step. Also, I add integration tests for `optimizationConfigLocal` namespace. Verifies `--use-cache`` calls `setPath()` and `--generate-cache`` calls `generate()` + `setPath()` with the correct cache path. Dynamically imports build.js per test after `vi.resetModules()` to re-execute its module-level side effects with controlled `process.argv`. Mocks `fs`, `@adguard/filters-compiler`, and `find_files` to stay isolated.
Vitest test (optimization-e2e.test.js) compiles filter_1 against a self-contained tmp fixture with two synthetic rules — hits=0 rule must be absent from *_optimized.txt, hits=9999 rule must be present. No network, no prereqs. Runs in CI via existing yarn test. Local bash script (optimization-integration-e2e.sh) covers the same contract against the real generate-cache output. Key fixes baked in: - strips CRLF (\r) from grepped rule text to match compiler trim() - scopes grep to *_optimized.txt (non-optimized 1.txt retains all rules) - sets minPercent=0/maxPercent=100 so percent check passes with only 2 rules in stats vs ~17k in the real filter Adds yarn test:optimization-e2e script entry and updates AGENTS.md.
4bf108a to
ac373e9
Compare
|
The workflow should be followed as follows:
However, This needs to be updated. Also, need to fix Build CI Failed. |
Adds support for downloading and reusing the optimization config locally, allowing users to review the optimization results before deploying changes to the server.
This feature should be managed through the build option in the FiltersRegistry, not by FiltersCompiler.
The workflow
percent.jsonis stored intemp/optimization_config/and read from there when--use-cacheis enabled.optimization_config/percent.json, edit it locally, then use it in the build.Both
--generate-cacheand--use-cacheflags now include optimization config handling alongside the existing filter source caching.Note to
@adguard/filters-compiler@adguard/filters-compileris set toAdguardTeam/FiltersCompiler#local_optimization_configinpackage.json.This requires
dist/to be committed to the branch, as GitHub shorthand installation does not trigger a build step.